diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e995d43e4..30482d5370 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,10 +112,12 @@ jobs: - uses: actions/checkout@v3 - uses: software-mansion/setup-scarb@v1 with: - scarb-version: "2.7.0" + scarb-version: "2.8.4" - run: | scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt --check - scarb --manifest-path crates/dojo-core/Scarb.toml fmt --check + scarb --manifest-path examples/simple/Scarb.toml fmt --check + scarb --manifest-path crates/dojo/core/Scarb.toml fmt --check + scarb --manifest-path crates/dojo/core-cairo-test/Scarb.toml fmt --check dojo-core-test: needs: build @@ -130,7 +132,7 @@ jobs: - uses: actions/checkout@v3 - run: | chmod +x /tmp/bins/sozo - /tmp/bins/sozo --manifest-path crates/dojo-core/Scarb.toml test + /tmp/bins/sozo --manifest-path crates/dojo/core/Scarb.toml test dojo-spawn-and-move-example-test: needs: build @@ -147,15 +149,6 @@ jobs: chmod +x /tmp/bins/sozo /tmp/bins/sozo --manifest-path examples/spawn-and-move/Scarb.toml test - dojo-world-bindings-check: - runs-on: ubuntu-latest - container: - image: ghcr.io/dojoengine/dojo-dev:v1.0.0-alpha.17 - steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - run: cargo run --bin dojo-world-abigen -- --check - clippy: runs-on: ubuntu-latest-4-cores container: @@ -201,5 +194,5 @@ jobs: nohup /tmp/bins/katana --accounts 2 --disable-fee & - run: | /tmp/bins/sozo --manifest-path examples/spawn-and-move/Scarb.toml build - /tmp/bins/sozo --manifest-path examples/spawn-and-move/Scarb.toml migrate apply + /tmp/bins/sozo --manifest-path examples/spawn-and-move/Scarb.toml migrate - run: hurl --test examples/rpc/**/*.hurl diff --git a/.tool-versions b/.tool-versions index aabe197960..dee4ebacd4 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -scarb 2.7.0 +scarb 2.8.4 starknet-foundry 0.30.0 diff --git a/Cargo.lock b/Cargo.lock index 5112d35e14..cc1f9676ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -578,7 +578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "alloy-rlp-derive", - "arrayvec", + "arrayvec 0.7.6", "bytes", ] @@ -908,6 +908,25 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "ansi-str" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cf4578926a981ab0ca955dc023541d19de37112bc24c1a197bd806d3d86ad1d" +dependencies = [ + "ansitok", +] + +[[package]] +name = "ansitok" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "220044e6a1bb31ddee4e3db724d29767f352de47445a6cd75e1a173142136c83" +dependencies = [ + "nom", + "vte", +] + [[package]] name = "anstream" version = "0.6.15" @@ -1172,6 +1191,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.6" @@ -1918,7 +1943,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools 0.10.5", "lazy_static", "lazycell", "log", @@ -2198,6 +2223,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + [[package]] name = "bytemuck" version = "1.18.0" @@ -2325,15 +2356,15 @@ dependencies = [ [[package]] name = "cainome" version = "0.4.6" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "anyhow", "async-trait", - "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", + "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", "cainome-cairo-serde-derive", - "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", - "cainome-rs 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", - "cainome-rs-macro 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", + "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", + "cainome-rs 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", + "cainome-rs-macro 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", "camino", "clap", "clap_complete", @@ -2361,7 +2392,7 @@ dependencies = [ [[package]] name = "cainome-cairo-serde" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "serde", "starknet 0.12.0", @@ -2371,7 +2402,7 @@ dependencies = [ [[package]] name = "cainome-cairo-serde-derive" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "proc-macro2", "quote", @@ -2395,7 +2426,7 @@ dependencies = [ [[package]] name = "cainome-parser" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "convert_case 0.6.0", "quote", @@ -2426,11 +2457,11 @@ dependencies = [ [[package]] name = "cainome-rs" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "anyhow", - "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", - "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", + "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", + "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", "camino", "prettyplease", "proc-macro2", @@ -2462,12 +2493,12 @@ dependencies = [ [[package]] name = "cainome-rs-macro" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?tag=v0.4.6#0c30f74923f68bced7380848148c22a8fc65075d" +source = "git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720#5c2616c273faca7700d2ba565503fcefb5b9d720" dependencies = [ "anyhow", - "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", - "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", - "cainome-rs 0.1.0 (git+https://github.com/cartridge-gg/cainome?tag=v0.4.6)", + "cainome-cairo-serde 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", + "cainome-parser 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", + "cainome-rs 0.1.0 (git+https://github.com/cartridge-gg/cainome?rev=5c2616c273faca7700d2ba565503fcefb5b9d720)", "proc-macro-error", "proc-macro2", "quote", @@ -2479,9 +2510,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a43421bf72645b3a562d264747166d6f093e960a69dfa38b67bb3209e370366" +checksum = "fd4d6659539ace9649c8e8a7434e51b0c50a7a700111d0a2b967dde220ddff49" dependencies = [ "cairo-lang-utils", "indoc 2.0.5", @@ -2493,9 +2524,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24242af537265add372896d9ab0678c86a68d3484281fbeb6d8a9d4d5bacf7c8" +checksum = "e2016966ed29f3a44487fd1bbdb05320fb6ea8ec46201c04c6b222ccb5264e0a" dependencies = [ "anyhow", "cairo-lang-defs", @@ -2510,25 +2541,27 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "indoc 2.0.5", - "salsa", + "rayon", + "rust-analyzer-salsa", + "semver 1.0.23", "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d28f38e1c62fed15a4de9f3c95741d6b24ef2a9e67a2b88a047eb6ea7de992e" +checksum = "50c804649297ca417206435ee3e8041d2100cc31ebf4a95bc4b92ed02dc63469" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712206b7be3fb1a33e50e1c30aa8502b4a461155fd93ad26213d0d8b242cb08d" +checksum = "e8fbda467ac36f73bb1879e1f741898fc719d6f9239a01cc422e6a023281319b" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -2537,15 +2570,15 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.12.1", - "salsa", + "rust-analyzer-salsa", "smol_str", ] [[package]] name = "cairo-lang-diagnostics" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3c8dc2bff2411fbf602d80a83b719e6e3955c1c5d767ec18b295fc92e8616a" +checksum = "c843ef4715e3d21de5388d02206db2506e2d2ec0e80e2629e0ae9900a08b8674" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -2555,9 +2588,9 @@ dependencies = [ [[package]] name = "cairo-lang-doc" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04a82d79c36047fe17f6d299053f35eb2b17c023f516730ca8c3945f046e02a" +checksum = "1a932262ab491cf248283ccbe6d584a76fd55fc85ae0c7879b2ad687c512a115" dependencies = [ "cairo-lang-defs", "cairo-lang-formatter", @@ -2565,14 +2598,14 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.12.1", - "salsa", + "rust-analyzer-salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaa8ac24c97770739f5a78d630b8515273c8b9f4aff34e1f88b988fac50340de" +checksum = "33a416c5871960fb4823160ebef2abc51e0c1b86fef1e97a1ebb2e5f3c3795d3" dependencies = [ "cairo-lang-utils", "good_lp", @@ -2580,23 +2613,24 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4596331565fe61d10a0a6a03ace2b9d0ba93f03ee12a8450fe9252a6fee770f3" +checksum = "47189e0cb84b21defd201af4cf24a94c6b0d09f48706cf659c9ffa0def8a7a43" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", "path-clean", - "salsa", + "rust-analyzer-salsa", + "semver 1.0.23", "serde", "smol_str", ] [[package]] name = "cairo-lang-formatter" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b8eb08e511d6e6df51370cdc7d85f0de9a38c8b14a15762665c60c2df6d32d" +checksum = "6409ff1f4a93ce7c0968d9d857d2a8c03657617a827159d33f978110b718b31d" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -2607,7 +2641,7 @@ dependencies = [ "diffy", "ignore", "itertools 0.12.1", - "salsa", + "rust-analyzer-salsa", "serde", "smol_str", "thiserror", @@ -2615,9 +2649,9 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce4ba948a52a088144071d2555d4383bf7f45ddfadecf99d0ef138f1718abc" +checksum = "7b5dad8906d9d4b3876e6b2061f9ddd499f0514368e3e7e0aeaea70e80c3608a" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -2634,12 +2668,15 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-test-plugin", "cairo-lang-utils", + "indent", + "indoc 2.0.5", "itertools 0.12.1", - "salsa", + "rust-analyzer-salsa", "scarb-metadata 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "smol_str", + "tempfile", "tokio", "tower-lsp", "tracing", @@ -2649,9 +2686,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d535dc591513875b39b799270df21db10540033fd7710917760c22fc063a4ae" +checksum = "1e224e006c82ef21bd9e243390992de2be25ae6fbbdaa8544067b3f0c31977f1" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2667,15 +2704,14 @@ dependencies = [ "log", "num-bigint", "num-traits 0.2.19", - "once_cell", - "salsa", + "rust-analyzer-salsa", "smol_str", ] [[package]] name = "cairo-lang-macro" version = "0.1.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "cairo-lang-macro-attributes", "cairo-lang-macro-stable", @@ -2701,9 +2737,9 @@ checksum = "c49906d6b1c215e5814be7c5c65ecf2328898b335bee8c2409ec07cfb5530daf" [[package]] name = "cairo-lang-parser" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73019d5873715964f428ff10467efb607d6dc007ae164a21547bf20d9b5dcc72" +checksum = "afb260ba349c2b699639e56f9b64deb969ff01179a0253087e2c8ceec7e32157" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -2714,16 +2750,16 @@ dependencies = [ "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", - "salsa", + "rust-analyzer-salsa", "smol_str", "unescaper", ] [[package]] name = "cairo-lang-plugins" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96e52fca18bc696011a47a4ded0dc00e2e0ac7c81a8052eddd4ad546c46b818e" +checksum = "05a2e500dc8ddea4d25a866d8a839158b0e4c41a6c023f21911e2da252bd91b3" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -2734,15 +2770,15 @@ dependencies = [ "indent", "indoc 2.0.5", "itertools 0.12.1", - "salsa", + "rust-analyzer-salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d55dcf98a6e1a03e0b36129fad4253f9e6666a1746ab9c075d212ba68a4e9c1" +checksum = "d72f17373740f242d6995e896b9195c2cedff7e8b14e496afdd16b405039d1fb" dependencies = [ "cairo-lang-debug", "quote", @@ -2751,9 +2787,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ddb432e5199a65e37bab97ef6322afabd60e0e638ada31178d9c23d237219d" +checksum = "13294f08d2013fcd6e815e7235935680963dec3390e5baf454f33da866fc44b6" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -2765,9 +2801,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5bbbabd509ce88abc67436973d3377e099269dbd14578fa84fce884a74fa23" +checksum = "6c5b9e6a21d92255b92f64c60658b4224dd7d290cde8beea783fadc10fbfcd8c" dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", @@ -2796,9 +2832,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "393325820207491a7475269e98163e0db7e85e4b215f4d801ca537ce1cd6daa7" +checksum = "6936215bca75c23e71873998420a3d46c322507a09917ce676c8d39f8c1bd6fe" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2815,17 +2851,16 @@ dependencies = [ "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", - "once_cell", - "salsa", + "rust-analyzer-salsa", "smol_str", "toml 0.8.19", ] [[package]] name = "cairo-lang-sierra" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918fb0611203fb8cdd1fcdb434f395a59e0ebb0db64b11a0e15bfbfb03552821" +checksum = "424f55450494e959c1ae26c52a71075767a90f76e3ecca6e81056dd7517e8ba0" dependencies = [ "anyhow", "cairo-lang-utils", @@ -2838,9 +2873,8 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.19", - "once_cell", "regex", - "salsa", + "rust-analyzer-salsa", "serde", "serde_json", "sha3", @@ -2851,9 +2885,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa1834ec729e89fcbd00df03f2a64a18515fcf07eb18dfef39afe020a10955d" +checksum = "053dd520e0b9d1c1078d93ea69045f6f334c3d41b4b75db183ab33e32cfd8570" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -2867,9 +2901,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b00927d39f910dd5ae1047cef9b46b2ee11617d33d290f875bc00dfc7e3d992" +checksum = "9a73227867377efc62ebb893cddaa88df3940bf2be5dbdc2f0b00f9edf69288e" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -2883,9 +2917,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7620a6a7becf5997093a83d289a5e3b3162bc8fd031ad75df82a5bc04f8cc954" +checksum = "a3752cacd475ea089d9a536357804150e693a124e703fcc33a55566d568094b3" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2899,8 +2933,7 @@ dependencies = [ "cairo-lang-utils", "itertools 0.12.1", "num-traits 0.2.19", - "once_cell", - "salsa", + "rust-analyzer-salsa", "serde", "serde_json", "smol_str", @@ -2908,9 +2941,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67bd155770abf91d4290a31b0c0a1fb393ecee85eb0af40c16893b4601eff4d6" +checksum = "7162fb3c93960dfc6d8005b65064e518e3f1ed6102e8981b42ea41879c331184" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -2929,9 +2962,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbae9458999da692c272501678b6cfec358a6bcadb54921bf35d21afdcd91251" +checksum = "a51b80c117e2b05a6d300f2e2247892cc99e42e950e79f6085e6ed6cbcb44d12" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -2939,9 +2972,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f242d889180386d35935597f9d1cac07d4f3d60bd0f10558660ae4a77da701b6" +checksum = "aafaabc43f78dfa2f45d935993ba21c05c164bbb3bf277d348847a51e5939a9f" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -2960,7 +2993,6 @@ dependencies = [ "indent", "indoc 2.0.5", "itertools 0.12.1", - "once_cell", "serde", "serde_json", "smol_str", @@ -2970,9 +3002,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa17b313f46fcf7ff4de32b86c250eaf584d1e2c8e37ed16db155b221721e735" +checksum = "832fd9072ddf4204ca6d227c0238929349f10146bd066a98025d51ac15d27fad" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -2983,7 +3015,6 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.19", - "once_cell", "serde", "serde_json", "sha3", @@ -2994,25 +3025,25 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0ca518ed7c3674d9b62470f7482f4b07553eb3a02d83e0ae61bd6b5ecb4ec8" +checksum = "cebe67c0d68f9acf8709d170c1308ca57a778d22f70da38a57f74ae250eee28a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint", "num-traits 0.2.19", - "salsa", + "rust-analyzer-salsa", "smol_str", "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "2.7.1" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01f276bc28f6302fc63032046a12b60d18498906e65f646acb963244eed97f7c" +checksum = "31cef5b4347626e61bad8f070495cd35d637a5cb6744c34d20dd382c7431aff8" dependencies = [ "genco", "xshell", @@ -3020,15 +3051,14 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20b526ea053b930222352027b3259be44fb3cd3b25106e2b1fbc815526423650" +checksum = "4d5f036132e07b7829cb1d61b1ecc02789a70c7d16b2733722a2aca992492bc3" dependencies = [ "anyhow", "cairo-lang-compiler", "cairo-lang-debug", "cairo-lang-defs", - "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", "cairo-lang-semantic", @@ -3048,9 +3078,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44caf2f6ef96ba7653037a7f419d941158f5bf35f2802986986352a02354eb6" +checksum = "3effbddf1d0cebab9c91ca46d9792ed441095e1eb75a53785a15e5f378f9c52e" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -3071,9 +3101,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a2365bd502a657437f9d0d665e32e017054d0effdbecb1dda776bfcc11235d" +checksum = "060c61ac4a3ae0428771244ff8db903105f127392b7d725d919fe3fb1ec4132f" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -3084,9 +3114,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.7.0" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd5c8c127b9362a12ffb9dede38e792c81b4ded5a98b448baec157b745f47d1" +checksum = "8bfc6372538143afad658c853a35bdc9f5210c5cb54e0c8f04ab78e268139466" dependencies = [ "env_logger", "hashbrown 0.14.5", @@ -3848,6 +3878,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -3918,10 +3958,10 @@ dependencies = [ [[package]] name = "create-output-dir" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "anyhow", - "core-foundation", + "core-foundation 0.10.0", "tempfile", "winapi", ] @@ -4567,8 +4607,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dojo-bindgen" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ + "anyhow", "assert_matches", "async-trait", "cainome 0.4.6", @@ -4581,30 +4622,31 @@ dependencies = [ "scarb", "serde", "serde_json", + "sozo-scarbext", "starknet 0.12.0", "thiserror", "tokio", ] [[package]] -name = "dojo-core" -version = "1.0.0-alpha.19" +name = "dojo-contracts" +version = "1.0.0-rc.0" [[package]] name = "dojo-examples-spawn-and-move" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" [[package]] name = "dojo-lang" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", + "assert_fs", "cairo-lang-compiler", "cairo-lang-debug", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", - "cairo-lang-formatter", "cairo-lang-parser", "cairo-lang-plugins", "cairo-lang-project", @@ -4618,39 +4660,74 @@ dependencies = [ "cairo-lang-utils", "camino", "convert_case 0.6.0", - "dojo-test-utils", - "dojo-types", - "dojo-world", + "dojo-types 1.0.0-rc.0", "indoc 1.0.9", "itertools 0.12.1", "once_cell", "regex", "salsa", - "scarb", - "scarb-ui", "semver 1.0.23", "serde", "serde_json", + "serde_with 3.9.0", "smol_str", "starknet 0.12.0", + "tempfile", "test-log", "toml 0.8.19", "tracing", "url", ] +[[package]] +name = "dojo-lang" +version = "1.0.0-rc.0" +source = "git+https://github.com/dojoengine/dojo?rev=479b698def87b004ecc074058182fac40d53d077#479b698def87b004ecc074058182fac40d53d077" +dependencies = [ + "anyhow", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-plugins", + "cairo-lang-project", + "cairo-lang-semantic", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-syntax", + "cairo-lang-test-plugin", + "cairo-lang-utils", + "camino", + "convert_case 0.6.0", + "dojo-types 1.0.0-rc.0 (git+https://github.com/dojoengine/dojo?rev=479b698def87b004ecc074058182fac40d53d077)", + "indoc 1.0.9", + "itertools 0.12.1", + "regex", + "semver 1.0.23", + "serde", + "serde_json", + "serde_with 3.9.0", + "smol_str", + "starknet 0.12.0", + "tempfile", + "toml 0.8.19", + "tracing", + "url", +] + [[package]] name = "dojo-language-server" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "cairo-lang-language-server", "clap", - "dojo-lang", + "dojo-lang 1.0.0-rc.0", ] [[package]] name = "dojo-metrics" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "hyper 0.14.30", @@ -4669,13 +4746,13 @@ dependencies = [ [[package]] name = "dojo-test-utils" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "assert_fs", "async-trait", "camino", - "dojo-lang", + "dojo-lang 1.0.0-rc.0", "dojo-world", "jsonrpsee 0.16.3", "katana-core", @@ -4694,16 +4771,40 @@ dependencies = [ [[package]] name = "dojo-types" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" +dependencies = [ + "anyhow", + "cainome 0.4.6", + "crypto-bigint", + "hex", + "itertools 0.12.1", + "num-traits 0.2.19", + "regex", + "serde", + "serde_json", + "starknet 0.12.0", + "starknet-crypto 0.7.2", + "strum 0.25.0", + "strum_macros 0.25.3", + "thiserror", +] + +[[package]] +name = "dojo-types" +version = "1.0.0-rc.0" +source = "git+https://github.com/dojoengine/dojo?rev=479b698def87b004ecc074058182fac40d53d077#479b698def87b004ecc074058182fac40d53d077" dependencies = [ + "anyhow", "cainome 0.4.6", "crypto-bigint", "hex", "itertools 0.12.1", "num-traits 0.2.19", + "regex", "serde", "serde_json", "starknet 0.12.0", + "starknet-crypto 0.7.2", "strum 0.25.0", "strum_macros 0.25.3", "thiserror", @@ -4711,65 +4812,51 @@ dependencies = [ [[package]] name = "dojo-utils" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "assert_matches", + "colored_json", "dojo-test-utils", "futures", "reqwest 0.12.7", "rpassword", + "serde_json", "starknet 0.12.0", "thiserror", "tokio", + "tracing", ] [[package]] name = "dojo-world" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", - "assert_fs", - "assert_matches", "async-trait", "cainome 0.4.6", - "cairo-lang-filesystem", - "cairo-lang-project", - "cairo-lang-starknet", "cairo-lang-starknet-classes", - "camino", - "convert_case 0.6.0", - "dojo-lang", - "dojo-test-utils", - "dojo-types", - "dojo-utils", - "http 0.2.12", + "dojo-types 1.0.0-rc.0", "ipfs-api-backend-hyper", - "katana-runner", - "num-traits 0.2.19", "regex", - "scarb", "serde", "serde_json", "serde_with 3.9.0", - "similar-asserts", - "smol_str", "starknet 0.12.0", "starknet-crypto 0.7.2", - "tempfile", "thiserror", "tokio", "toml 0.8.19", - "topological-sort", "tracing", "url", - "walkdir", ] [[package]] name = "dojo-world-abigen" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ + "anyhow", + "cainome 0.4.6", "cairo-lang-starknet", "cairo-lang-starknet-classes", "camino", @@ -5140,7 +5227,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" dependencies = [ - "arrayvec", + "arrayvec 0.7.6", "auto_impl", "bytes", ] @@ -7121,7 +7208,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core 0.51.1", ] [[package]] @@ -7192,7 +7279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io 2.3.4", - "core-foundation", + "core-foundation 0.9.4", "fnv", "futures", "if-addrs", @@ -7786,7 +7873,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", - "arrayvec", + "arrayvec 0.7.6", "async-lock 2.8.0", "async-trait", "beef", @@ -8001,7 +8088,7 @@ dependencies = [ [[package]] name = "katana" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8028,7 +8115,7 @@ dependencies = [ [[package]] name = "katana-cairo" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "cairo-lang-casm", "cairo-lang-runner", @@ -8043,7 +8130,7 @@ dependencies = [ [[package]] name = "katana-codecs" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "bytes", "katana-primitives", @@ -8051,7 +8138,7 @@ dependencies = [ [[package]] name = "katana-codecs-derive" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "proc-macro2", "quote", @@ -8061,7 +8148,7 @@ dependencies = [ [[package]] name = "katana-core" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-contract 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-network 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8100,7 +8187,7 @@ dependencies = [ [[package]] name = "katana-db" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "arbitrary", @@ -8123,7 +8210,7 @@ dependencies = [ [[package]] name = "katana-executor" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8150,7 +8237,7 @@ dependencies = [ [[package]] name = "katana-node" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "const_format", @@ -8180,7 +8267,7 @@ dependencies = [ [[package]] name = "katana-node-bindings" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "regex", "serde", @@ -8195,7 +8282,7 @@ dependencies = [ [[package]] name = "katana-pipeline" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "async-trait", @@ -8211,7 +8298,7 @@ dependencies = [ [[package]] name = "katana-pool" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "futures", "katana-executor", @@ -8226,7 +8313,7 @@ dependencies = [ [[package]] name = "katana-primitives" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8254,7 +8341,7 @@ dependencies = [ [[package]] name = "katana-provider" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8279,7 +8366,7 @@ dependencies = [ [[package]] name = "katana-rpc" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy", "alloy-primitives", @@ -8321,7 +8408,7 @@ dependencies = [ [[package]] name = "katana-rpc-api" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "jsonrpsee 0.16.3", "katana-core", @@ -8332,7 +8419,7 @@ dependencies = [ [[package]] name = "katana-rpc-types" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8356,7 +8443,7 @@ dependencies = [ [[package]] name = "katana-rpc-types-builder" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "katana-executor", @@ -8368,7 +8455,7 @@ dependencies = [ [[package]] name = "katana-runner" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "assert_fs", @@ -8384,7 +8471,7 @@ dependencies = [ [[package]] name = "katana-runner-macro" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "proc-macro2", "quote", @@ -8393,7 +8480,7 @@ dependencies = [ [[package]] name = "katana-slot-controller" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -8411,7 +8498,7 @@ dependencies = [ [[package]] name = "katana-tasks" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "futures", "rayon", @@ -9857,7 +9944,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec", + "arrayvec 0.7.6", "itoa", ] @@ -10162,13 +10249,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "papergrid" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7419ad52a7de9b60d33e11085a0fe3df1fbd5926aa3f93d3dd53afbc9e86725" +dependencies = [ + "ansi-str", + "ansitok", + "bytecount", + "fnv", + "unicode-width", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ - "arrayvec", + "arrayvec 0.7.6", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", @@ -10932,7 +11032,7 @@ checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck 0.5.0", - "itertools 0.12.1", + "itertools 0.10.5", "log", "multimap", "once_cell", @@ -10973,7 +11073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.77", @@ -11461,6 +11561,7 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "native-tls", "once_cell", "percent-encoding", @@ -11884,13 +11985,42 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" +[[package]] +name = "rust-analyzer-salsa" +version = "0.17.0-pre.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719825638c59fd26a55412a24561c7c5bcf54364c88b9a7a04ba08a6eafaba8d" +dependencies = [ + "indexmap 2.5.0", + "lock_api", + "oorandom", + "parking_lot 0.12.3", + "rust-analyzer-salsa-macros", + "rustc-hash 1.1.0", + "smallvec", + "tracing", + "triomphe", +] + +[[package]] +name = "rust-analyzer-salsa-macros" +version = "0.17.0-pre.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d96498e9684848c6676c399032ebc37c52da95ecbefa83d71ccc53b9f8a4a8e" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "rust_decimal" version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ - "arrayvec", + "arrayvec 0.7.6", "borsh", "bytes", "num-traits 0.2.19", @@ -12101,7 +12231,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" dependencies = [ - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "jni 0.19.0", "log", @@ -12227,7 +12357,7 @@ dependencies = [ [[package]] name = "saya" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "clap", @@ -12245,7 +12375,7 @@ dependencies = [ [[package]] name = "saya-core" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "async-trait", @@ -12278,7 +12408,7 @@ dependencies = [ [[package]] name = "saya-provider" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "alloy-primitives", "anyhow", @@ -12309,8 +12439,8 @@ dependencies = [ [[package]] name = "scarb" -version = "2.7.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +version = "2.8.4" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "anyhow", "async-trait", @@ -12340,6 +12470,7 @@ dependencies = [ "derive_builder", "dialoguer", "directories", + "dojo-lang 1.0.0-rc.0 (git+https://github.com/dojoengine/dojo?rev=479b698def87b004ecc074058182fac40d53d077)", "dunce", "fs4", "fs_extra", @@ -12359,8 +12490,8 @@ dependencies = [ "redb", "reqwest 0.11.27", "scarb-build-metadata", - "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?tag=v2.7.0)", - "scarb-stable-hash 1.0.0 (git+https://github.com/software-mansion/scarb?tag=v2.7.0)", + "scarb-metadata 1.12.0 (git+https://github.com/dojoengine/scarb?branch=dojo-284)", + "scarb-stable-hash 1.0.0 (git+https://github.com/dojoengine/scarb?branch=dojo-284)", "scarb-ui", "semver 1.0.23", "serde", @@ -12382,15 +12513,15 @@ dependencies = [ "url", "walkdir", "which 5.0.0", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "zip", "zstd 0.13.2", ] [[package]] name = "scarb-build-metadata" -version = "2.7.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +version = "2.8.4" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "cargo_metadata", ] @@ -12411,7 +12542,7 @@ dependencies = [ [[package]] name = "scarb-metadata" version = "1.12.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "camino", "derive_builder", @@ -12434,7 +12565,7 @@ dependencies = [ [[package]] name = "scarb-stable-hash" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "data-encoding", "xxhash-rust", @@ -12443,14 +12574,14 @@ dependencies = [ [[package]] name = "scarb-ui" version = "0.1.5" -source = "git+https://github.com/software-mansion/scarb?tag=v2.7.0#e9a2b8716daf7388bfab5e4b0a2656e1b0c02d4d" +source = "git+https://github.com/dojoengine/scarb?branch=dojo-284#5ee01a699da7a973c38ba51eac1cb6065bb5006f" dependencies = [ "anyhow", "camino", "clap", "console", "indicatif", - "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?tag=v2.7.0)", + "scarb-metadata 1.12.0 (git+https://github.com/dojoengine/scarb?branch=dojo-284)", "serde", "serde_json", "tracing-core", @@ -12467,7 +12598,7 @@ dependencies = [ [[package]] name = "scheduler" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "clap", @@ -12578,7 +12709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "libc", "num-bigint", @@ -13203,7 +13334,7 @@ dependencies = [ [[package]] name = "sozo" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "assert_fs", @@ -13211,12 +13342,9 @@ dependencies = [ "bigdecimal 0.4.5", "cainome 0.4.6", "cairo-lang-compiler", - "cairo-lang-defs", "cairo-lang-filesystem", "cairo-lang-plugins", "cairo-lang-project", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", "cairo-lang-starknet", "cairo-lang-test-plugin", "cairo-lang-test-runner", @@ -13224,18 +13352,17 @@ dependencies = [ "camino", "clap", "clap-verbosity-flag", - "clap_complete", + "colored", "console", - "derive_more 0.99.18", "dojo-bindgen", - "dojo-lang", + "dojo-lang 1.0.0-rc.0", "dojo-test-utils", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", - "futures", "hex", "hex-literal", + "itertools 0.12.1", "katana-rpc-api", "katana-runner", "notify", @@ -13254,11 +13381,15 @@ dependencies = [ "smol_str", "snapbox", "sozo-ops", + "sozo-scarbext", "sozo-walnut", + "spinoff", "starknet 0.12.0", "starknet-crypto 0.7.2", + "tabled", "thiserror", "tokio", + "toml 0.8.19", "tracing", "tracing-log 0.1.4", "tracing-subscriber", @@ -13267,62 +13398,51 @@ dependencies = [ [[package]] name = "sozo-ops" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "assert_fs", "async-trait", "bigdecimal 0.4.5", "cainome 0.4.6", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-filesystem", - "cairo-lang-plugins", - "cairo-lang-project", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", - "cairo-lang-test-plugin", - "cairo-lang-utils", - "camino", - "clap", "colored", "colored_json", - "console", - "dojo-lang", "dojo-test-utils", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", "futures", "ipfs-api-backend-hyper", - "itertools 0.12.1", "katana-runner", - "num-bigint", "num-traits 0.2.19", - "reqwest 0.12.7", - "rpassword", - "scarb", - "scarb-ui", - "semver 1.0.23", "serde", "serde_json", "serde_with 3.9.0", - "smol_str", "sozo-walnut", + "spinoff", "starknet 0.12.0", "starknet-crypto 0.7.2", "thiserror", - "tokio", "toml 0.8.19", "tracing", - "url", +] + +[[package]] +name = "sozo-scarbext" +version = "1.0.0-rc.0" +dependencies = [ + "anyhow", + "camino", + "dojo-world", + "scarb", + "serde", + "serde_json", + "toml 0.8.19", ] [[package]] name = "sozo-signers" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "starknet 0.12.0", @@ -13330,7 +13450,7 @@ dependencies = [ [[package]] name = "sozo-walnut" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "console", @@ -13340,6 +13460,7 @@ dependencies = [ "scarb-ui", "serde", "serde_json", + "sozo-scarbext", "starknet 0.12.0", "thiserror", "url", @@ -13362,6 +13483,17 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spinoff" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20aa2ed67fbb202e7b716ff8bfc6571dd9301617767380197d701c31124e88f6" +dependencies = [ + "colored", + "once_cell", + "paste", +] + [[package]] name = "spki" version = "0.7.3" @@ -14276,7 +14408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -14290,6 +14422,31 @@ dependencies = [ "libc", ] +[[package]] +name = "tabled" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c9303ee60b9bedf722012ea29ae3711ba13a67c9b9ae28993838b63057cb1b" +dependencies = [ + "ansi-str", + "ansitok", + "papergrid", + "tabled_derive", +] + +[[package]] +name = "tabled_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf0fb8bfdc709786c154e24a66777493fb63ae97e3036d914c8666774c477069" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "tap" version = "1.0.1" @@ -14821,15 +14978,9 @@ dependencies = [ "web-sys", ] -[[package]] -name = "topological-sort" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" - [[package]] name = "torii" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "async-trait", @@ -14839,7 +14990,7 @@ dependencies = [ "clap", "ctrlc", "dojo-metrics", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", "either", @@ -14875,12 +15026,12 @@ dependencies = [ [[package]] name = "torii-client" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "async-trait", "camino", "crypto-bigint", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-world", "futures", "futures-util", @@ -14903,18 +15054,17 @@ dependencies = [ [[package]] name = "torii-core" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "async-trait", "base64 0.21.7", "bitflags 2.6.0", "cainome 0.4.6", - "camino", "chrono", "crypto-bigint", "dojo-test-utils", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", "futures-channel", @@ -14928,6 +15078,7 @@ dependencies = [ "serde", "serde_json", "slab", + "sozo-scarbext", "sqlx", "starknet 0.12.0", "starknet-crypto 0.7.2", @@ -14941,7 +15092,7 @@ dependencies = [ [[package]] name = "torii-graphql" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "async-graphql", @@ -14952,7 +15103,7 @@ dependencies = [ "chrono", "convert_case 0.6.0", "dojo-test-utils", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", "katana-runner", @@ -14962,6 +15113,7 @@ dependencies = [ "serde", "serde_json", "serial_test", + "sozo-scarbext", "sqlx", "starknet 0.12.0", "starknet-crypto 0.7.2", @@ -14980,13 +15132,13 @@ dependencies = [ [[package]] name = "torii-grpc" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "cainome 0.4.6", "camino", "crypto-bigint", "dojo-test-utils", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-utils", "dojo-world", "futures", @@ -15002,6 +15154,7 @@ dependencies = [ "scarb", "serde", "serde_json", + "sozo-scarbext", "sqlx", "starknet 0.12.0", "starknet-crypto 0.7.2", @@ -15026,13 +15179,13 @@ dependencies = [ [[package]] name = "torii-relay" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "anyhow", "cainome 0.4.6", "chrono", "crypto-bigint", - "dojo-types", + "dojo-types 1.0.0-rc.0", "dojo-world", "futures", "indexmap 2.5.0", @@ -15061,7 +15214,7 @@ dependencies = [ [[package]] name = "torii-server" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "base64 0.21.7", "http 0.2.12", @@ -15317,6 +15470,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "triomphe" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -15421,7 +15584,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "types-test" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" [[package]] name = "u256-literal" @@ -15457,7 +15620,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c8a2469e56e6e5095c82ccd3afb98dad95f7af7929aab6d8ba8d6e0f73657da" dependencies = [ - "arrayvec", + "arrayvec 0.7.6", ] [[package]] @@ -15525,9 +15688,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -15712,7 +15875,7 @@ dependencies = [ [[package]] name = "verify_db_balances" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ "clap", "num-traits 0.2.19", @@ -15735,6 +15898,27 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "vte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" +dependencies = [ + "arrayvec 0.5.2", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "wait-timeout" version = "0.2.0" @@ -15978,7 +16162,7 @@ version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db67ae75a9405634f5882791678772c94ff5f16a66535aae186e26aa0841fc8b" dependencies = [ - "core-foundation", + "core-foundation 0.9.4", "home", "jni 0.21.1", "log", @@ -16341,15 +16525,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-core" version = "0.57.0" @@ -16755,14 +16930,17 @@ checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852" [[package]] name = "xtask-generate-test-db" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" dependencies = [ + "anyhow", "dojo-test-utils", "dojo-utils", + "dojo-world", "katana-runner", "reqwest 0.12.7", "scarb", "sozo-ops", + "sozo-scarbext", "starknet 0.12.0", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index af0729158d..b5a19cedad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,14 +8,14 @@ members = [ "bin/scheduler", "bin/sozo", "bin/torii", - "crates/dojo-bindgen", - "crates/dojo-core", - "crates/dojo-lang", - "crates/dojo-test-utils", - "crates/dojo-types", - "crates/dojo-utils", - "crates/dojo-world", - "crates/dojo-world/abigen", + "crates/dojo/bindgen", + "crates/dojo/core", + "crates/dojo/lang", + "crates/dojo/test-utils", + "crates/dojo/types", + "crates/dojo/utils", + "crates/dojo/world", + "crates/dojo/world/abigen", "crates/katana/controller", "crates/katana/core", "crates/katana/executor", @@ -38,6 +38,7 @@ members = [ "crates/metrics", "crates/saya/core", "crates/saya/provider", + "crates/sozo/scarbext", "crates/sozo/signers", "crates/sozo/walnut", "crates/torii/client", @@ -53,7 +54,7 @@ edition = "2021" license = "Apache-2.0" license-file = "LICENSE" repository = "https://github.com/dojoengine/dojo/" -version = "1.0.0-alpha.19" +version = "1.0.0-rc.0" [profile.performance] codegen-units = 1 @@ -62,19 +63,19 @@ inherits = "release" lto = "fat" [workspace.dependencies] -cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.4.6", features = [ "abigen-rs" ] } -dojo-utils = { path = "crates/dojo-utils" } +cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "5c2616c273faca7700d2ba565503fcefb5b9d720", features = [ "abigen-rs" ] } +dojo-utils = { path = "crates/dojo/utils" } # metrics dojo-metrics = { path = "crates/metrics" } # dojo-lang -dojo-bindgen = { path = "crates/dojo-bindgen" } -dojo-core = { path = "crates/dojo-core" } -dojo-lang = { path = "crates/dojo-lang" } -dojo-test-utils = { path = "crates/dojo-test-utils" } -dojo-types = { path = "crates/dojo-types" } -dojo-world = { path = "crates/dojo-world" } +dojo-bindgen = { path = "crates/dojo/bindgen" } +dojo-core = { path = "crates/dojo/core" } +dojo-lang = { path = "crates/dojo/lang" } +dojo-test-utils = { path = "crates/dojo/test-utils" } +dojo-types = { path = "crates/dojo/types" } +dojo-world = { path = "crates/dojo/world" } # dojo-world topological-sort = "0.2" @@ -114,6 +115,7 @@ saya-provider = { path = "crates/saya/provider" } # sozo sozo-ops = { path = "crates/sozo/ops" } +sozo-scarbext = { path = "crates/sozo/scarbext" } sozo-signers = { path = "crates/sozo/signers" } sozo-walnut = { path = "crates/sozo/walnut" } @@ -126,34 +128,36 @@ auto_impl = "1.2.0" base64 = "0.21.2" bigdecimal = "0.4.1" bytes = "1.6" -cairo-lang-compiler = "2.7.0" -cairo-lang-debug = "2.7.0" -cairo-lang-defs = "2.7.0" +cairo-lang-compiler = "2.8.4" +cairo-lang-debug = "2.8.4" +cairo-lang-defs = "2.8.4" cairo-lang-diagnostics = "2.7.0" -cairo-lang-filesystem = "2.7.0" -cairo-lang-formatter = "2.7.0" -cairo-lang-language-server = "2.7.0" -cairo-lang-lowering = "2.7.0" -cairo-lang-parser = "2.7.0" -cairo-lang-plugins = { version = "2.7.0", features = [ "testing" ] } -cairo-lang-project = "2.7.0" -cairo-lang-semantic = "2.7.0" -cairo-lang-sierra = "2.7.0" -cairo-lang-sierra-generator = "2.7.0" -cairo-lang-sierra-to-casm = "2.7.0" -cairo-lang-starknet = "2.7.0" -cairo-lang-starknet-classes = "2.7.0" -cairo-lang-syntax = "2.7.0" -cairo-lang-test-plugin = "2.7.0" -cairo-lang-test-runner = "2.7.0" -cairo-lang-test-utils = "2.7.0" -cairo-lang-utils = "2.7.0" +cairo-lang-filesystem = "2.8.4" +cairo-lang-formatter = "2.8.4" +cairo-lang-language-server = "2.8.4" +cairo-lang-lowering = "2.8.4" +cairo-lang-parser = "2.8.4" +cairo-lang-plugins = { version = "2.8.4", features = [ "testing" ] } +cairo-lang-project = "2.8.4" +cairo-lang-semantic = "2.8.4" +cairo-lang-sierra = "2.8.4" +cairo-lang-sierra-generator = "2.8.4" +cairo-lang-sierra-to-casm = "2.8.4" +cairo-lang-starknet = "2.8.4" +cairo-lang-starknet-classes = "2.8.4" +cairo-lang-syntax = "2.8.4" +cairo-lang-test-plugin = "2.8.4" +cairo-lang-test-runner = "2.8.4" +cairo-lang-test-utils = "2.8.4" +cairo-lang-utils = "2.8.4" cairo-vm = "1.0.0-rc4" camino = { version = "1.1.2", features = [ "serde1" ] } chrono = { version = "0.4.24", features = [ "serde" ] } clap = { version = "4.5.16", features = [ "derive", "env" ] } clap-verbosity-flag = "2.0.1" clap_complete = "4.3" +colored = "2.0.0" +colored_json = "3.2.0" console = "0.15.7" convert_case = "0.6.0" crypto-bigint = { version = "0.5.3", features = [ "serde" ] } @@ -184,14 +188,19 @@ rpassword = "7.2.0" rstest = "0.18.2" rstest_reuse = "0.6.0" salsa = "0.16.1" -scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.7.0" } -scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.7.0" } +#scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.4" } +#scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.4" } +scarb = { git = "https://github.com/dojoengine/scarb", branch = "dojo-284" } +scarb-ui = { git = "https://github.com/dojoengine/scarb", branch = "dojo-284" } +#scarb = { path = "/Users/glihm/swm/scarb/scarb" } +#scarb-ui = { path = "/Users/glihm/swm/scarb/utils/scarb-ui" } semver = "1.0.5" serde = { version = "1.0", features = [ "derive" ] } serde_json = { version = "1.0", features = [ "arbitrary_precision" ] } serde_with = "3.9.0" similar-asserts = "1.5.0" smol_str = { version = "0.2.0", features = [ "serde" ] } +spinoff = "0.8.0" sqlx = { version = "0.8.2", features = [ "chrono", "macros", "regexp", "runtime-async-std", "runtime-tokio", "sqlite", "uuid" ] } starknet_api = "0.11.0" strum = "0.25" diff --git a/bin/dojo-language-server/src/main.rs b/bin/dojo-language-server/src/main.rs index d6516351a2..7f12f22078 100644 --- a/bin/dojo-language-server/src/main.rs +++ b/bin/dojo-language-server/src/main.rs @@ -1,6 +1,6 @@ use cairo_lang_language_server::Tricks; use clap::Parser; -use dojo_lang::plugin::dojo_plugin_suite; +use dojo_lang::dojo_plugin_suite; /// Dojo Language Server #[derive(Parser, Debug)] diff --git a/bin/sozo/Cargo.toml b/bin/sozo/Cargo.toml index a2833b0e33..a947156a5c 100644 --- a/bin/sozo/Cargo.toml +++ b/bin/sozo/Cargo.toml @@ -12,12 +12,9 @@ anyhow.workspace = true async-trait.workspace = true bigdecimal.workspace = true cairo-lang-compiler.workspace = true -cairo-lang-defs.workspace = true cairo-lang-filesystem.workspace = true cairo-lang-plugins.workspace = true cairo-lang-project.workspace = true -cairo-lang-sierra.workspace = true -cairo-lang-sierra-to-casm.workspace = true cairo-lang-starknet.workspace = true cairo-lang-test-plugin.workspace = true cairo-lang-test-runner.workspace = true @@ -25,22 +22,22 @@ cairo-lang-utils.workspace = true camino.workspace = true clap.workspace = true clap-verbosity-flag.workspace = true -clap_complete.workspace = true +colored.workspace = true console.workspace = true -derive_more.workspace = true dojo-bindgen.workspace = true dojo-lang.workspace = true dojo-types.workspace = true dojo-utils.workspace = true -dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } -futures.workspace = true +dojo-world.workspace = true hex = "0.4.3" hex-literal = "0.4.1" +itertools.workspace = true katana-rpc-api.workspace = true notify = "6.0.1" num-bigint = "0.4.3" num-integer = "0.1.45" prettytable-rs = "0.10.0" +tabled = { version = "0.16.0", features = [ "ansi" ] } regex.workspace = true rpassword.workspace = true scarb.workspace = true @@ -51,9 +48,12 @@ serde_json.workspace = true smol_str.workspace = true sozo-ops.workspace = true sozo-walnut = { workspace = true, optional = true } +sozo-scarbext.workspace = true +spinoff.workspace = true starknet.workspace = true starknet-crypto.workspace = true thiserror.workspace = true +toml.workspace = true tokio.workspace = true tracing.workspace = true tracing-log.workspace = true diff --git a/bin/sozo/benches/spawn-and-move-build.rs b/bin/sozo/benches/spawn-and-move-build.rs index 59f0b2b298..8fccb7e7e1 100644 --- a/bin/sozo/benches/spawn-and-move-build.rs +++ b/bin/sozo/benches/spawn-and-move-build.rs @@ -1,6 +1,5 @@ use std::time::Instant; -use dojo_lang::scarb_internal::compile_workspace; use dojo_test_utils::compiler::CompilerTestSetup; use scarb::compiler::Profile; use scarb::core::TargetKind; @@ -12,7 +11,7 @@ use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; // `bench.yml` action. fn build_spawn_and_move() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); + let setup = CompilerTestSetup::from_examples("../../crates/dojo/core", "../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); @@ -21,8 +20,8 @@ fn build_spawn_and_move() { let packages: Vec<_> = ws.members().collect(); - let _compile_info = compile_workspace( - &config, + scarb::ops::compile( + packages.iter().map(|p| p.id).collect(), CompileOpts { include_target_names: vec![], include_target_kinds: vec![], @@ -32,7 +31,7 @@ fn build_spawn_and_move() { no_default_features: false, }, }, - packages.iter().map(|p| p.id).collect(), + &ws, ) .expect("Failed to build spawn and move"); } diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 4b977fbe0c..8ad205b603 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -52,7 +52,8 @@ impl SozoArgs { } pub fn init_logging(&self) -> Result<(), Box> { - const DEFAULT_LOG_FILTER: &str = "info,hyper=off,scarb=off,salsa=off"; + const DEFAULT_LOG_FILTER: &str = + "info,hyper=off,scarb=off,salsa=off,sozo=info,dojo_world=info"; LogTracer::init()?; diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 46cb25e8d9..69fda5634a 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -1,23 +1,13 @@ -use anyhow::{Context, Result}; +use anyhow::Result; use clap::{Args, Parser}; use dojo_bindgen::{BuiltinPlugins, PluginManager}; -use dojo_lang::scarb_internal::compile_workspace; -use dojo_world::manifest::MANIFESTS_DIR; -use prettytable::format::consts::FORMAT_NO_LINESEP_WITH_TITLE; -use prettytable::{format, Cell, Row, Table}; use scarb::core::{Config, Package, TargetKind}; use scarb::ops::CompileOpts; use scarb_ui::args::{FeaturesSpec, PackagesFilter}; -use sozo_ops::statistics::{get_contract_statistics_for_dir, ContractStatistics}; -use tracing::trace; +use sozo_scarbext::WorkspaceExt; +use tracing::debug; use crate::commands::check_package_dojo_version; -use crate::commands::clean::CleanArgs; - -const BYTECODE_SIZE_LABEL: &str = "Bytecode size [in felts]\n(Sierra, Casm)"; -const CONTRACT_CLASS_SIZE_LABEL: &str = "Contract Class size [in bytes]\n(Sierra, Casm)"; - -const CONTRACT_NAME_LABEL: &str = "Contract"; #[derive(Debug, Args)] pub struct BuildArgs { @@ -56,6 +46,11 @@ pub struct BuildArgs { impl BuildArgs { pub fn run(self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + ws.profile_check()?; + + // Ensure we don't have old contracts in the build dir, since the local artifacts + // guides the migration. + ws.clean_dir_profile(); let packages: Vec = if let Some(filter) = self.packages { filter.match_many(&ws)?.into_iter().collect() @@ -67,28 +62,18 @@ impl BuildArgs { check_package_dojo_version(&ws, p)?; } - let profile_name = - ws.current_profile().expect("Scarb profile is expected at this point.").to_string(); - - // Manifest path is always a file, we can unwrap safely to get the parent folder. - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - - let profile_dir = manifest_dir.join(MANIFESTS_DIR).join(profile_name); - CleanArgs::clean_manifests(&profile_dir)?; - - trace!(?packages); + debug!(?packages); - let compile_info = compile_workspace( - config, + scarb::ops::compile( + packages.iter().map(|p| p.id).collect(), CompileOpts { include_target_names: vec![], include_target_kinds: vec![], exclude_target_kinds: vec![TargetKind::TEST], features: self.features.try_into()?, }, - packages.iter().map(|p| p.id).collect(), + &ws, )?; - trace!(?compile_info, "Compiled workspace."); let mut builtin_plugins = vec![]; @@ -104,48 +89,18 @@ impl BuildArgs { builtin_plugins.push(BuiltinPlugins::Unity); } - if self.stats { - let target_dir = &compile_info.target_dir; - let contracts_statistics = get_contract_statistics_for_dir(config.ui(), target_dir) - .context("Error getting contracts stats")?; - trace!( - ?contracts_statistics, - ?target_dir, - "Read contract statistics for target directory." - ); - - let ui = config.ui(); - - ui.print( - "Bytecode: It is low-level code that constitutes smart contracts and is \ - represented by an array of felts.", - ); - ui.print("Bytecode size: It is number of felts in Bytecode."); - ui.print( - "Contract Class: It serve as the fundamental building blocks of smart contracts.", - ); - ui.print( - "Contract Class size: It denotes the file size of the minified JSON \ - representation of the contract class.", - ); - ui.print(" "); - - let table = create_stats_table(contracts_statistics); - table.printstd() - } - // Custom plugins are always empty for now. let bindgen = PluginManager { - profile_name: compile_info.profile_name, - output_path: self.bindings_output.into(), - manifest_path: compile_info.manifest_path, - root_package_name: compile_info - .root_package_name + profile_name: ws.current_profile().expect("Profile expected").to_string(), + root_package_name: ws + .root_package() + .map(|p| p.id.name.to_string()) .unwrap_or("NO_ROOT_PACKAGE".to_string()), + output_path: self.bindings_output.into(), + manifest_path: config.manifest_path().to_path_buf(), plugins: vec![], builtin_plugins, }; - trace!(pluginManager=?bindgen, "Generating bindings."); // TODO: check about the skip migration as now we process the metadata // directly during the compilation to get the data we need from it. @@ -175,133 +130,3 @@ impl Default for BuildArgs { } } } - -fn create_stats_table(mut contracts_statistics: Vec) -> Table { - let mut table = Table::new(); - table.set_format(*FORMAT_NO_LINESEP_WITH_TITLE); - - // Add table headers - table.set_titles(Row::new(vec![ - Cell::new_align(CONTRACT_NAME_LABEL, format::Alignment::CENTER), - Cell::new_align(BYTECODE_SIZE_LABEL, format::Alignment::CENTER), - Cell::new_align(CONTRACT_CLASS_SIZE_LABEL, format::Alignment::CENTER), - ])); - - // sort contracts in alphabetical order - contracts_statistics.sort_by(|a, b| a.contract_name.cmp(&b.contract_name)); - - for contract_stats in contracts_statistics { - // Add table rows - let contract_name = contract_stats.contract_name; - - let sierra_bytecode_size = contract_stats.sierra_bytecode_size; - let sierra_contract_class_size = contract_stats.sierra_contract_class_size; - - let casm_bytecode_size = contract_stats.casm_bytecode_size; - let casm_contract_class_size = contract_stats.casm_contract_class_size; - - table.add_row(Row::new(vec![ - Cell::new_align(&contract_name, format::Alignment::LEFT), - Cell::new_align( - format!("{}, {}", sierra_bytecode_size, casm_bytecode_size).as_str(), - format::Alignment::CENTER, - ), - Cell::new_align( - format!("{}, {}", sierra_contract_class_size, casm_contract_class_size).as_str(), - format::Alignment::CENTER, - ), - ])); - } - - table -} - -#[cfg(test)] -mod tests { - use dojo_test_utils::compiler::CompilerTestSetup; - use prettytable::format::consts::FORMAT_NO_LINESEP_WITH_TITLE; - use prettytable::{format, Cell, Row, Table}; - use scarb::compiler::Profile; - use sozo_ops::statistics::ContractStatistics; - - use super::{create_stats_table, BuildArgs, *}; - use crate::commands::build::CONTRACT_NAME_LABEL; - - // Ignored as scarb takes too much time to compile in debug mode. - // It's anyway run in the CI in the `test` job. - #[test] - #[ignore] - fn build_example_with_typescript_and_unity_bindings() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let build_args = BuildArgs { - bindings_output: "generated".to_string(), - // typescript: false, - unity: true, - typescript_v2: true, - stats: true, - ..Default::default() - }; - let result = build_args.run(&config); - assert!(result.is_ok()); - } - - #[test] - fn test_create_stats_table() { - // Arrange - let contracts_statistics = vec![ - ContractStatistics { - contract_name: "Test1".to_string(), - sierra_bytecode_size: 33, - sierra_contract_class_size: 33, - casm_bytecode_size: 66, - casm_contract_class_size: 66, - }, - ContractStatistics { - contract_name: "Test2".to_string(), - sierra_bytecode_size: 43, - sierra_contract_class_size: 24, - casm_bytecode_size: 86, - casm_contract_class_size: 48, - }, - ContractStatistics { - contract_name: "Test3".to_string(), - sierra_bytecode_size: 36, - sierra_contract_class_size: 12, - casm_bytecode_size: 72, - casm_contract_class_size: 24, - }, - ]; - - let mut expected_table = Table::new(); - expected_table.set_format(*FORMAT_NO_LINESEP_WITH_TITLE); - expected_table.set_titles(Row::new(vec![ - Cell::new_align(CONTRACT_NAME_LABEL, format::Alignment::CENTER), - Cell::new_align(BYTECODE_SIZE_LABEL, format::Alignment::CENTER), - Cell::new_align(CONTRACT_CLASS_SIZE_LABEL, format::Alignment::CENTER), - ])); - expected_table.add_row(Row::new(vec![ - Cell::new_align("Test1", format::Alignment::LEFT), - Cell::new_align(format!("{}, {}", 33, 66).as_str(), format::Alignment::CENTER), - Cell::new_align(format!("{}, {}", 33, 66).as_str(), format::Alignment::CENTER), - ])); - expected_table.add_row(Row::new(vec![ - Cell::new_align("Test2", format::Alignment::LEFT), - Cell::new_align(format!("{}, {}", 43, 86).as_str(), format::Alignment::CENTER), - Cell::new_align(format!("{}, {}", 24, 48).as_str(), format::Alignment::CENTER), - ])); - expected_table.add_row(Row::new(vec![ - Cell::new_align("Test3", format::Alignment::LEFT), - Cell::new_align(format!("{}, {}", 36, 72).as_str(), format::Alignment::CENTER), - Cell::new_align(format!("{}, {}", 12, 24).as_str(), format::Alignment::CENTER), - ])); - - // Act - let table = create_stats_table(contracts_statistics); - - // Assert - assert_eq!(table, expected_table, "Tables mismatch") - } -} diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index d24494ce20..f6661ff740 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -1,10 +1,17 @@ -use anyhow::Result; +use std::str::FromStr; + +use anyhow::{anyhow, Result}; use clap::Args; +use dojo_types::naming; use dojo_world::contracts::naming::ensure_namespace; -use dojo_world::metadata::get_default_namespace_from_ws; use scarb::core::Config; +use sozo_scarbext::WorkspaceExt; +use starknet::core::types::{BlockId, BlockTag, Felt, FunctionCall, StarknetError}; +use starknet::core::utils as snutils; +use starknet::providers::{Provider, ProviderError}; use tracing::trace; +use super::execute::ContractDescriptor; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::commands::calldata_decoder; @@ -46,22 +53,22 @@ impl CallArgs { pub fn run(self, config: &Config) -> Result<()> { trace!(args = ?self); - let env_metadata = utils::load_metadata_from_config(config)?; - trace!(?env_metadata, "Loaded metadata from config."); + let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + + let profile_config = ws.load_profile_config()?; - let tag_or_address = if utils::is_address(&self.tag_or_address) { - self.tag_or_address + let descriptor = if utils::is_address(&self.tag_or_address) { + ContractDescriptor::Address(Felt::from_str(&self.tag_or_address)?) } else { - let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - let default_namespace = get_default_namespace_from_ws(&ws)?; - ensure_namespace(&self.tag_or_address, &default_namespace) + ContractDescriptor::Tag(ensure_namespace( + &self.tag_or_address, + &profile_config.namespace.default, + )) }; config.tokio_handle().block_on(async { - let world_reader = - utils::world_reader_from_env_metadata(self.world, self.starknet, &env_metadata) - .await - .unwrap(); + let (world_diff, provider, _) = + utils::get_world_diff_and_provider(self.starknet.clone(), self.world, &ws).await?; let calldata = if let Some(cd) = self.calldata { calldata_decoder::decode_calldata(&cd)? @@ -69,15 +76,55 @@ impl CallArgs { vec![] }; - sozo_ops::call::call( - &config.ui(), - world_reader, - tag_or_address, - self.entrypoint, - calldata, - self.block_id, - ) - .await + let contract_address = match &descriptor { + ContractDescriptor::Address(address) => Some(*address), + ContractDescriptor::Tag(tag) => { + let selector = naming::compute_selector_from_tag(tag); + world_diff.get_contract_address(selector) + } + } + .ok_or_else(|| anyhow!("Contract {descriptor} not found in the world diff."))?; + + let block_id = if let Some(block_id) = self.block_id { + dojo_utils::parse_block_id(block_id)? + } else { + BlockId::Tag(BlockTag::Pending) + }; + + let res = provider + .call( + FunctionCall { + contract_address, + entry_point_selector: snutils::get_selector_from_name(&self.entrypoint)?, + calldata, + }, + block_id, + ) + .await; + + match res { + Ok(output) => { + println!( + "[ {} ]", + output.iter().map(|o| format!("0x{:x}", o)).collect::>().join(" ") + ); + } + Err(e) => { + anyhow::bail!(format!( + "Error calling entrypoint `{}` on address: {:#066x}\n{}", + self.entrypoint, + contract_address, + match &e { + ProviderError::StarknetError(StarknetError::ContractError(e)) => { + format!("Contract error: {}", e.revert_error.clone()) + } + _ => e.to_string(), + } + )); + } + }; + + Ok(()) }) } } diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index c793380dad..5414545b55 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -1,86 +1,23 @@ -use std::fs; - -use anyhow::{Context, Result}; -use camino::Utf8PathBuf; +use anyhow::Result; use clap::Args; -use dojo_world::manifest::{BASE_DIR, MANIFESTS_DIR}; use scarb::core::Config; -use scarb::ops; -use tracing::trace; +use sozo_scarbext::WorkspaceExt; #[derive(Debug, Args)] pub struct CleanArgs { - #[arg(long)] - #[arg(help = "Removes all the generated files, including scarb artifacts and ALL the \ - manifests files.")] - pub full: bool, - #[arg(long)] #[arg(help = "Clean all profiles.")] pub all_profiles: bool, } impl CleanArgs { - /// Cleans the manifests and abis files that are generated at build time. - /// - /// # Arguments - /// - /// * `profile_dir` - The directory where the profile files are located. - pub fn clean_manifests(profile_dir: &Utf8PathBuf) -> Result<()> { - trace!(?profile_dir, "Cleaning manifests."); - let dirs = vec![profile_dir.join(BASE_DIR)]; - - for d in dirs { - if d.exists() { - trace!(directory=?d, "Removing directory."); - fs::remove_dir_all(d)?; - } - } - - Ok(()) - } - pub fn run(self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(ws=?ws, "Workspace read successfully."); - let profile_names = if self.all_profiles { - ws.profile_names() + if self.all_profiles { + ws.clean_dir_all_profiles(); } else { - vec![ - ws.current_profile().expect("Scarb profile is expected at this point.").to_string(), - ] - }; - - for profile_name in profile_names { - // Manifest path is always a file, we can unwrap safely to get the - // parent folder. - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - - // By default, this command cleans the build manifests and scarb artifacts. - trace!("Cleaning Scarb artifacts and build manifests."); - - { - // copied from scarb::ops::clean since scarb cleans build file of all the profiles - // we only want to clean build files for specified profile - // - // cleaning build files for all profiles would create inconsistency with the - // manifest files in `manifests` directory - let ws = ops::read_workspace(config.manifest_path(), config)?; - let path = ws.target_dir().path_unchecked().join(&profile_name); - if path.exists() { - fs::remove_dir_all(path).context("failed to clean generated artifacts")?; - } - } - - let profile_dir = manifest_dir.join(MANIFESTS_DIR).join(&profile_name); - - Self::clean_manifests(&profile_dir)?; - - if self.full && profile_dir.exists() { - trace!(?profile_dir, "Removing entire profile directory."); - fs::remove_dir_all(profile_dir)?; - } + ws.clean_dir_profile(); } Ok(()) @@ -89,156 +26,156 @@ impl CleanArgs { // these tests assume `example/spawn-and-move` is build for `dev` and `release` profile, // which are normally built by the `build.rs` of `dojo-test-utils`. -#[cfg(test)] -mod tests { - use dojo_test_utils::compiler::CompilerTestSetup; - use dojo_world::manifest::DEPLOYMENT_DIR; - use dojo_world::metadata::ABIS_DIR; - use scarb::compiler::Profile; - - use super::*; - - #[test] - fn default_clean_works() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); - - println!("temp_project_dir: {:?}", temp_project_dir); - - let clean_cmd = CleanArgs { full: false, all_profiles: false }; - clean_cmd.run(&config).unwrap(); - - let dev_profile_name = "dev"; - let release_profile_name = "release"; - - let target_dev_dir = temp_project_dir.join("target").join(dev_profile_name); - let target_release_dir = temp_project_dir.join("target").join(release_profile_name); - - let dev_manifests_dir = temp_project_dir.join("manifests").join(dev_profile_name); - let release_manifests_dir = temp_project_dir.join("manifests").join(release_profile_name); - - let dev_manifests_base_dir = dev_manifests_dir.join("base"); - let dev_manifests_abis_base_dir = dev_manifests_dir.join("base").join("abis"); - let release_manifests_base_dir = release_manifests_dir.join("base"); - let release_manifests_abis_base_dir = release_manifests_dir.join("base").join("abis"); - - let dev_manifests_depl_dir = dev_manifests_dir.join("deployment"); - let dev_manifests_abis_depl_dir = dev_manifests_depl_dir.join("abis"); - let dev_manifest_toml = dev_manifests_depl_dir.join("manifest").with_extension("toml"); - let dev_manifest_json = dev_manifests_depl_dir.join("manifest").with_extension("json"); - - assert!(fs::read_dir(target_dev_dir).is_err(), "Expected 'target/dev' to be empty"); - assert!( - fs::read_dir(target_release_dir).is_ok(), - "Expected 'target/release' to be present" - ); - - assert!( - fs::read_dir(dev_manifests_base_dir).is_err(), - "Expected 'manifests/dev/base' to be empty" - ); - assert!( - fs::read_dir(dev_manifests_abis_base_dir).is_err(), - "Expected 'manifests/dev/base/abis' to be empty" - ); - assert!( - fs::read_dir(&dev_manifests_abis_depl_dir).is_ok(), - "Expected 'manifests/dev/deployment/abis' to be non empty" - ); - - // we expect release profile to be not affected - assert!( - fs::read_dir(release_manifests_base_dir).is_ok(), - "Expected 'manifests/release/base' to be non empty" - ); - assert!( - fs::read_dir(release_manifests_abis_base_dir).is_ok(), - "Expected 'manifests/release/base/abis' to be non empty" - ); - - assert!(dev_manifest_toml.exists(), "Expected 'manifest.toml' to exist"); - assert!(dev_manifest_json.exists(), "Expected 'manifest.json' to exist"); - - let clean_cmd = CleanArgs { full: true, all_profiles: false }; - clean_cmd.run(&config).unwrap(); - - assert!( - fs::read_dir(&dev_manifests_abis_depl_dir).is_err(), - "Expected 'manifests/dev/deployment/abis' to be empty" - ); - assert!(!dev_manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); - assert!(!dev_manifest_json.exists(), "Expected 'manifest.json' to not exist"); - } - - #[test] - fn all_profile_clean_works() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); - - let clean_cmd = CleanArgs { full: false, all_profiles: true }; - clean_cmd.run(&config).unwrap(); - - let dev_profile_name = "dev"; - let release_profile_name = "release"; - - let target_dev_dir = temp_project_dir.join("target").join(dev_profile_name); - let target_release_dir = temp_project_dir.join("target").join(release_profile_name); - - let dev_manifests_dir = temp_project_dir.join(MANIFESTS_DIR).join(dev_profile_name); - let release_manifests_dir = temp_project_dir.join(MANIFESTS_DIR).join(release_profile_name); - - let dev_manifests_base_dir = dev_manifests_dir.join(BASE_DIR); - let dev_manifests_abis_base_dir = dev_manifests_base_dir.join(ABIS_DIR); - let release_manifests_base_dir = release_manifests_dir.join(BASE_DIR); - let release_manifests_abis_base_dir = release_manifests_base_dir.join(ABIS_DIR); - - let dev_manifests_deploy_dir = dev_manifests_dir.join(DEPLOYMENT_DIR); - let dev_manifests_abis_depl_dir = dev_manifests_deploy_dir.join(ABIS_DIR); - - let dev_manifest_toml = dev_manifests_deploy_dir.join("manifest").with_extension("toml"); - let dev_manifest_json = dev_manifests_deploy_dir.join("manifest").with_extension("json"); - - assert!(fs::read_dir(target_dev_dir).is_err(), "Expected 'target/dev' to be empty"); - assert!(fs::read_dir(target_release_dir).is_err(), "Expected 'target/release' to be empty"); - - assert!( - fs::read_dir(dev_manifests_base_dir).is_err(), - "Expected 'manifests/dev/base' to be empty" - ); - assert!( - fs::read_dir(dev_manifests_abis_base_dir).is_err(), - "Expected 'manifests/dev/base/abis' to be empty" - ); - assert!( - fs::read_dir(&dev_manifests_abis_depl_dir).is_ok(), - "Expected 'manifests/dev/deployment/abis' to be empty" - ); - - assert!( - fs::read_dir(release_manifests_base_dir).is_err(), - "Expected 'manifests/release/base' to be empty" - ); - assert!( - fs::read_dir(release_manifests_abis_base_dir).is_err(), - "Expected 'manifests/release/base/abis' to be empty" - ); - - assert!(dev_manifest_toml.exists(), "Expected 'manifest.toml' to exist"); - assert!(dev_manifest_json.exists(), "Expected 'manifest.json' to exist"); - - let clean_cmd = CleanArgs { full: true, all_profiles: true }; - clean_cmd.run(&config).unwrap(); - - assert!( - fs::read_dir(&dev_manifests_abis_depl_dir).is_err(), - "Expected 'manifests/dev/deployment/abis' to be empty" - ); - assert!(!dev_manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); - assert!(!dev_manifest_json.exists(), "Expected 'manifest.json' to not exist"); - } -} +// #[cfg(test)] +// mod tests { +// use dojo_test_utils::compiler::CompilerTestSetup; +// use dojo_world::manifest::DEPLOYMENT_DIR; +// use dojo_world::metadata::ABIS_DIR; +// use scarb::compiler::Profile; +// +// use super::*; +// +// #[test] +// fn default_clean_works() { +// let setup = CompilerTestSetup::from_examples("../../crates/dojo/core", "../../examples/"); +// let config = setup.build_test_config("spawn-and-move", Profile::DEV); +// +// let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); +// +// println!("temp_project_dir: {:?}", temp_project_dir); +// +// let clean_cmd = CleanArgs { full: false, all_profiles: false }; +// clean_cmd.run(&config).unwrap(); +// +// let dev_profile_name = "dev"; +// let release_profile_name = "release"; +// +// let target_dev_dir = temp_project_dir.join("target").join(dev_profile_name); +// let target_release_dir = temp_project_dir.join("target").join(release_profile_name); +// +// let dev_manifests_dir = temp_project_dir.join("manifests").join(dev_profile_name); +// let release_manifests_dir = temp_project_dir.join("manifests").join(release_profile_name); +// +// let dev_manifests_base_dir = dev_manifests_dir.join("base"); +// let dev_manifests_abis_base_dir = dev_manifests_dir.join("base").join("abis"); +// let release_manifests_base_dir = release_manifests_dir.join("base"); +// let release_manifests_abis_base_dir = release_manifests_dir.join("base").join("abis"); +// +// let dev_manifests_depl_dir = dev_manifests_dir.join("deployment"); +// let dev_manifests_abis_depl_dir = dev_manifests_depl_dir.join("abis"); +// let dev_manifest_toml = dev_manifests_depl_dir.join("manifest").with_extension("toml"); +// let dev_manifest_json = dev_manifests_depl_dir.join("manifest").with_extension("json"); +// +// assert!(fs::read_dir(target_dev_dir).is_err(), "Expected 'target/dev' to be empty"); +// assert!( +// fs::read_dir(target_release_dir).is_ok(), +// "Expected 'target/release' to be present" +// ); +// +// assert!( +// fs::read_dir(dev_manifests_base_dir).is_err(), +// "Expected 'manifests/dev/base' to be empty" +// ); +// assert!( +// fs::read_dir(dev_manifests_abis_base_dir).is_err(), +// "Expected 'manifests/dev/base/abis' to be empty" +// ); +// assert!( +// fs::read_dir(&dev_manifests_abis_depl_dir).is_ok(), +// "Expected 'manifests/dev/deployment/abis' to be non empty" +// ); +// +// we expect release profile to be not affected +// assert!( +// fs::read_dir(release_manifests_base_dir).is_ok(), +// "Expected 'manifests/release/base' to be non empty" +// ); +// assert!( +// fs::read_dir(release_manifests_abis_base_dir).is_ok(), +// "Expected 'manifests/release/base/abis' to be non empty" +// ); +// +// assert!(dev_manifest_toml.exists(), "Expected 'manifest.toml' to exist"); +// assert!(dev_manifest_json.exists(), "Expected 'manifest.json' to exist"); +// +// let clean_cmd = CleanArgs { full: true, all_profiles: false }; +// clean_cmd.run(&config).unwrap(); +// +// assert!( +// fs::read_dir(&dev_manifests_abis_depl_dir).is_err(), +// "Expected 'manifests/dev/deployment/abis' to be empty" +// ); +// assert!(!dev_manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); +// assert!(!dev_manifest_json.exists(), "Expected 'manifest.json' to not exist"); +// } +// +// #[test] +// fn all_profile_clean_works() { +// let setup = CompilerTestSetup::from_examples("../../crates/dojo/core", "../../examples/"); +// +// let config = setup.build_test_config("spawn-and-move", Profile::DEV); +// +// let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); +// +// let clean_cmd = CleanArgs { full: false, all_profiles: true }; +// clean_cmd.run(&config).unwrap(); +// +// let dev_profile_name = "dev"; +// let release_profile_name = "release"; +// +// let target_dev_dir = temp_project_dir.join("target").join(dev_profile_name); +// let target_release_dir = temp_project_dir.join("target").join(release_profile_name); +// +// let dev_manifests_dir = temp_project_dir.join(MANIFESTS_DIR).join(dev_profile_name); +// let release_manifests_dir = temp_project_dir.join(MANIFESTS_DIR).join(release_profile_name); +// +// let dev_manifests_base_dir = dev_manifests_dir.join(BASE_DIR); +// let dev_manifests_abis_base_dir = dev_manifests_base_dir.join(ABIS_DIR); +// let release_manifests_base_dir = release_manifests_dir.join(BASE_DIR); +// let release_manifests_abis_base_dir = release_manifests_base_dir.join(ABIS_DIR); +// +// let dev_manifests_deploy_dir = dev_manifests_dir.join(DEPLOYMENT_DIR); +// let dev_manifests_abis_depl_dir = dev_manifests_deploy_dir.join(ABIS_DIR); +// +// let dev_manifest_toml = dev_manifests_deploy_dir.join("manifest").with_extension("toml"); +// let dev_manifest_json = dev_manifests_deploy_dir.join("manifest").with_extension("json"); +// +// assert!(fs::read_dir(target_dev_dir).is_err(), "Expected 'target/dev' to be empty"); +// assert!(fs::read_dir(target_release_dir).is_err(), "Expected 'target/release' to be empty"); +// +// assert!( +// fs::read_dir(dev_manifests_base_dir).is_err(), +// "Expected 'manifests/dev/base' to be empty" +// ); +// assert!( +// fs::read_dir(dev_manifests_abis_base_dir).is_err(), +// "Expected 'manifests/dev/base/abis' to be empty" +// ); +// assert!( +// fs::read_dir(&dev_manifests_abis_depl_dir).is_ok(), +// "Expected 'manifests/dev/deployment/abis' to be empty" +// ); +// +// assert!( +// fs::read_dir(release_manifests_base_dir).is_err(), +// "Expected 'manifests/release/base' to be empty" +// ); +// assert!( +// fs::read_dir(release_manifests_abis_base_dir).is_err(), +// "Expected 'manifests/release/base/abis' to be empty" +// ); +// +// assert!(dev_manifest_toml.exists(), "Expected 'manifest.toml' to exist"); +// assert!(dev_manifest_json.exists(), "Expected 'manifest.json' to exist"); +// +// let clean_cmd = CleanArgs { full: true, all_profiles: true }; +// clean_cmd.run(&config).unwrap(); +// +// assert!( +// fs::read_dir(&dev_manifests_abis_depl_dir).is_err(), +// "Expected 'manifests/dev/deployment/abis' to be empty" +// ); +// assert!(!dev_manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); +// assert!(!dev_manifest_json.exists(), "Expected 'manifest.json' to not exist"); +// } +// } diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index a0ee15de56..d04d026386 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -1,18 +1,23 @@ -use anyhow::Result; +use std::fmt; +use std::str::FromStr; + +use anyhow::{anyhow, Result}; use clap::Args; +use dojo_types::naming; +use dojo_utils::Invoker; use dojo_world::contracts::naming::ensure_namespace; -use dojo_world::metadata::get_default_namespace_from_ws; use scarb::core::Config; -use sozo_ops::execute; -#[cfg(feature = "walnut")] +use sozo_scarbext::WorkspaceExt; use sozo_walnut::WalnutDebugger; +use starknet::core::types::{Call, Felt}; +use starknet::core::utils as snutils; use tracing::trace; -use super::calldata_decoder; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; +use crate::commands::calldata_decoder; use crate::utils; #[derive(Debug, Args)] @@ -53,36 +58,48 @@ pub struct ExecuteArgs { impl ExecuteArgs { pub fn run(self, config: &Config) -> Result<()> { trace!(args = ?self); - let env_metadata = utils::load_metadata_from_config(config)?; - let tag_or_address = if utils::is_address(&self.tag_or_address) { - self.tag_or_address + let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + + let profile_config = ws.load_profile_config()?; + + let descriptor = if utils::is_address(&self.tag_or_address) { + ContractDescriptor::Address(Felt::from_str(&self.tag_or_address)?) } else { - let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - let default_namespace = get_default_namespace_from_ws(&ws)?; - ensure_namespace(&self.tag_or_address, &default_namespace) + ContractDescriptor::Tag(ensure_namespace( + &self.tag_or_address, + &profile_config.namespace.default, + )) }; #[cfg(feature = "walnut")] - let walnut_debugger = WalnutDebugger::new_from_flag( + let _walnut_debugger = WalnutDebugger::new_from_flag( self.transaction.walnut, - self.starknet.url(env_metadata.as_ref())?, + self.starknet.url(profile_config.env.as_ref())?, ); config.tokio_handle().block_on(async { - let world = utils::world_from_env_metadata( - self.world, + let (world_diff, account, _) = utils::get_world_diff_and_account( self.account, - &self.starknet, - &env_metadata, - config, + self.starknet.clone(), + self.world, + &ws, ) .await?; + let contract_address = match &descriptor { + ContractDescriptor::Address(address) => Some(*address), + ContractDescriptor::Tag(tag) => { + let selector = naming::compute_selector_from_tag(tag); + world_diff.get_contract_address(selector) + } + } + .ok_or_else(|| anyhow!("Contract {descriptor} not found in the world diff."))?; + let tx_config = self.transaction.into(); trace!( - contract=?tag_or_address, + contract=?descriptor, entrypoint=self.entrypoint, calldata=?self.calldata, "Executing Execute command." @@ -94,17 +111,33 @@ impl ExecuteArgs { vec![] }; - execute::execute( - &config.ui(), - tag_or_address, - self.entrypoint, + let call = Call { calldata, - &world, - &tx_config, - #[cfg(feature = "walnut")] - &walnut_debugger, - ) - .await + to: contract_address, + selector: snutils::get_selector_from_name(&self.entrypoint)?, + }; + + let invoker = Invoker::new(&account, tx_config); + // TODO: add walnut back, perhaps at the invoker level. + let tx_result = invoker.invoke(call).await?; + + println!("{}", tx_result); + Ok(()) }) } } + +#[derive(Debug)] +pub enum ContractDescriptor { + Address(Felt), + Tag(String), +} + +impl fmt::Display for ContractDescriptor { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ContractDescriptor::Address(address) => write!(f, "{:#066x}", address), + ContractDescriptor::Tag(tag) => write!(f, "{}", tag), + } + } +} diff --git a/bin/sozo/src/commands/hash.rs b/bin/sozo/src/commands/hash.rs index 9f594e0a4e..acf726350a 100644 --- a/bin/sozo/src/commands/hash.rs +++ b/bin/sozo/src/commands/hash.rs @@ -41,9 +41,11 @@ impl HashArgs { if !self.input.contains(',') { let felt = felt_from_str(&self.input)?; let poseidon = format!("{:#066x}", poseidon_hash_single(felt)); + let poseidon_array = format!("{:#066x}", poseidon_hash_many(&[felt])); let snkeccak = format!("{:#066x}", starknet_keccak(&felt.to_bytes_le())); - println!("Poseidon: {}", poseidon); + println!("Poseidon single: {}", poseidon); + println!("Poseidon array 1 value: {}", poseidon_array); println!("SnKeccak: {}", snkeccak); return Ok(vec![poseidon.to_string(), snkeccak.to_string()]); diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index cf840a5416..dd64558abb 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -63,6 +63,8 @@ impl InitArgs { Err(e) => return Err(e.context("Failed to get Sozo version")), }; + trace!(repo_url = repo_url, sozo_version = sozo_version); + clone_repo(&repo_url, &target_dir, &sozo_version, config)?; // Navigate to the newly cloned repo. @@ -107,6 +109,7 @@ fn get_sozo_version() -> Result { } fn check_tag_exists(url: &str, version: &str) -> Result { + trace!(url = url, version = version, "Checking tag."); let output = Command::new("git").args(["ls-remote", "--tags", url]).output()?; let output_str = String::from_utf8(output.stdout)?; diff --git a/bin/sozo/src/commands/inspect.rs b/bin/sozo/src/commands/inspect.rs new file mode 100644 index 0000000000..3d90bf1815 --- /dev/null +++ b/bin/sozo/src/commands/inspect.rs @@ -0,0 +1,505 @@ +use anyhow::Result; +use clap::Args; +use colored::*; +use dojo_types::naming; +use dojo_world::diff::{ResourceDiff, WorldDiff, WorldStatus}; +use dojo_world::ResourceType; +use scarb::core::Config; +use serde::Serialize; +use tabled::settings::object::Cell; +use tabled::settings::{Color, Theme}; +use tabled::{Table, Tabled}; +use tracing::trace; + +use super::options::starknet::StarknetOptions; +use super::options::world::WorldOptions; +use crate::utils; + +#[derive(Debug, Args)] +pub struct InspectArgs { + #[arg(help = "The tag of the resource to inspect. If not provided, a world summary will be \ + displayed.")] + resource: Option, + + #[command(flatten)] + world: WorldOptions, + + #[command(flatten)] + starknet: StarknetOptions, +} + +impl InspectArgs { + pub fn run(self, config: &Config) -> Result<()> { + trace!(args = ?self); + let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + + let InspectArgs { world, starknet, resource } = self; + + config.tokio_handle().block_on(async { + let (world_diff, _, _) = + utils::get_world_diff_and_provider(starknet.clone(), world, &ws).await?; + + if let Some(resource) = resource { + inspect_resource(&resource, &world_diff); + } else { + inspect_world(&world_diff); + } + + Ok(()) + }) + } +} + +#[derive(Debug, Serialize)] +enum ResourceStatus { + Created, + Updated, + Synced, + DirtyLocalPerms, + MigrationSkipped, +} + +impl std::fmt::Display for ResourceStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ResourceStatus::Created => write!(f, "{}", "Created".blue()), + ResourceStatus::Updated => write!(f, "{}", "Updated".yellow()), + ResourceStatus::Synced => write!(f, "{}", "Synced".green()), + ResourceStatus::DirtyLocalPerms => write!(f, "{}", "Dirty local perms".yellow()), + ResourceStatus::MigrationSkipped => write!(f, "{}", "Migration skipped".black()), + } + } +} + +#[derive(Debug, Tabled, Serialize)] +enum ResourceInspect { + Namespace(NamespaceInspect), + Contract(ContractInspect), + Model(ModelInspect), + Event(EventInspect), +} + +#[derive(Debug, Tabled, Serialize)] +struct NamespaceInspect { + #[tabled(rename = "Namespaces")] + name: String, + #[tabled(rename = "Status")] + status: ResourceStatus, + #[tabled(rename = "Dojo Selector")] + selector: String, +} + +#[derive(Debug, Tabled, Serialize)] +struct WorldInspect { + #[tabled(rename = "World")] + status: ResourceStatus, + #[tabled(rename = "Contract Address")] + address: String, + #[tabled(rename = "Class Hash")] + current_class_hash: String, +} + +#[derive(Debug, Tabled, Serialize)] +struct ContractInspect { + #[tabled(rename = "Contracts")] + tag: String, + #[tabled(rename = "Status")] + status: ResourceStatus, + #[tabled(rename = "Is Initialized")] + is_initialized: bool, + #[tabled(rename = "Dojo Selector")] + selector: String, + #[tabled(rename = "Contract Address")] + address: String, + #[tabled(skip)] + current_class_hash: String, +} + +#[derive(Debug, Tabled, Serialize)] +struct ModelInspect { + #[tabled(rename = "Models")] + tag: String, + #[tabled(rename = "Status")] + status: ResourceStatus, + #[tabled(rename = "Dojo Selector")] + selector: String, +} + +#[derive(Debug, Tabled, Serialize)] +struct EventInspect { + #[tabled(rename = "Events")] + tag: String, + #[tabled(rename = "Status")] + status: ResourceStatus, + #[tabled(rename = "Dojo Selector")] + selector: String, +} + +#[derive(Debug, Tabled)] +enum GranteeSource { + #[tabled(rename = "Local")] + Local, + #[tabled(rename = "Remote")] + Remote, + #[tabled(rename = "Synced")] + Synced, +} + +impl std::fmt::Display for GranteeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GranteeSource::Local => write!(f, "{}", "Local".blue()), + GranteeSource::Remote => write!(f, "{}", "Remote".black()), + GranteeSource::Synced => write!(f, "{}", "Synced".green()), + } + } +} + +#[derive(Debug, Tabled)] +struct GranteeDisplay { + #[tabled(rename = "Tag")] + tag: String, + #[tabled(rename = "Contract Address")] + address: String, + #[tabled(rename = "Source")] + source: GranteeSource, +} + +/// Inspects a resource. +fn inspect_resource(resource_name_or_tag: &str, world_diff: &WorldDiff) { + let selector = if naming::is_valid_tag(resource_name_or_tag) { + naming::compute_selector_from_tag(resource_name_or_tag) + } else { + naming::compute_bytearray_hash(resource_name_or_tag) + }; + + let resource_diff = world_diff.resources.get(&selector); + + if resource_diff.is_none() { + println!("Resource not found locally."); + return; + } + + let resource_diff = resource_diff.unwrap(); + + let inspect = resource_diff_display(world_diff, resource_diff); + pretty_print_toml(&toml::to_string_pretty(&inspect).unwrap()); + + let writers = world_diff.get_writers(resource_diff.dojo_selector()); + let mut writers_disp = vec![]; + + for pdiff in writers.only_local() { + writers_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Local, + }); + } + + for pdiff in writers.only_remote() { + writers_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Remote, + }); + } + + for pdiff in writers.synced() { + writers_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Synced, + }); + } + + let owners = world_diff.get_owners(resource_diff.dojo_selector()); + let mut owners_disp = vec![]; + + for pdiff in owners.only_local() { + owners_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Local, + }); + } + + for pdiff in owners.only_remote() { + owners_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Remote, + }); + } + + for pdiff in owners.synced() { + owners_disp.push(GranteeDisplay { + tag: pdiff.tag.unwrap_or("external".to_string()), + address: format!("{:#066x}", pdiff.address), + source: GranteeSource::Synced, + }); + } + + writers_disp.sort_by_key(|m| m.tag.to_string()); + owners_disp.sort_by_key(|m| m.tag.to_string()); + + print_table(&writers_disp, Some(Color::FG_BRIGHT_CYAN), Some("\n> Writers")); + print_table(&owners_disp, Some(Color::FG_BRIGHT_MAGENTA), Some("\n> Owners")); +} + +/// Inspects the whole world. +fn inspect_world(world_diff: &WorldDiff) { + println!(); + + let status = match &world_diff.world_info.status { + WorldStatus::NotDeployed => ResourceStatus::Created, + WorldStatus::NewVersion => ResourceStatus::Updated, + WorldStatus::Synced => ResourceStatus::Synced, + }; + + let world = WorldInspect { + address: format!("{:#066x}", world_diff.world_info.address), + current_class_hash: format!("{:#066x}", world_diff.world_info.class_hash), + status, + }; + + print_table(&[world], Some(Color::FG_BRIGHT_BLACK), None); + + let mut namespaces_disp = vec![]; + let mut contracts_disp = vec![]; + let mut models_disp = vec![]; + let mut events_disp = vec![]; + + for resource in world_diff.resources.values() { + match resource.resource_type() { + ResourceType::Namespace => match resource_diff_display(world_diff, resource) { + ResourceInspect::Namespace(n) => namespaces_disp.push(n), + _ => unreachable!(), + }, + ResourceType::Contract => match resource_diff_display(world_diff, resource) { + ResourceInspect::Contract(c) => contracts_disp.push(c), + _ => unreachable!(), + }, + ResourceType::Model => match resource_diff_display(world_diff, resource) { + ResourceInspect::Model(m) => models_disp.push(m), + _ => unreachable!(), + }, + ResourceType::Event => match resource_diff_display(world_diff, resource) { + ResourceInspect::Event(e) => events_disp.push(e), + _ => unreachable!(), + }, + _ => {} + } + } + + namespaces_disp.sort_by_key(|m| m.name.to_string()); + contracts_disp.sort_by_key(|m| m.tag.to_string()); + models_disp.sort_by_key(|m| m.tag.to_string()); + events_disp.sort_by_key(|m| m.tag.to_string()); + + print_table(&namespaces_disp, Some(Color::FG_BRIGHT_BLACK), None); + print_table(&contracts_disp, Some(Color::FG_BRIGHT_BLACK), None); + print_table(&models_disp, Some(Color::FG_BRIGHT_BLACK), None); + print_table(&events_disp, Some(Color::FG_BRIGHT_BLACK), None); +} + +/// Displays the resource diff with the address and class hash. +fn resource_diff_display(world_diff: &WorldDiff, resource: &ResourceDiff) -> ResourceInspect { + let n_local_writers_only = world_diff.get_writers(resource.dojo_selector()).only_local().len(); + let n_local_owners_only = world_diff.get_owners(resource.dojo_selector()).only_local().len(); + // Dirty perms is pertinent only when the status is synced. + let has_dirty_perms = n_local_writers_only > 0 || n_local_owners_only > 0; + + match resource.resource_type() { + ResourceType::Namespace => { + let status = match resource { + ResourceDiff::Created(_) => ResourceStatus::Created, + ResourceDiff::Synced(_, _) => { + if has_dirty_perms { + ResourceStatus::DirtyLocalPerms + } else { + ResourceStatus::Synced + } + } + _ => unreachable!(), + }; + + let status = if world_diff.profile_config.is_skipped(&resource.tag()) { + ResourceStatus::MigrationSkipped + } else { + status + }; + + ResourceInspect::Namespace(NamespaceInspect { + name: resource.name(), + status, + selector: format!("{:#066x}", resource.dojo_selector()), + }) + } + ResourceType::Contract => { + let (is_initialized, contract_address, status) = match resource { + ResourceDiff::Created(_) => ( + false, + world_diff.get_contract_address(resource.dojo_selector()).unwrap(), + ResourceStatus::Created, + ), + ResourceDiff::Updated(_, remote) => ( + remote.as_contract_or_panic().is_initialized, + remote.address(), + ResourceStatus::Updated, + ), + ResourceDiff::Synced(_, remote) => ( + remote.as_contract_or_panic().is_initialized, + remote.address(), + if has_dirty_perms { + ResourceStatus::DirtyLocalPerms + } else { + ResourceStatus::Synced + }, + ), + }; + + let status = if world_diff.profile_config.is_skipped(&resource.tag()) { + ResourceStatus::MigrationSkipped + } else { + status + }; + + ResourceInspect::Contract(ContractInspect { + tag: resource.tag(), + status, + is_initialized, + address: format!("{:#066x}", contract_address), + current_class_hash: format!("{:#066x}", resource.current_class_hash()), + selector: format!("{:#066x}", resource.dojo_selector()), + }) + } + ResourceType::Model => { + let status = match resource { + ResourceDiff::Created(_) => ResourceStatus::Created, + ResourceDiff::Updated(_, _) => ResourceStatus::Updated, + ResourceDiff::Synced(_, _) => { + if has_dirty_perms { + ResourceStatus::DirtyLocalPerms + } else { + ResourceStatus::Synced + } + } + }; + + let status = if world_diff.profile_config.is_skipped(&resource.tag()) { + ResourceStatus::MigrationSkipped + } else { + status + }; + + ResourceInspect::Model(ModelInspect { + tag: resource.tag(), + status, + selector: format!("{:#066x}", resource.dojo_selector()), + }) + } + ResourceType::Event => { + let status = match resource { + ResourceDiff::Created(_) => ResourceStatus::Created, + ResourceDiff::Updated(_, _) => ResourceStatus::Updated, + ResourceDiff::Synced(_, _) => { + if has_dirty_perms { + ResourceStatus::DirtyLocalPerms + } else { + ResourceStatus::Synced + } + } + }; + + let status = if world_diff.profile_config.is_skipped(&resource.tag()) { + ResourceStatus::MigrationSkipped + } else { + status + }; + + ResourceInspect::Event(EventInspect { + tag: resource.tag(), + status, + selector: format!("{:#066x}", resource.dojo_selector()), + }) + } + ResourceType::StarknetContract => { + todo!() + } + } +} + +/// Prints a table. +fn print_table(data: T, color: Option, title: Option<&str>) +where + T: IntoIterator + Clone, + ::Item: Tabled, +{ + if data.clone().into_iter().count() == 0 { + return; + } + + let mut table = Table::new(data); + table.with(halloween()); + + if let Some(color) = color { + table.modify(Cell::new(0, 0), color); + } + + if let Some(title) = title { + println!("{title}"); + } + + println!("{table}\n"); +} + +pub fn halloween() -> Theme { + let mut style = Theme::default(); + style.set_borders_vertical('💀'); + style.set_borders_left('💀'); + style.set_borders_right('💀'); + + style.set_borders_corner_top_left('🎃'); + + style +} + +/// Pretty prints a TOML string. +fn pretty_print_toml(str: &str) { + for line in str.lines() { + if line.starts_with("[") { + // Print section headers. + println!("\n{}", line.blue()); + } else if line.contains('=') { + // Print key-value pairs with keys in green and values. + let parts: Vec<&str> = line.splitn(2, '=').collect(); + if parts.len() == 2 { + let key = parts[0].trim(); + let value = parts[1].trim().replace("\"", ""); + + let colored_values = match key { + "status" => match value.to_string().as_str() { + "Created" => value.blue(), + "Updated" => value.yellow(), + "Synced" => value.green(), + "DirtyLocalPerms" => "Dirty local permissions".yellow(), + _ => value.white(), + }, + "is_initialized" => match value.to_string().as_str() { + "true" => value.green(), + "false" => value.red(), + _ => value.white(), + }, + _ => value.white(), + }; + + println!("{}: {}", key.black(), colored_values); + } else { + println!("{}", line); + } + } else { + // Print other lines normally. + println!("{}", line); + } + } +} diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index 3d46649d2a..257aaf977e 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -1,29 +1,28 @@ -use anyhow::{anyhow, Context, Result}; -use clap::{Args, Subcommand}; -use dojo_utils::TxnConfig; -use dojo_world::config::Environment; -use dojo_world::manifest::MANIFESTS_DIR; -use dojo_world::metadata::dojo_metadata_from_workspace; -use katana_rpc_api::starknet::RPC_SPEC_VERSION; +use anyhow::{Context, Result}; +use clap::Args; +use colored::Colorize; +use dojo_utils::{self, TxnConfig}; +use dojo_world::contracts::WorldContract; use scarb::core::{Config, Workspace}; -use sozo_ops::migration; -use starknet::accounts::{Account, ConnectedAccount}; -use starknet::core::types::{BlockId, BlockTag, Felt, StarknetError}; +use sozo_ops::migrate::{Migration, MigrationResult, MigrationUi}; +use sozo_scarbext::WorkspaceExt; +use spinoff::{spinner, spinners, Spinner}; use starknet::core::utils::parse_cairo_short_string; -use starknet::providers::jsonrpc::HttpTransport; -use starknet::providers::{JsonRpcClient, Provider, ProviderError}; +use starknet::providers::Provider; +use tabled::settings::Style; +use tabled::{Table, Tabled}; use tracing::trace; -use super::options::account::{AccountOptions, SozoAccount}; +use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; -use crate::commands::options::account::WorldAddressOrName; +use crate::utils; #[derive(Debug, Args)] pub struct MigrateArgs { - #[command(subcommand)] - pub command: MigrateCommand, + #[command(flatten)] + transaction: TransactionOptions, #[command(flatten)] world: WorldOptions, @@ -35,231 +34,87 @@ pub struct MigrateArgs { account: AccountOptions, } -#[derive(Debug, Subcommand)] -pub enum MigrateCommand { - #[command(about = "Plan the migration and output the manifests.")] - Plan, - #[command(about = "Apply the migration on-chain.")] - Apply { - #[command(flatten)] - transaction: TransactionOptions, - }, -} - impl MigrateArgs { - /// Creates a new `MigrateArgs` with the `Apply` command. - pub fn new_apply( - world: WorldOptions, - starknet: StarknetOptions, - account: AccountOptions, - ) -> Self { - Self { - command: MigrateCommand::Apply { transaction: TransactionOptions::init_wait() }, - world, - starknet, - account, - } - } - + /// Runs the migration. pub fn run(self, config: &Config) -> Result<()> { trace!(args = ?self); - let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - let dojo_metadata = dojo_metadata_from_workspace(&ws)?; - let env_metadata = if config.manifest_path().exists() { - dojo_metadata.env().cloned() - } else { - trace!("Manifest path does not exist."); - None - }; - - let profile_name = - ws.current_profile().expect("Scarb profile expected to be defined.").to_string(); - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - if !manifest_dir.join(MANIFESTS_DIR).join(profile_name).exists() { - return Err(anyhow!("Build project using `sozo build` first")); - } + let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + ws.profile_check()?; + ws.ensure_profile_artifacts()?; let MigrateArgs { world, starknet, account, .. } = self; - let name = dojo_metadata.world.seed; - - let (world_address, account, rpc_url) = config.tokio_handle().block_on(async { - setup_env(&ws, account, starknet, world, &name, env_metadata.as_ref()).await - })?; - - match self.command { - MigrateCommand::Plan => config - .tokio_handle() - .block_on(async { - trace!(name, "Planning migration."); - migration::migrate( - &ws, - world_address, - rpc_url, - account, - &name, - true, - TxnConfig::default(), - dojo_metadata.migration.map(|m| m.skip_contracts.clone()), - ) - .await - }) - .map(|_| ()), - MigrateCommand::Apply { transaction } => config - .tokio_handle() - .block_on(async { - trace!(name, "Applying migration."); - let txn_config: TxnConfig = transaction.into(); - - migration::migrate( - &ws, - world_address, - rpc_url, - account, - &name, - false, - txn_config, - dojo_metadata.migration.map(|m| m.skip_contracts.clone()), - ) - .await - }) - .map(|_| ()), - } - } -} - -pub async fn setup_env<'a>( - ws: &'a Workspace<'a>, - account: AccountOptions, - starknet: StarknetOptions, - world: WorldOptions, - name: &str, - env: Option<&'a Environment>, -) -> Result<(Option, SozoAccount>, String)> { - trace!("Setting up environment."); - let ui = ws.config().ui(); - - let world_address = world.address(env).ok(); - trace!(?world_address); + let frames = spinner!(["⛩️ ", "🎃", "👻", "🧟", "💀"], 500); + // let frames = spinner!(["⛩️ ", "🥷 ", "🗡️ "], 500); - let (account, rpc_url) = { - let provider = starknet.provider(env)?; - trace!(?provider, "Provider initialized."); + config.tokio_handle().block_on(async { + print_banner(&ws, &starknet).await?; - let spec_version = provider.spec_version().await?; - trace!(spec_version); + let mut spinner = + MigrationUi::Spinner(Spinner::new(frames, "Evaluating world diff...", None)); - if !is_compatible_version(&spec_version, RPC_SPEC_VERSION)? { - return Err(anyhow!( - "Unsupported Starknet RPC version: {}, expected {}.", - spec_version, - RPC_SPEC_VERSION - )); - } + let mut txn_config: TxnConfig = self.transaction.into(); + txn_config.wait = true; - let rpc_url = starknet.url(env)?; - trace!(?rpc_url); + let (world_diff, account, rpc_url) = + utils::get_world_diff_and_account(account, starknet, world, &ws).await?; - let chain_id = provider.chain_id().await?; - let chain_id = parse_cairo_short_string(&chain_id) - .with_context(|| "Cannot parse chain_id as string")?; - trace!(chain_id); + let world_address = world_diff.world_info.address; - let account = { - // This is mainly for controller account for creating policies. - let world_address_or_name = world_address - .map(WorldAddressOrName::Address) - .unwrap_or(WorldAddressOrName::Name(name.to_string())); + let migration = Migration::new( + world_diff, + WorldContract::new(world_address, &account), + txn_config, + ws.load_profile_config()?, + rpc_url, + ); - account.account(provider, world_address_or_name, &starknet, env, ws.config()).await? - }; + let MigrationResult { manifest, has_changes } = + migration.migrate(&mut spinner).await.context("💀 Migration failed.")?; - let address = account.address(); + spinner.update_text("Writing manifest..."); + ws.write_manifest_profile(manifest).context("🪦 Failed to write manifest.")?; - ui.print(format!("\nMigration account: {address:#x}")); + let colored_address = format!("{:#066x}", world_address).green(); - ui.print(format!("\nWorld name: {name}")); + let (symbol, end_text) = if has_changes { + ("⛩️ ", format!("Migration successful with world at address {}", colored_address)) + } else { + ("🎃", format!("No changes for world at address {:#066x}", world_address)) + }; - ui.print(format!("\nChain ID: {chain_id}\n")); + spinner.stop_and_persist(symbol, Box::leak(end_text.into_boxed_str())); - match account.provider().get_class_hash_at(BlockId::Tag(BlockTag::Pending), address).await { - Ok(_) => Ok((account, rpc_url)), - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { - Err(anyhow!("Account with address {:#x} doesn't exist.", account.address())) - } - Err(e) => Err(e.into()), - } + Ok(()) + }) } - .with_context(|| "Problem initializing account for migration.")?; - - Ok((world_address, account, rpc_url.to_string())) } -/// Checks if the provided version string is compatible with the expected version string using -/// semantic versioning rules. Includes specific backward compatibility rules, e.g., version 0.6 is -/// compatible with 0.7. -/// -/// # Arguments -/// -/// * `provided_version` - The version string provided by the user. -/// * `expected_version` - The expected version string. -/// -/// # Returns -/// -/// * `Result` - Returns `true` if the provided version is compatible with the expected -/// version, `false` otherwise. -fn is_compatible_version(provided_version: &str, expected_version: &str) -> Result { - use semver::{Version, VersionReq}; - - let provided_ver = Version::parse(provided_version) - .map_err(|e| anyhow!("Failed to parse provided version '{}': {}", provided_version, e))?; - let expected_ver = Version::parse(expected_version) - .map_err(|e| anyhow!("Failed to parse expected version '{}': {}", expected_version, e))?; - - // Specific backward compatibility rule: 0.6 is compatible with 0.7. - if (provided_ver.major == 0 && provided_ver.minor == 7) - && (expected_ver.major == 0 && expected_ver.minor == 6) - { - return Ok(true); - } - - let expected_ver_req = VersionReq::parse(expected_version).map_err(|e| { - anyhow!("Failed to parse expected version requirement '{}': {}", expected_version, e) - })?; - - Ok(expected_ver_req.matches(&provided_ver)) +#[derive(Debug, Tabled)] +pub struct Banner { + pub profile: String, + pub chain_id: String, + pub rpc_url: String, } -#[cfg(test)] -mod tests { - use super::*; +/// Prints the migration banner. +async fn print_banner(ws: &Workspace<'_>, starknet: &StarknetOptions) -> Result<()> { + let (provider, rpc_url) = starknet.provider(None)?; - #[test] - fn test_is_compatible_version_major_mismatch() { - assert!(!is_compatible_version("1.0.0", "2.0.0").unwrap()); - } + let chain_id = provider.chain_id().await?; + let chain_id = parse_cairo_short_string(&chain_id) + .with_context(|| "💀 Cannot parse chain_id as string")?; - #[test] - fn test_is_compatible_version_minor_compatible() { - assert!(is_compatible_version("1.2.0", "1.1.0").unwrap()); - } + let banner = Banner { + profile: ws.current_profile().expect("💀 Scarb profile should be set.").to_string(), + chain_id, + rpc_url, + }; - #[test] - fn test_is_compatible_version_minor_mismatch() { - assert!(!is_compatible_version("0.2.0", "0.7.0").unwrap()); - } + println!(); + println!("{}", Table::new(&[banner]).with(Style::psql())); + println!(); - #[test] - fn test_is_compatible_version_specific_backward_compatibility() { - let node_version = "0.7.1"; - let katana_version = "0.6.0"; - assert!(is_compatible_version(node_version, katana_version).unwrap()); - } - - #[test] - fn test_is_compatible_version_invalid_version_string() { - assert!(is_compatible_version("1.0", "1.0.0").is_err()); - assert!(is_compatible_version("1.0.0", "1.0").is_err()); - } + Ok(()) } diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 815265bdfd..db3f634390 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -3,104 +3,65 @@ use core::fmt; use anyhow::Result; use clap::Subcommand; use scarb::core::{Config, Package, Workspace}; +use tracing::info_span; -pub(crate) mod account; -pub(crate) mod auth; pub(crate) mod build; pub(crate) mod call; pub(crate) mod calldata_decoder; pub(crate) mod clean; -pub(crate) mod completions; -pub(crate) mod dev; -pub(crate) mod events; pub(crate) mod execute; pub(crate) mod hash; pub(crate) mod init; -pub(crate) mod keystore; +pub(crate) mod inspect; pub(crate) mod migrate; -pub(crate) mod model; pub(crate) mod options; -pub(crate) mod print_env; -pub(crate) mod register; pub(crate) mod test; -use account::AccountArgs; -use auth::AuthArgs; use build::BuildArgs; use call::CallArgs; use clean::CleanArgs; -use completions::CompletionsArgs; -use dev::DevArgs; -use events::EventsArgs; use execute::ExecuteArgs; +use hash::HashArgs; use init::InitArgs; -use keystore::KeystoreArgs; +use inspect::InspectArgs; use migrate::MigrateArgs; -use model::ModelArgs; -use print_env::PrintEnvArgs; -use register::RegisterArgs; use test::TestArgs; -use tracing::info_span; #[derive(Debug, Subcommand)] pub enum Commands { - #[command(about = "Manage accounts")] - Account(AccountArgs), - #[command(about = "Manage keystore files")] - Keystore(KeystoreArgs), #[command(about = "Build the world, generating the necessary artifacts for deployment")] Build(BuildArgs), - #[command(about = "Initialize a new project")] - Init(InitArgs), - #[command(about = "Remove generated artifacts, manifests and abis")] - Clean(CleanArgs), #[command(about = "Run a migration, declaring and deploying contracts as necessary to update \ the world")] Migrate(Box), - #[command(about = "Developer mode: watcher for building and migration")] - Dev(DevArgs), - #[command(about = "Test the project's smart contracts")] - Test(TestArgs), - #[command(about = "Execute a world's system")] - Execute(ExecuteArgs), - #[command(about = "Call a world's system")] - Call(CallArgs), - #[command(about = "Interact with a worlds models")] - Model(ModelArgs), - #[command(about = "Register new models")] - Register(RegisterArgs), - #[command(about = "Select a model")] - Hash(hash::HashArgs), - #[command(about = "Queries world events")] - Events(EventsArgs), - #[command(about = "Manage world authorization")] - Auth(AuthArgs), - #[command(about = "Generate shell completion file for specified shell")] - Completions(CompletionsArgs), - #[command(about = "Print information about current")] - PrintEnv(PrintEnvArgs), + #[command(about = "Execute a system with the given calldata.")] + Execute(Box), + #[command(about = "Inspect the world")] + Inspect(Box), + #[command(about = "Clean the build directory")] + Clean(Box), + #[command(about = "Call a contract")] + Call(Box), + #[command(about = "Runs cairo tests")] + Test(Box), + #[command(about = "Computes hash with different hash functions")] + Hash(Box), + #[command(about = "Initialize a new dojo project")] + Init(Box), } impl fmt::Display for Commands { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Commands::Account(_) => write!(f, "Account"), - Commands::Keystore(_) => write!(f, "Keystore"), Commands::Build(_) => write!(f, "Build"), - Commands::Init(_) => write!(f, "Init"), Commands::Clean(_) => write!(f, "Clean"), - Commands::Migrate(_) => write!(f, "Migrate"), - Commands::Dev(_) => write!(f, "Dev"), - Commands::Test(_) => write!(f, "Test"), Commands::Execute(_) => write!(f, "Execute"), + Commands::Inspect(_) => write!(f, "Inspect"), + Commands::Migrate(_) => write!(f, "Migrate"), Commands::Call(_) => write!(f, "Call"), - Commands::Model(_) => write!(f, "Model"), - Commands::Register(_) => write!(f, "Register"), + Commands::Test(_) => write!(f, "Test"), Commands::Hash(_) => write!(f, "Hash"), - Commands::Events(_) => write!(f, "Events"), - Commands::Auth(_) => write!(f, "Auth"), - Commands::Completions(_) => write!(f, "Completions"), - Commands::PrintEnv(_) => write!(f, "PrintEnv"), + Commands::Init(_) => write!(f, "Init"), } } } @@ -114,23 +75,15 @@ pub fn run(command: Commands, config: &Config) -> Result<()> { // useful to write tests for each command. match command { - Commands::Account(args) => args.run(config), - Commands::Keystore(args) => args.run(config), - Commands::Init(args) => args.run(config), - Commands::Clean(args) => args.run(config), - Commands::Test(args) => args.run(config), Commands::Build(args) => args.run(config), Commands::Migrate(args) => args.run(config), - Commands::Dev(args) => args.run(config), - Commands::Auth(args) => args.run(config), Commands::Execute(args) => args.run(config), + Commands::Inspect(args) => args.run(config), + Commands::Clean(args) => args.run(config), Commands::Call(args) => args.run(config), - Commands::Model(args) => args.run(config), - Commands::Register(args) => args.run(config), + Commands::Test(args) => args.run(config), Commands::Hash(args) => args.run().map(|_| ()), - Commands::Events(args) => args.run(config), - Commands::PrintEnv(args) => args.run(config), - Commands::Completions(args) => args.run(), + Commands::Init(args) => args.run(config), } } diff --git a/bin/sozo/src/commands/options/account/controller.rs b/bin/sozo/src/commands/options/account/controller.rs index 4f58ad6ca5..4e4801f777 100644 --- a/bin/sozo/src/commands/options/account/controller.rs +++ b/bin/sozo/src/commands/options/account/controller.rs @@ -1,28 +1,20 @@ use std::sync::Arc; -use anyhow::{bail, Context, Result}; -use camino::{Utf8Path, Utf8PathBuf}; -use dojo_world::contracts::naming::get_name_from_tag; -use dojo_world::manifest::{BaseManifest, Class, DojoContract, Manifest}; -use dojo_world::migration::strategy::generate_salt; -use scarb::core::Config; +use anyhow::{bail, Result}; +use dojo_world::diff::WorldDiff; +use dojo_world::ResourceType; use slot::account_sdk::account::session::hash::{Policy, ProvedPolicy}; use slot::account_sdk::account::session::merkle::MerkleTree; use slot::account_sdk::account::session::SessionAccount; use slot::session::{FullSessionInfo, PolicyMethod}; use starknet::core::types::contract::{AbiEntry, StateMutability}; use starknet::core::types::Felt; -use starknet::core::utils::{ - cairo_short_string_to_felt, get_contract_address, get_selector_from_name, -}; +use starknet::core::utils::get_selector_from_name; use starknet::macros::felt; use starknet::providers::Provider; -use starknet_crypto::poseidon_hash_single; use tracing::trace; use url::Url; -use super::WorldAddressOrName; - // Why the Arc? becaues the Controller account implementation over on `account_sdk` crate is // riddled with `+ Clone` bounds on its Provider generic. So we explicitly specify that the Provider // impl here is wrapped in an Arc to satisfy the Clone bound. Otherwise, you would get a 'trait @@ -45,15 +37,14 @@ pub type ControllerSessionAccount

= SessionAccount>; /// * Slot hosted networks #[tracing::instrument( name = "create_controller", - skip(rpc_url, provider, world_addr_or_name, config) + skip(rpc_url, provider, world_address, world_diff) )] pub async fn create_controller

( // Ideally we can get the url from the provider so we dont have to pass an extra url param here rpc_url: Url, provider: P, - // Use to either specify the world address or compute the world address from the world name - world_addr_or_name: WorldAddressOrName, - config: &Config, + world_address: Felt, + world_diff: &WorldDiff, ) -> Result> where P: Provider, @@ -71,13 +62,14 @@ where bail!("No Controller is associated with this account."); }; + let policies = collect_policies(world_address, contract_address, world_diff)?; + // Check if the session exists, if not create a new one let session_details = match slot::session::get(chain_id)? { Some(session) => { trace!(target: "account::controller", expires_at = %session.session.expires_at, policies = session.session.policies.len(), "Found existing session."); // Check if the policies have changed - let policies = collect_policies(world_addr_or_name, contract_address, config)?; let is_equal = is_equal_to_existing(&policies, &session); if is_equal { @@ -99,7 +91,6 @@ where // Create a new session if not found None => { trace!(target: "account::controller", %username, chain = format!("{chain_id:#}"), "Creating new session."); - let policies = collect_policies(world_addr_or_name, contract_address, config)?; let session = slot::session::create(rpc_url.clone(), &policies).await?; slot::session::store(chain_id, &session)?; session @@ -141,48 +132,36 @@ fn is_equal_to_existing(new_policies: &[PolicyMethod], session_info: &FullSessio /// This function collect all the contracts' methods in the current project according to the /// project's base manifest ( `/manifests//base` ) and convert them into policies. fn collect_policies( - world_addr_or_name: WorldAddressOrName, + world_address: Felt, user_address: Felt, - config: &Config, + world_diff: &WorldDiff, ) -> Result> { - let root_dir = config.root(); - let manifest = get_project_base_manifest(root_dir, config.profile().as_str())?; - let policies = - collect_policies_from_base_manifest(world_addr_or_name, user_address, root_dir, manifest)?; + let policies = collect_policies_from_local_world(world_address, user_address, world_diff)?; trace!(target: "account::controller", policies_count = policies.len(), "Extracted policies from project."); Ok(policies) } -fn get_project_base_manifest(root_dir: &Utf8Path, profile: &str) -> Result { - let mut manifest_path = root_dir.to_path_buf(); - manifest_path.extend(["manifests", profile, "base"]); - Ok(BaseManifest::load_from_path(&manifest_path)?) -} - -fn collect_policies_from_base_manifest( - world_address: WorldAddressOrName, +fn collect_policies_from_local_world( + world_address: Felt, user_address: Felt, - base_path: &Utf8Path, - manifest: BaseManifest, + world_diff: &WorldDiff, ) -> Result> { let mut policies: Vec = Vec::new(); - let base_path: Utf8PathBuf = base_path.to_path_buf(); - - // compute the world address here if it's a name - let world_address = get_dojo_world_address(world_address, &manifest)?; // get methods from all project contracts - for contract in manifest.contracts { - let contract_address = get_dojo_contract_address(world_address, &contract, &manifest.base); - let abis = contract.inner.abi.unwrap().load_abi_string(&base_path)?; - let abis = serde_json::from_str::>(&abis)?; - policies_from_abis(&mut policies, &contract.inner.tag, contract_address, &abis); + for (selector, resource) in world_diff.resources.iter() { + if resource.resource_type() == ResourceType::Contract { + // Safe to unwrap the two methods since the selector comes from the resources registry + // in the local world. + let contract_address = world_diff.get_contract_address(*selector).unwrap(); + let sierra_class = world_diff.get_class(*selector).unwrap(); + + policies_from_abis(&mut policies, &resource.tag(), contract_address, &sierra_class.abi); + } } // get method from world contract - let abis = manifest.world.inner.abi.unwrap().load_abi_string(&base_path)?; - let abis = serde_json::from_str::>(&abis)?; - policies_from_abis(&mut policies, "world", world_address, &abis); + policies_from_abis(&mut policies, "world", world_address, &world_diff.world_info.class.abi); // special policy for sending declare tx // corresponds to [account_sdk::account::DECLARATION_SELECTOR] @@ -229,73 +208,44 @@ fn policies_from_abis( } } -fn get_dojo_contract_address( - world_address: Felt, - contract: &Manifest, - base_class: &Manifest, -) -> Felt { - // The `base_class_hash` field in the Contract's base manifest is initially set to ZERO, - // so we need to use the `class_hash` from the base class manifest instead. - let base_class_hash = if contract.inner.base_class_hash != Felt::ZERO { - contract.inner.base_class_hash - } else { - base_class.inner.class_hash - }; - - if let Some(address) = contract.inner.address { - address - } else { - let salt = generate_salt(&get_name_from_tag(&contract.inner.tag)); - get_contract_address(salt, base_class_hash, &[], world_address) - } -} - -fn get_dojo_world_address( - world_address: WorldAddressOrName, - manifest: &BaseManifest, -) -> Result { - match world_address { - WorldAddressOrName::Address(addr) => Ok(addr), - WorldAddressOrName::Name(name) => { - let seed = cairo_short_string_to_felt(&name).context("Failed to parse World name.")?; - let salt = poseidon_hash_single(seed); - let address = get_contract_address( - salt, - manifest.world.inner.original_class_hash, - &[manifest.base.inner.original_class_hash], - Felt::ZERO, - ); - Ok(address) - } - } -} - #[cfg(test)] mod tests { use dojo_test_utils::compiler::CompilerTestSetup; + use dojo_world::diff::WorldDiff; use scarb::compiler::Profile; + use sozo_scarbext::WorkspaceExt; use starknet::macros::felt; use super::{collect_policies, PolicyMethod}; - use crate::commands::options::account::WorldAddressOrName; #[test] fn collect_policies_from_project() { - let config = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/") - .build_test_config("spawn-and-move", Profile::DEV); + let current_dir = std::env::current_dir().unwrap(); + println!("Current directory: {:?}", current_dir); + let setup = CompilerTestSetup::from_examples("../../crates/dojo/core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); - let world_addr = felt!("0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a"); - let user_addr = felt!("0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"); + let ws = scarb::ops::read_workspace(config.manifest_path(), &config) + .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let policies = - collect_policies(WorldAddressOrName::Address(world_addr), user_addr, &config).unwrap(); + let world_local = ws.load_world_local().unwrap(); + let world_diff = WorldDiff::from_local(world_local).unwrap(); - // Get test data - let test_data = include_str!("../../../../tests/test_data/policies.json"); - let expected_policies: Vec = serde_json::from_str(test_data).unwrap(); + let user_addr = felt!("0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"); - // Compare the collected policies with the test data - assert_eq!(policies.len(), expected_policies.len()); - expected_policies.iter().for_each(|p| assert!(policies.contains(p))); + let policies = + collect_policies(world_diff.world_info.address, user_addr, &world_diff).unwrap(); + + if std::env::var("POLICIES_FIX").is_ok() { + let policies_json = serde_json::to_string_pretty(&policies).unwrap(); + println!("{}", policies_json); + } else { + let test_data = include_str!("../../../../tests/test_data/policies.json"); + let expected_policies: Vec = serde_json::from_str(test_data).unwrap(); + + // Compare the collected policies with the test data. + assert_eq!(policies.len(), expected_policies.len()); + expected_policies.iter().for_each(|p| assert!(policies.contains(p))); + } } } diff --git a/bin/sozo/src/commands/options/account/mod.rs b/bin/sozo/src/commands/options/account/mod.rs index 89231243b5..f9b35952a5 100644 --- a/bin/sozo/src/commands/options/account/mod.rs +++ b/bin/sozo/src/commands/options/account/mod.rs @@ -4,7 +4,7 @@ use anyhow::{anyhow, Context, Result}; use clap::Args; use dojo_utils::env::DOJO_ACCOUNT_ADDRESS_ENV_VAR; use dojo_world::config::Environment; -use scarb::core::Config; +use dojo_world::diff::WorldDiff; use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount}; use starknet::core::types::{BlockId, BlockTag, Felt}; use starknet::providers::Provider; @@ -23,15 +23,6 @@ mod r#type; use controller::ControllerSessionAccount; pub use r#type::*; -/// Helper type for identifying how the world address will be provided. -/// If it's a name, it will be used as the seed for computing the address. -/// Else if it's an address, it will be used directly. -#[derive(Debug)] -pub enum WorldAddressOrName { - Address(Felt), - Name(String), -} - // INVARIANT: // - For commandline: we can either specify `private_key` or `keystore_path` along with // `keystore_password`. This is enforced by Clap. @@ -68,14 +59,14 @@ impl AccountOptions { &self, rpc_url: Url, provider: P, - world_address_or_name: WorldAddressOrName, - config: &Config, + world_address: Felt, + world_diff: &WorldDiff, ) -> Result> where P: Provider, P: Send + Sync, { - controller::create_controller(rpc_url, provider, world_address_or_name, config) + controller::create_controller(rpc_url, provider, world_address, world_diff) .await .context("Failed to create a Controller account") } @@ -83,10 +74,10 @@ impl AccountOptions { pub async fn account

( &self, provider: P, - world_address_or_name: WorldAddressOrName, + world_address: Felt, starknet: &StarknetOptions, env_metadata: Option<&Environment>, - config: &Config, + world_diff: &WorldDiff, ) -> Result> where P: Provider, @@ -95,7 +86,7 @@ impl AccountOptions { #[cfg(feature = "controller")] if self.controller { let url = starknet.url(env_metadata)?; - let account = self.controller(url, provider, world_address_or_name, config).await?; + let account = self.controller(url, provider, world_address, world_diff).await?; return Ok(SozoAccount::Controller(account)); } @@ -113,7 +104,6 @@ impl AccountOptions { P: Send + Sync, { let account_address = self.account_address(env_metadata)?; - trace!(?account_address, "Account address determined."); let signer = self.signer.signer(env_metadata, false)?; trace!(?signer, "Signer obtained."); diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index eb4cc5fe32..8a14e61fbe 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -124,7 +124,7 @@ impl SignerOptions { } /// Retrieves the private key from the CLI or environment metadata. - pub fn private_key(&self, env_metadata: Option<&Environment>) -> Option { + pub fn _private_key(&self, env_metadata: Option<&Environment>) -> Option { if let Some(s) = &self.private_key { Some(s.to_owned()) } else { @@ -133,7 +133,7 @@ impl SignerOptions { } /// Retrieves the keystore path from the CLI or environment metadata. - pub fn keystore_path(&self, env_metadata: Option<&Environment>) -> Option { + pub fn _keystore_path(&self, env_metadata: Option<&Environment>) -> Option { if let Some(s) = &self.keystore_path { Some(s.to_owned()) } else { diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 78e32734ff..2c60165393 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -18,13 +18,16 @@ pub struct StarknetOptions { } impl StarknetOptions { + /// Returns a [`JsonRpcClient`] and the rpc url. + /// + /// It would be convenient to have the rpc url retrievable from the Provider trait instead. pub fn provider( &self, env_metadata: Option<&Environment>, - ) -> Result> { + ) -> Result<(JsonRpcClient, String)> { let url = self.url(env_metadata)?; trace!(?url, "Creating JsonRpcClient with given RPC URL."); - Ok(JsonRpcClient::new(HttpTransport::new(url))) + Ok((JsonRpcClient::new(HttpTransport::new(url.clone())), url.to_string())) } // We dont check the env var because that would be handled by `clap`. diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 998ea89ce2..9b04a857b5 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -2,7 +2,6 @@ use anyhow::{bail, Result}; use clap::Args; use dojo_utils::{TxnAction, TxnConfig}; use starknet::core::types::Felt; -use tracing::trace; #[derive(Debug, Args, Default)] #[command(next_help_heading = "Transaction options")] @@ -42,6 +41,12 @@ pub struct TransactionOptions { #[arg(help = "Display the link to debug the transaction with Walnut.")] #[arg(global = true)] pub walnut: bool, + + #[arg(long)] + #[arg(help = "The timeout in milliseconds for the transaction wait.")] + #[arg(value_name = "TIMEOUT-MS")] + #[arg(global = true)] + pub timeout: Option, } impl TransactionOptions { @@ -62,6 +67,7 @@ impl TransactionOptions { max_fee_raw: self.max_fee_raw, fee_estimate_multiplier: self.fee_estimate_multiplier, walnut: self.walnut, + timeout_ms: self.timeout, }), } } @@ -69,18 +75,13 @@ impl TransactionOptions { impl From for TxnConfig { fn from(value: TransactionOptions) -> Self { - trace!( - fee_estimate_multiplier = value.fee_estimate_multiplier, - wait = value.wait, - receipt = value.receipt, - "Converting TransactionOptions to TxnConfig." - ); Self { fee_estimate_multiplier: value.fee_estimate_multiplier, wait: value.wait || value.walnut, receipt: value.receipt, max_fee_raw: value.max_fee_raw, walnut: value.walnut, + timeout_ms: value.timeout, } } } diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index 86d8aab560..76f3dc309e 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anyhow::{anyhow, Result}; +use anyhow::Result; use clap::Args; use dojo_utils::env::DOJO_WORLD_ADDRESS_ENV_VAR; use dojo_world::config::Environment; @@ -17,18 +17,16 @@ pub struct WorldOptions { } impl WorldOptions { - pub fn address(&self, env_metadata: Option<&Environment>) -> Result { + pub fn address(&self, env_metadata: Option<&Environment>) -> Result> { if let Some(world_address) = self.world_address { trace!(?world_address, "Loaded world_address."); - Ok(world_address) + Ok(Some(world_address)) } else if let Some(world_address) = env_metadata.and_then(|env| env.world_address()) { trace!(world_address, "Loaded world_address from env metadata."); - Ok(Felt::from_str(world_address)?) + Ok(Some(Felt::from_str(world_address)?)) } else { - Err(anyhow!( - "Could not find World address. Please specify it with --world, environment \ - variable or in the world config." - )) + trace!("No world address found."); + Ok(None) } } } @@ -36,6 +34,8 @@ impl WorldOptions { #[cfg(test)] mod tests { + use std::str::FromStr; + use clap::Parser; use starknet_crypto::Felt; @@ -52,13 +52,13 @@ mod tests { std::env::set_var(DOJO_WORLD_ADDRESS_ENV_VAR, "0x0"); let cmd = Command::parse_from([""]); - assert_eq!(cmd.inner.world_address, Some(Felt::from_hex("0x0").unwrap())); + assert_eq!(cmd.inner.world_address, Some(Felt::from_str("0x0").unwrap())); } #[test] fn world_address_from_args() { let cmd = Command::parse_from(["sozo", "--world", "0x0"]); - assert_eq!(cmd.inner.address(None).unwrap(), Felt::from_hex("0x0").unwrap()); + assert_eq!(cmd.inner.address(None).unwrap(), Some(Felt::from_str("0x0").unwrap())); } #[test] @@ -69,7 +69,10 @@ mod tests { }; let cmd = Command::parse_from([""]); - assert_eq!(cmd.inner.address(Some(&env_metadata)).unwrap(), Felt::from_hex("0x0").unwrap()); + assert_eq!( + cmd.inner.address(Some(&env_metadata)).unwrap(), + Some(Felt::from_hex("0x0").unwrap()) + ); } #[test] @@ -80,12 +83,15 @@ mod tests { }; let cmd = Command::parse_from(["sozo", "--world", "0x1"]); - assert_eq!(cmd.inner.address(Some(&env_metadata)).unwrap(), Felt::from_hex("0x1").unwrap()); + assert_eq!( + cmd.inner.address(Some(&env_metadata)).unwrap(), + Some(Felt::from_hex("0x1").unwrap()) + ); } #[test] fn world_address_from_neither() { let cmd = Command::parse_from([""]); - assert!(cmd.inner.address(None).is_err()); + assert!(cmd.inner.address(None).is_ok()); } } diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index 05a3dc4daa..772a87df1a 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -1,28 +1,42 @@ //! Compiles and runs tests for a Dojo project. +//! +//! We can't use scarb to run tests since our injection will not work. +//! Scarb uses other binaries to run tests. Dojo plugin injection is done in scarb itself. +//! When proc macro will be fully supported, we can switch back to scarb. use anyhow::{bail, Result}; use cairo_lang_compiler::db::RootDatabase; use cairo_lang_compiler::diagnostics::DiagnosticsReporter; use cairo_lang_compiler::project::{ProjectConfig, ProjectConfigContent}; use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; -use cairo_lang_filesystem::ids::Directory; +use cairo_lang_filesystem::db::{CrateSettings, ExperimentalFeaturesConfig, FilesGroup}; +use cairo_lang_filesystem::ids::{CrateId, CrateLongId, Directory}; +use cairo_lang_project::AllCratesConfig; use cairo_lang_starknet::starknet_plugin_suite; -use cairo_lang_test_plugin::test_plugin_suite; +use cairo_lang_test_plugin::{test_plugin_suite, TestsCompilationConfig}; use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestCompiler, TestRunConfig}; +use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use clap::Args; -use dojo_lang::compiler::{collect_core_crate_ids, collect_external_crate_ids, Props}; -use dojo_lang::plugin::dojo_plugin_suite; -use dojo_lang::scarb_internal::{cfg_set_from_component, crates_config_for_compilation_unit}; -use dojo_world::metadata::dojo_metadata_from_package; -use scarb::compiler::helpers::{collect_all_crate_ids, collect_main_crate_ids}; -use scarb::compiler::{CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes}; +use dojo_lang::dojo_plugin_suite; +use itertools::Itertools; +use scarb::compiler::{ + CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes, ContractSelector, +}; use scarb::core::{Config, Package, TargetKind}; use scarb::ops::{self, CompileOpts}; use scarb_ui::args::{FeaturesSpec, PackagesFilter}; +use serde::{Deserialize, Serialize}; +use smol_str::SmolStr; use tracing::trace; +pub const WORLD_QUALIFIED_PATH: &str = "dojo::world::world_contract::world"; + use super::check_package_dojo_version; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::test"; +#[derive(Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct Props { + pub build_external_contracts: Option>, +} #[derive(Debug, Clone, PartialEq, clap::ValueEnum)] pub enum ProfilerMode { @@ -71,6 +85,7 @@ pub struct TestArgs { } impl TestArgs { + // TODO: move this into the DojoCompiler. pub fn run(self, config: &Config) -> anyhow::Result<()> { let ws = ops::read_workspace(config.manifest_path(), config).unwrap_or_else(|err| { eprintln!("error: {err}"); @@ -119,7 +134,7 @@ impl TestArgs { .collect::>(); for unit in compilation_units { - let mut unit = if let CompilationUnit::Cairo(unit) = unit { + let unit = if let CompilationUnit::Cairo(unit) = unit { unit } else { continue; @@ -127,30 +142,6 @@ impl TestArgs { config.ui().print(format!("testing {}", unit.name())); - let root_dojo_metadata = dojo_metadata_from_package(&unit.components[0].package, &ws)?; - - // For each component in the compilation unit (namely, the dependencies being - // compiled) we inject into the `CfgSet` the component name and - // namespace configuration. Doing this here ensures the parsing of - // of the manifest is done once at compile time, and not everytime - // the plugin is called. - for c in unit.components.iter_mut() { - c.cfg_set = Some(cfg_set_from_component( - c, - &root_dojo_metadata.namespace, - &config.ui(), - &ws, - )?); - - // As we override all the components CfgSet to ensure the namespace mapping - // is effective for all of them, we must also insert the "test" and "target" - // configs here to ensure correct testing configuration. - if let Some(cfg_set) = c.cfg_set.as_mut() { - cfg_set.insert(Cfg::name("test")); - cfg_set.insert(Cfg::kv("target", "test")); - } - } - let props: Props = unit.main_component().target_props()?; let db = build_root_database(&unit)?; @@ -158,16 +149,12 @@ impl TestArgs { bail!("failed to compile"); } - let mut main_crate_ids = collect_all_crate_ids(&unit, &db); - let test_crate_ids = collect_main_crate_ids(&unit, &db); + let test_crate_ids = collect_main_crate_ids(&unit, &db, false); - if unit.main_package_id.name.to_string() != "dojo" { - let core_crate_ids = collect_core_crate_ids(&db); - main_crate_ids.extend(core_crate_ids); - } + let mut main_crate_ids = collect_all_crate_ids(&unit, &db); if let Some(external_contracts) = props.build_external_contracts { - main_crate_ids.extend(collect_external_crate_ids(&db, external_contracts)); + main_crate_ids.extend(collect_crates_ids_from_selectors(&db, &external_contracts)); } let config = TestRunConfig { @@ -179,8 +166,17 @@ impl TestArgs { print_resource_usage: self.print_resource_usage, }; - let compiler = - TestCompiler { db: db.snapshot(), main_crate_ids, test_crate_ids, starknet: true }; + let compiler = TestCompiler { + db: db.snapshot(), + main_crate_ids, + test_crate_ids, + allow_warnings: true, + config: TestsCompilationConfig { + starknet: true, + add_statements_functions: false, + add_statements_code_locations: false, + }, + }; let compiled = compiler.build()?; let runner = CompiledTestRunner { compiled, config }; @@ -214,7 +210,12 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { .filter(|c| !c.package.id.is_core()) // NOTE: We're taking the first target of each compilation unit, which should always be the // main package source root due to the order maintained by scarb. - .map(|c| (c.cairo_package_name(), c.targets[0].source_root().into())) + .map(|c| { + ( + c.cairo_package_name(), + c.first_target().source_root().into(), + ) + }) .collect(); let corelib = @@ -227,43 +228,75 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { let project_config = ProjectConfig { base_path: unit.main_component().package.root().into(), corelib, content }; - trace!(target: LOG_TARGET, ?project_config); + trace!(?project_config, "Project config built."); Ok(project_config) } -#[cfg(test)] -mod tests { - use dojo_test_utils::compiler::CompilerTestSetup; - use scarb::compiler::Profile; - - use super::*; - - // Ignored as scarb takes too much time to compile in debug mode. - // It's anyway run in the CI in the `test` job. - #[test] - #[ignore] - fn test_spawn_and_move_test() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let test_args = TestArgs { - filter: String::new(), - include_ignored: false, - ignored: false, - profiler_mode: ProfilerMode::None, - gas_enabled: true, - print_resource_usage: false, - features: FeaturesSpec { - features: vec![], - all_features: true, - no_default_features: false, - }, - packages: None, - }; - - let result = test_args.run(&config); - assert!(result.is_ok()); +/// Collects the main crate ids for Dojo including the core crates. +pub fn collect_main_crate_ids( + unit: &CairoCompilationUnit, + db: &RootDatabase, + with_dojo_core: bool, +) -> Vec { + let mut main_crate_ids = scarb::compiler::helpers::collect_main_crate_ids(unit, db); + + if unit.main_package_id.name.to_string() != "dojo" && with_dojo_core { + let core_crate_ids: Vec = collect_crates_ids_from_selectors( + db, + &[ContractSelector(WORLD_QUALIFIED_PATH.to_string())], + ); + + main_crate_ids.extend(core_crate_ids); } + + main_crate_ids +} + +/// Collects the crate ids containing the given contract selectors. +pub fn collect_crates_ids_from_selectors( + db: &RootDatabase, + contract_selectors: &[ContractSelector], +) -> Vec { + contract_selectors + .iter() + .map(|selector| selector.package().into()) + .unique() + .map(|package_name: SmolStr| db.intern_crate(CrateLongId::Real(package_name))) + .collect::>() +} + +pub fn collect_all_crate_ids(unit: &CairoCompilationUnit, db: &RootDatabase) -> Vec { + unit.components + .iter() + .map(|component| db.intern_crate(CrateLongId::Real(component.cairo_package_name()))) + .collect() +} + +pub fn crates_config_for_compilation_unit(unit: &CairoCompilationUnit) -> AllCratesConfig { + let crates_config: OrderedHashMap = unit + .components() + .iter() + .map(|component| { + // Ensure experimental features are only enable if required. + let experimental_features = component.package.manifest.experimental_features.clone(); + let experimental_features = experimental_features.unwrap_or_default(); + + ( + component.cairo_package_name(), + CrateSettings { + version: Some(component.package.id.version.clone()), + edition: component.package.manifest.edition, + experimental_features: ExperimentalFeaturesConfig { + negative_impls: experimental_features + .contains(&SmolStr::new_inline("negative_impls")), + coupons: experimental_features.contains(&SmolStr::new_inline("coupons")), + }, + cfg_set: component.cfg_set.clone(), + }, + ) + }) + .collect(); + + AllCratesConfig { override_map: crates_config, ..Default::default() } } diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 9fcddf4c7f..f2855135a4 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -1,18 +1,17 @@ +// #![cfg_attr(not(test), warn(unused_crate_dependencies))] + use std::env; use std::process::exit; use anyhow::Result; use args::SozoArgs; use clap::Parser; -use dojo_lang::compiler::DojoCompiler; -use dojo_lang::plugin::CairoPluginRepository; +use scarb::compiler::plugin::CairoPluginRepository; use scarb::compiler::CompilerRepository; use scarb::core::Config; use scarb_ui::{OutputFormat, Ui}; use tracing::trace; -use crate::commands::Commands; - mod args; mod commands; mod utils; @@ -29,22 +28,8 @@ fn main() { } fn cli_main(args: SozoArgs) -> Result<()> { - let mut compilers = CompilerRepository::std(); - let cairo_plugins = CairoPluginRepository::default(); - - match &args.command { - Commands::Build(args) => { - trace!("Adding DojoCompiler to compiler repository."); - compilers.add(Box::new(DojoCompiler::new(args.output_debug_info))).unwrap() - } - - Commands::Dev(_) | Commands::Migrate(_) => { - trace!("Adding DojoCompiler to compiler repository."); - compilers.add(Box::new(DojoCompiler::default())).unwrap() - } - - _ => {} - } + let compilers = CompilerRepository::std(); + let cairo_plugins = CairoPluginRepository::std(); let manifest_path = scarb::ops::find_manifest_path(args.manifest_path.as_deref())?; @@ -54,7 +39,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { .log_filter_directive(env::var_os("SCARB_LOG")) .profile(args.profile_spec.determine()?) .offline(args.offline) - .cairo_plugins(cairo_plugins.into()) + .cairo_plugins(cairo_plugins) .ui_verbosity(args.ui_verbosity()) .compilers(compilers) .build()?; diff --git a/bin/sozo/src/utils.rs b/bin/sozo/src/utils.rs index 662076e4df..254cc80dba 100644 --- a/bin/sozo/src/utils.rs +++ b/bin/sozo/src/utils.rs @@ -1,98 +1,55 @@ use std::str::FromStr; -use anyhow::{Error, Result}; +use anyhow::{anyhow, Context, Result}; use camino::Utf8PathBuf; -use dojo_world::config::Environment; -use dojo_world::contracts::world::WorldContract; -use dojo_world::contracts::WorldContractReader; -use dojo_world::metadata::dojo_metadata_from_workspace; -use scarb::core::{Config, TomlManifest}; +use colored::*; +use dojo_world::config::ProfileConfig; +use dojo_world::diff::WorldDiff; +use dojo_world::local::WorldLocal; +use katana_rpc_api::starknet::RPC_SPEC_VERSION; +use scarb::core::{TomlManifest, Workspace}; use semver::Version; +use sozo_scarbext::WorkspaceExt; +use starknet::accounts::{Account, ConnectedAccount}; +use starknet::core::types::Felt; +use starknet::core::utils as snutils; use starknet::providers::jsonrpc::HttpTransport; -use starknet::providers::JsonRpcClient; +use starknet::providers::{JsonRpcClient, Provider}; +use tracing::trace; -use crate::commands::options::account::{AccountOptions, SozoAccount, WorldAddressOrName}; +use crate::commands::options::account::{AccountOptions, SozoAccount}; use crate::commands::options::starknet::StarknetOptions; use crate::commands::options::world::WorldOptions; -/// Load metadata from the Scarb configuration. -/// -/// # Arguments -/// -/// * `config` - Scarb project configuration. -/// -/// # Returns -/// -/// A [`Environment`] on success. -pub fn load_metadata_from_config(config: &Config) -> Result, Error> { - let env_metadata = if config.manifest_path().exists() { - let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - let dojo_metadata = dojo_metadata_from_workspace(&ws)?; - - dojo_metadata.env().cloned() +/// Computes the world address based on the provided options. +pub fn get_world_address( + profile_config: &ProfileConfig, + world: &WorldOptions, + world_local: &WorldLocal, +) -> Result { + let env = profile_config.env.as_ref(); + + let deterministic_world_address = world_local.deterministic_world_address()?; + + if let Some(wa) = world.address(env)? { + if wa != deterministic_world_address { + println!( + "{}", + format!( + "The world address computed from the seed is different from the address \ + provided in config:\n\ndeterministic address: {:#x}\nconfig address: \ + {:#x}\n\nThe address in the config file is preferred, consider commenting it \ + out if you attempt to migrate the world with a new seed.", + deterministic_world_address, wa + ) + .yellow() + ); + } + + Ok(wa) } else { - None - }; - - Ok(env_metadata) -} - -/// Build a world contract from the provided environment. -/// -/// # Arguments -/// -/// * `world` - The world options such as the world address, -/// * `account` - The account options, -/// * `starknet` - The Starknet options such as the RPC url, -/// * `env_metadata` - Optional environment coming from Scarb configuration. -/// -/// # Returns -/// -/// A [`WorldContract`] on success. -pub async fn world_from_env_metadata( - world: WorldOptions, - account: AccountOptions, - starknet: &StarknetOptions, - env_metadata: &Option, - config: &Config, -) -> Result>>, Error> { - let env_metadata = env_metadata.as_ref(); - - let world_address = world.address(env_metadata)?; - let provider = starknet.provider(env_metadata)?; - let account = account - .account( - provider, - WorldAddressOrName::Address(world_address), - starknet, - env_metadata, - config, - ) - .await?; - - Ok(WorldContract::new(world_address, account)) -} - -/// Build a world contract reader from the provided environment. -/// -/// # Arguments -/// -/// * `world` - The world options such as the world address, -/// * `starknet` - The Starknet options such as the RPC url, -/// * `env_metadata` - Optional environment coming from Scarb configuration. -/// -/// # Returns -/// -/// A [`WorldContractReader`] on success. -pub async fn world_reader_from_env_metadata( - world: WorldOptions, - starknet: StarknetOptions, - env_metadata: &Option, -) -> Result>, Error> { - let world_address = world.address(env_metadata.as_ref())?; - let provider = starknet.provider(env_metadata.as_ref())?; - - Ok(WorldContractReader::new(world_address, provider)) + Ok(deterministic_world_address) + } } pub fn verify_cairo_version_compatibility(manifest_path: &Utf8PathBuf) -> Result<()> { @@ -111,7 +68,11 @@ pub fn verify_cairo_version_compatibility(manifest_path: &Utf8PathBuf) -> Result let version = Version::from_str(scarb_cairo_version.version).unwrap(); if !version_req.matches(&version) { anyhow::bail!( - "Specified cairo version not supported by dojo. Please verify and update dojo." + "Cairo version {} found in {} is not supported by dojo (expecting {}). Please change \ + the Cairo version in your manifest or update dojo.", + version_req, + manifest_path, + version, ); }; @@ -134,3 +95,139 @@ pub fn generate_version() -> String { pub fn is_address(tag_or_address: &str) -> bool { tag_or_address.starts_with("0x") } + +/// Sets up the world diff from the environment and returns associated starknet account. +/// +/// Returns the world address, the world diff, the starknet provider and the rpc url. +pub async fn get_world_diff_and_provider( + starknet: StarknetOptions, + world: WorldOptions, + ws: &Workspace<'_>, +) -> Result<(WorldDiff, JsonRpcClient, String)> { + let world_local = ws.load_world_local()?; + let profile_config = ws.load_profile_config()?; + + let env = profile_config.env.as_ref(); + + let world_address = get_world_address(&profile_config, &world, &world_local)?; + + let (provider, rpc_url) = starknet.provider(env)?; + trace!(?provider, "Provider initialized."); + + let spec_version = provider.spec_version().await?; + trace!(spec_version); + + if !is_compatible_version(&spec_version, RPC_SPEC_VERSION)? { + return Err(anyhow!( + "Unsupported Starknet RPC version: {}, expected {}.", + spec_version, + RPC_SPEC_VERSION + )); + } + + let chain_id = provider.chain_id().await?; + let chain_id = snutils::parse_cairo_short_string(&chain_id) + .with_context(|| "Cannot parse chain_id as string")?; + trace!(chain_id); + + let world_diff = WorldDiff::new_from_chain(world_address, world_local, &provider).await?; + + Ok((world_diff, provider, rpc_url)) +} + +/// Sets up the world diff from the environment and returns associated starknet account. +/// +/// Returns the world address, the world diff, the account and the rpc url. +/// This would be convenient to have the rpc url retrievable from the [`Provider`] trait. +pub async fn get_world_diff_and_account( + account: AccountOptions, + starknet: StarknetOptions, + world: WorldOptions, + ws: &Workspace<'_>, +) -> Result<(WorldDiff, SozoAccount>, String)> { + let profile_config = ws.load_profile_config()?; + let env = profile_config.env.as_ref(); + + let (world_diff, provider, rpc_url) = + get_world_diff_and_provider(starknet.clone(), world, ws).await?; + + let account = { + account + .account(provider, world_diff.world_info.address, &starknet, env, &world_diff) + .await? + }; + + if !dojo_utils::is_deployed(account.address(), &account.provider()).await? { + return Err(anyhow!("Account with address {:#x} doesn't exist.", account.address())); + } + + Ok((world_diff, account, rpc_url)) +} + +/// Checks if the provided version string is compatible with the expected version string using +/// semantic versioning rules. Includes specific backward compatibility rules, e.g., version 0.6 is +/// compatible with 0.7. +/// +/// # Arguments +/// +/// * `provided_version` - The version string provided by the user. +/// * `expected_version` - The expected version string. +/// +/// # Returns +/// +/// * `Result` - Returns `true` if the provided version is compatible with the expected +/// version, `false` otherwise. +fn is_compatible_version(provided_version: &str, expected_version: &str) -> Result { + use semver::{Version, VersionReq}; + + let provided_ver = Version::parse(provided_version) + .map_err(|e| anyhow!("Failed to parse provided version '{}': {}", provided_version, e))?; + let expected_ver = Version::parse(expected_version) + .map_err(|e| anyhow!("Failed to parse expected version '{}': {}", expected_version, e))?; + + // Specific backward compatibility rule: 0.6 is compatible with 0.7. + if (provided_ver.major == 0 && provided_ver.minor == 7) + && (expected_ver.major == 0 && expected_ver.minor == 6) + { + return Ok(true); + } + + let expected_ver_req = VersionReq::parse(expected_version).map_err(|e| { + anyhow!("Failed to parse expected version requirement '{}': {}", expected_version, e) + })?; + + Ok(expected_ver_req.matches(&provided_ver)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_is_compatible_version_major_mismatch() { + assert!(!is_compatible_version("1.0.0", "2.0.0").unwrap()); + } + + #[test] + fn test_is_compatible_version_minor_compatible() { + assert!(is_compatible_version("1.2.0", "1.1.0").unwrap()); + } + + #[test] + fn test_is_compatible_version_minor_mismatch() { + assert!(!is_compatible_version("0.2.0", "0.7.0").unwrap()); + } + + #[test] + fn test_is_compatible_version_specific_backward_compatibility() { + let node_version = "0.7.1"; + let katana_version = "0.6.0"; + assert!(is_compatible_version(node_version, katana_version).unwrap()); + } + + #[test] + fn test_is_compatible_version_invalid_version_string() { + assert!(is_compatible_version("1.0", "1.0.0").is_err()); + assert!(is_compatible_version("1.0.0", "1.0").is_err()); + } +} diff --git a/bin/sozo/tests/mod.rs b/bin/sozo/tests/mod.rs new file mode 100644 index 0000000000..25de1b695b --- /dev/null +++ b/bin/sozo/tests/mod.rs @@ -0,0 +1,2 @@ +//! For testing sozo, let's use code call instead of snapbox. +//! This will help having more coverage and better testing to now rely on output. diff --git a/bin/sozo/tests/register_test.rs b/bin/sozo/tests/register_test.rs deleted file mode 100644 index 5b5e490571..0000000000 --- a/bin/sozo/tests/register_test.rs +++ /dev/null @@ -1,64 +0,0 @@ -mod utils; - -use camino::Utf8PathBuf; -use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::{copy_spawn_and_move_db, prepare_migration_with_world_and_seed}; -use katana_runner::RunnerCtx; -use scarb::compiler::Profile; -use scarb::ops; -use starknet::accounts::Account; -use starknet::core::types::{BlockId, BlockTag}; -use utils::snapbox::get_snapbox; - -#[tokio::test(flavor = "multi_thread")] -#[katana_runner::test(db_dir = copy_spawn_and_move_db().as_str())] -async fn reregister_models(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_path = - ws.target_dir().path_existent().unwrap().join(ws.config().profile().to_string()); - - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_path, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); - - let mut account = sequencer.account(0); - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let world_address = &format!("0x{:x}", &strat.world_address); - let account_address = &format!("0x{:x}", account.address()); - let private_key = - &format!("0x{:x}", sequencer.account_data(0).private_key.as_ref().unwrap().secret_scalar()); - let rpc_url = &sequencer.url().to_string(); - - let moves_model = strat.models.iter().find(|m| m.diff.tag == "dojo_examples-Moves").unwrap(); - let moves_model_class_hash = &format!("0x{:x}", moves_model.diff.local_class_hash); - let args_vec = [ - "register", - "model", - moves_model_class_hash, - "--world", - world_address, - "--account-address", - account_address, - "--rpc-url", - rpc_url, - "--private-key", - private_key, - "--manifest-path", - config.manifest_path().as_ref(), - ]; - - let assert = get_snapbox().args(args_vec.iter()).assert().success(); - assert!(format!("{:?}", assert.get_output()).contains("No new models to register")); -} diff --git a/bin/sozo/tests/test_account.rs b/bin/sozo/tests/test_account.rs deleted file mode 100644 index 1ed467e9b6..0000000000 --- a/bin/sozo/tests/test_account.rs +++ /dev/null @@ -1,48 +0,0 @@ -mod utils; - -use std::fs; - -use assert_fs::fixture::PathChild; -use katana_runner::RunnerCtx; -use sozo_ops::account; -use starknet::accounts::Account; -use utils::snapbox::get_snapbox; - -#[test] -fn test_account_new() { - let pt = assert_fs::TempDir::new().unwrap(); - let dst_path = pt.child("keystore.json"); - let src_path = fs::canonicalize("./tests/test_data/keystore/keystore.json").unwrap(); - fs::copy(src_path, dst_path).unwrap(); - - get_snapbox() - .arg("account") - .arg("new") - .arg("account.json") - .arg("--keystore") - .arg("keystore.json") - .arg("--password") - .arg("password") - .current_dir(&pt) - .assert() - .success(); - - assert!(pt.child("account.json").exists()); -} - -#[tokio::test] -#[katana_runner::test(accounts = 2, fee = false)] -async fn test_account_fetch(runner: &RunnerCtx) { - let pt = assert_fs::TempDir::new().unwrap(); - - account::fetch( - runner.owned_provider(), - false, - pt.child("account.json").to_path_buf(), - runner.account(1).address(), - ) - .await - .unwrap(); - - assert!(pt.child("account.json").exists()); -} diff --git a/bin/sozo/tests/test_build.rs b/bin/sozo/tests/test_build.rs deleted file mode 100644 index 722d231036..0000000000 --- a/bin/sozo/tests/test_build.rs +++ /dev/null @@ -1,14 +0,0 @@ -mod utils; - -use std::fs; - -use utils::snapbox::get_snapbox; - -#[test] -fn test_invalid_cairo_version() { - let path = fs::canonicalize("./tests/test_data/invalid_cairo_version"); - let assert = get_snapbox().arg("build").current_dir(path.unwrap()).assert().failure(); - assert.stdout_matches( - "[..]Specified cairo version not supported by dojo. Please verify and update dojo[..]", - ); -} diff --git a/bin/sozo/tests/test_data/policies.json b/bin/sozo/tests/test_data/policies.json index 72785ac8f3..86f69297ee 100644 --- a/bin/sozo/tests/test_data/policies.json +++ b/bin/sozo/tests/test_data/policies.json @@ -1,132 +1,120 @@ [ { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "spawn" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "move" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "set_player_config" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", - "method": "update_player_name" - }, - { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", - "method": "update_player_items" - }, - { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "reset_player_config" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "set_player_server_profile" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "set_models" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "enter_dungeon" }, { - "target": "0x2d24481107b55ecd73c4d1b62f6bfe8c42a224447b71db7dcec2eab484d53cd", + "target": "0x7bc340927668bc87eea10d95cb2dfe0fa10be12075fe8189f363643205c34d4", "method": "upgrade" }, { - "target": "0x454e4731e29aad869794ce03040f1bd866556132b0e633a376918ee17801f5e", + "target": "0x79e0653fbebdbdb864ca69d1470b263f2efdfce9cf355cfe9c7719627eff792", "method": "upgrade" }, { - "target": "0x57d20e85621372042af6b626884361c1c64c701b0b7db985d10faf92aa0dedc", + "target": "0x2e7d504b81c2f1b60986c95de64b650feb8ae625f04c6cd924150fab3cad4a8", "method": "upgrade" }, { - "target": "0x52da0b3df1cb3f0627dbe75960ae5ebad647b6ade1930dc9a499c0475168754", + "target": "0x41ceb76687e3653610fffc3c830607d90079e9c5d96cfb6f270c8231e9ee9db", "method": "upgrade" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "uuid" + }, + { + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "set_metadata" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "register_namespace" + }, + { + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "register_event" + }, + { + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "register_model" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "upgrade_model" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "register_contract" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "register_namespace" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "init_contract" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "deploy_contract" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "upgrade_event" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "upgrade_contract" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "upgrade_model" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "init_contract" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "upgrade_contract" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "uuid" + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "method": "emit_event" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "set_entity" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "delete_entity" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "grant_owner" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "revoke_owner" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "grant_writer" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "revoke_writer" }, { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", + "target": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", "method": "upgrade" }, - { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "upgrade_state" - }, - { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "set_differ_program_hash" - }, - { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "set_merger_program_hash" - }, - { - "target": "0x74c73d35df54ddc53bcf34aab5e0dbb09c447e99e01f4d69535441253c9571a", - "method": "set_facts_registry" - }, { "target": "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba", "method": "__declare_transaction__" diff --git a/bin/sozo/tests/test_init.rs b/bin/sozo/tests/test_init.rs deleted file mode 100644 index e58f728e7e..0000000000 --- a/bin/sozo/tests/test_init.rs +++ /dev/null @@ -1,19 +0,0 @@ -mod utils; - -use utils::snapbox::get_snapbox; -use utils::stdout::expected_stdout; - -#[test] -fn test_init() { - let pt = assert_fs::TempDir::new().unwrap(); - - let assert = get_snapbox().arg("init").current_dir(&pt).assert().success(); - - let output = format!("{:#?}", assert.get_output()); - - if output.contains("Couldn't find template for your current sozo version.") { - assert.stdout_eq(expected_stdout("init_default")); - } else { - assert.stdout_eq(expected_stdout("init")); - } -} diff --git a/bin/sozo/tests/test_keystore.rs b/bin/sozo/tests/test_keystore.rs deleted file mode 100644 index 3da687d9d4..0000000000 --- a/bin/sozo/tests/test_keystore.rs +++ /dev/null @@ -1,129 +0,0 @@ -mod utils; - -use std::fs; - -use assert_fs::fixture::{FileTouch, PathChild}; -use utils::snapbox::get_snapbox; - -#[test] -fn test_keystore_new() { - let pt = assert_fs::TempDir::new().unwrap(); - - get_snapbox() - .arg("keystore") - .arg("new") - .arg("keystore.json") - .arg("--password") - .arg("password") - .current_dir(&pt) - .assert() - .success(); - - assert!(pt.child("keystore.json").exists()); -} - -#[test] -fn test_keystore_new_force() { - let pt = assert_fs::TempDir::new().unwrap(); - - pt.child("keystore.json").touch().unwrap(); - - get_snapbox() - .arg("keystore") - .arg("new") - .arg("--password") - .arg("password") - .arg("keystore.json") - .arg("--force") - .current_dir(&pt) - .assert() - .success(); - - assert!(pt.child("keystore.json").exists()); - - let contents = fs::read_to_string(pt.child("keystore.json")).unwrap(); - assert!(!contents.is_empty()); -} - -#[test] -fn test_keystore_from_key() { - let pt = assert_fs::TempDir::new().unwrap(); - - get_snapbox() - .arg("keystore") - .arg("from-key") - .arg("keystore.json") - .arg("--password") - .arg("password") - .arg("--private-key") - .arg("0x123") - .current_dir(&pt) - .assert() - .success(); - - assert!(pt.child("keystore.json").exists()); -} - -#[test] -fn test_keystore_inspect() { - let path = fs::canonicalize("./tests/test_data/keystore").unwrap(); - - let assert = get_snapbox() - .arg("keystore") - .arg("inspect") - .arg("keystore.json") - .arg("--password") - .arg("password") - .current_dir(path) - .assert() - .success(); - - let output = String::from_utf8(assert.get_output().stdout.clone()).unwrap(); - - assert_eq!( - output.trim(), - "Public key: 0x0566d69d8c99f62bc71118399bab25c1f03719463eab8d6a444cd11ece131616" - ) -} - -#[test] -fn test_keystore_inspect_raw() { - let path = fs::canonicalize("./tests/test_data/keystore").unwrap(); - - let assert = get_snapbox() - .arg("keystore") - .arg("inspect") - .arg("keystore.json") - .arg("--password") - .arg("password") - .arg("--raw") - .current_dir(path) - .assert() - .success(); - - let output = String::from_utf8(assert.get_output().stdout.clone()).unwrap(); - - assert_eq!(output.trim(), "0x0566d69d8c99f62bc71118399bab25c1f03719463eab8d6a444cd11ece131616") -} - -#[test] -fn test_keystore_inspect_private() { - let path = fs::canonicalize("./tests/test_data/keystore").unwrap(); - - let assert = get_snapbox() - .arg("keystore") - .arg("inspect-private") - .arg("keystore.json") - .arg("--password") - .arg("password") - .current_dir(path) - .assert() - .success(); - - let output = String::from_utf8(assert.get_output().stdout.clone()).unwrap(); - - assert_eq!( - output.trim(), - "Private key: 0x0000000000000000000000000000000000000000000000000000000000000123" - ) -} diff --git a/bin/sozo/tests/test_migrate.rs b/bin/sozo/tests/test_migrate.rs deleted file mode 100644 index ca55c20dc6..0000000000 --- a/bin/sozo/tests/test_migrate.rs +++ /dev/null @@ -1,88 +0,0 @@ -use std::fs; - -use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::copy_spawn_and_move_db; -use katana_runner::{KatanaRunner, RunnerCtx}; -use scarb::compiler::Profile; -use starknet::accounts::Account; -use starknet::core::types::{BlockId, BlockTag}; -use utils::snapbox::get_snapbox; - -mod utils; - -#[tokio::test(flavor = "multi_thread")] -async fn migrate_dry_run() { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - - let sequencer = KatanaRunner::new().expect("Failed to start runner."); - - let mut account = sequencer.account(0); - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let account_address = &format!("0x{:x}", account.address()); - let private_key = - &format!("0x{:x}", sequencer.account_data(0).private_key.as_ref().unwrap().secret_scalar()); - let rpc_url = &sequencer.url().to_string(); - - let args_vec = [ - "migrate", - "plan", - "--account-address", - account_address, - "--rpc-url", - rpc_url, - "--private-key", - private_key, - "--manifest-path", - config.manifest_path().as_ref(), - ]; - - let assert = get_snapbox().args(args_vec.iter()).assert().success(); - let output = format!("{:#?}", assert.get_output()); - - dbg!("{}", &output); - - assert!(output.contains("Migration Strategy")); - assert!(output.contains("# Base Contract")); - assert!(output.contains("# Models (10)")); - assert!(output.contains("# World")); - assert!(output.contains("# Contracts (4)")); -} - -#[tokio::test(flavor = "multi_thread")] -#[katana_runner::test(db_dir = copy_spawn_and_move_db().as_str())] -async fn test_migrate_then_upgrade(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - let tmp_dir = config.manifest_path().parent().unwrap(); - - let mut account = sequencer.account(0); - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let rpc_url = &sequencer.url().to_string(); - - // Modify the actions contracts to have a new class hash. - let actions_path = tmp_dir.join("src/actions.cairo"); - let mut actions_content = fs::read_to_string(&actions_path).unwrap(); - actions_content = actions_content.replace("quantity: 100", "quantity: 200"); - fs::write(&actions_path, actions_content).unwrap(); - - let build_vec = ["build", "--manifest-path", config.manifest_path().as_ref()]; - - get_snapbox().args(build_vec.iter()).assert().success(); - - let plan_args = [ - "migrate", - "plan", - "--rpc-url", - rpc_url, - "--manifest-path", - config.manifest_path().as_ref(), - ]; - - let plan_assert = get_snapbox().args(plan_args.iter()).assert().success(); - let plan_output = format!("{:#?}", plan_assert.get_output()); - - assert!(plan_output.contains("Contracts (1)")); -} diff --git a/crates/dojo-core/.gitignore b/crates/dojo-core/.gitignore deleted file mode 100644 index 1de565933b..0000000000 --- a/crates/dojo-core/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target \ No newline at end of file diff --git a/crates/dojo-core/Scarb.toml b/crates/dojo-core/Scarb.toml deleted file mode 100644 index d0e0718a42..0000000000 --- a/crates/dojo-core/Scarb.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -cairo-version = "2.7.0" -edition = "2024_07" -description = "The Dojo Core library for autonomous worlds." -name = "dojo" -version = "1.0.0-alpha.4" - -[dependencies] -starknet = "=2.7.0" - -[lib] diff --git a/crates/dojo-core/src/contract/base_contract.cairo b/crates/dojo-core/src/contract/base_contract.cairo deleted file mode 100644 index d00a69a224..0000000000 --- a/crates/dojo-core/src/contract/base_contract.cairo +++ /dev/null @@ -1,39 +0,0 @@ -#[starknet::contract] -pub mod base { - use starknet::{ClassHash, ContractAddress, get_caller_address}; - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - - use dojo::contract::upgradeable::upgradeable as upgradeable_component; - use dojo::world::{IWorldProvider, IWorldDispatcher, IWorldDispatcherTrait}; - - component!(path: upgradeable_component, storage: upgradeable, event: UpgradeableEvent); - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - UpgradeableEvent: upgradeable_component::Event - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: upgradeable_component::Storage, - } - - #[constructor] - fn constructor(ref self: ContractState) { - self.world_dispatcher.write(IWorldDispatcher { contract_address: get_caller_address() }); - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = upgradeable_component::UpgradableImpl; -} diff --git a/crates/dojo-core/src/contract/contract.cairo b/crates/dojo-core/src/contract/contract.cairo deleted file mode 100644 index 462d02d54b..0000000000 --- a/crates/dojo-core/src/contract/contract.cairo +++ /dev/null @@ -1,9 +0,0 @@ -#[starknet::interface] -pub trait IContract { - fn name(self: @T) -> ByteArray; - fn namespace(self: @T) -> ByteArray; - fn tag(self: @T) -> ByteArray; - fn name_hash(self: @T) -> felt252; - fn namespace_hash(self: @T) -> felt252; - fn selector(self: @T) -> felt252; -} diff --git a/crates/dojo-core/src/lib.cairo b/crates/dojo-core/src/lib.cairo deleted file mode 100644 index ed6b9ac046..0000000000 --- a/crates/dojo-core/src/lib.cairo +++ /dev/null @@ -1,94 +0,0 @@ -pub mod contract { - mod base_contract; - pub use base_contract::base; - pub mod contract; - pub use contract::{IContract, IContractDispatcher, IContractDispatcherTrait}; - pub mod upgradeable; -} - -pub mod model { - pub mod introspect; - pub mod layout; - pub use layout::{Layout, FieldLayout}; - - pub mod model; - pub use model::{ - Model, ModelIndex, ModelEntity, IModel, IModelDispatcher, IModelDispatcherTrait, - deploy_and_get_metadata - }; - - #[cfg(target: "test")] - pub use model::{ModelTest, ModelEntityTest}; - - pub mod metadata; - pub use metadata::{ResourceMetadata, ResourceMetadataTrait, resource_metadata}; - pub(crate) use metadata::{initial_address, initial_class_hash}; -} - -pub(crate) mod storage { - pub(crate) mod database; - pub(crate) mod packing; - pub(crate) mod layout; - pub(crate) mod storage; -} - -pub mod utils { - // Since Scarb 2.6.0 there's an optimization that does not - // build tests for dependencies and it's not configurable. - // - // To expose correctly the test utils for a package using dojo-core, - // we need to it in the `lib` target or using the `#[cfg(target: "test")]` - // attribute. - // - // Since `test_utils` is using `TEST_CLASS_HASH` to factorize some deployment - // core, we place it under the test target manually. - #[cfg(target: "test")] - pub mod test; - - pub mod utils; - pub use utils::{ - bytearray_hash, entity_id_from_keys, find_field_layout, find_model_field_layout, any_none, - sum, combine_key, selector_from_names - }; -} - -pub mod world { - pub(crate) mod update; - pub(crate) mod config; - pub(crate) mod errors; - - mod world_contract; - pub use world_contract::{ - world, IWorld, IWorldDispatcher, IWorldDispatcherTrait, IWorldProvider, - IWorldProviderDispatcher, IWorldProviderDispatcherTrait, Resource, - }; - pub(crate) use world_contract::{ - IUpgradeableWorld, IUpgradeableWorldDispatcher, IUpgradeableWorldDispatcherTrait - }; - - #[cfg(target: "test")] - pub use world_contract::{IWorldTest, IWorldTestDispatcher, IWorldTestDispatcherTrait}; -} - -#[cfg(test)] -mod tests { - mod model { - mod introspect; - mod model; - } - mod storage { - mod database; - mod packing; - mod storage; - } - mod base; - mod benchmarks; - mod helpers; - mod world { - mod acl; - mod entities; - mod resources; - mod world; - } - mod utils; -} diff --git a/crates/dojo-core/src/model/metadata.cairo b/crates/dojo-core/src/model/metadata.cairo deleted file mode 100644 index 7a8e18080c..0000000000 --- a/crates/dojo-core/src/model/metadata.cairo +++ /dev/null @@ -1,246 +0,0 @@ -//! ResourceMetadata model. -//! -//! Manually expand to ensure that dojo-core -//! does not depend on dojo plugin to be built. -//! -use core::array::ArrayTrait; -use core::byte_array::ByteArray; -use core::poseidon::poseidon_hash_span; -use core::serde::Serde; - -use dojo::model::introspect::{Introspect, Ty, Struct, Member}; -use dojo::model::{Model, ModelIndex, Layout, FieldLayout}; -use dojo::utils; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; - -pub fn initial_address() -> starknet::ContractAddress { - starknet::contract_address_const::<0>() -} - -pub fn initial_class_hash() -> starknet::ClassHash { - starknet::class_hash::class_hash_const::< - 0x03f75587469e8101729b3b02a46150a3d99315bc9c5026d64f2e8a061e413255 - >() -} - -#[derive(Drop, Serde, PartialEq, Clone, Debug)] -pub struct ResourceMetadata { - // #[key] - pub resource_id: felt252, - pub metadata_uri: ByteArray, -} - -#[generate_trait] -pub impl ResourceMetadataImpl of ResourceMetadataTrait { - fn from_values(resource_id: felt252, ref values: Span) -> ResourceMetadata { - let metadata_uri = Serde::::deserialize(ref values); - if metadata_uri.is_none() { - panic!("Model `ResourceMetadata`: metadata_uri deserialization failed."); - } - - ResourceMetadata { resource_id, metadata_uri: metadata_uri.unwrap() } - } -} - -pub impl ResourceMetadataModel of Model { - fn get(world: IWorldDispatcher, keys: Span) -> ResourceMetadata { - if keys.len() != 1 { - panic!("Model `ResourceMetadata`: bad keys length."); - }; - - let mut values = world.entity(Self::selector(), ModelIndex::Keys(keys), Self::layout()); - ResourceMetadataTrait::from_values(*keys.at(0), ref values) - } - - fn set_model(self: @ResourceMetadata, world: IWorldDispatcher,) { - IWorldDispatcherTrait::set_entity( - world, Self::selector(), ModelIndex::Keys(self.keys()), self.values(), Self::layout() - ); - } - - fn delete_model(self: @ResourceMetadata, world: IWorldDispatcher,) { - world.delete_entity(Self::selector(), ModelIndex::Keys(self.keys()), Self::layout()); - } - - fn get_member( - world: IWorldDispatcher, keys: Span, member_id: felt252 - ) -> Span { - match utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = utils::entity_id_from_keys(keys); - world - .entity( - Self::selector(), ModelIndex::MemberId((entity_id, member_id)), field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ResourceMetadata, world: IWorldDispatcher, member_id: felt252, values: Span - ) { - match utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - world - .set_entity( - Self::selector(), - ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ResourceMetadata" - } - - fn namespace() -> ByteArray { - "__DOJO__" - } - - fn tag() -> ByteArray { - "__DOJO__-ResourceMetadata" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - poseidon_hash_span([Self::namespace_hash(), Self::name_hash()].span()) - } - - #[inline(always)] - fn instance_selector(self: @ResourceMetadata) -> felt252 { - Self::selector() - } - - fn name_hash() -> felt252 { - utils::bytearray_hash(@Self::name()) - } - - fn namespace_hash() -> felt252 { - utils::bytearray_hash(@Self::namespace()) - } - - #[inline(always)] - fn entity_id(self: @ResourceMetadata) -> felt252 { - poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ResourceMetadata) -> Span { - let mut serialized = ArrayTrait::new(); - ArrayTrait::append(ref serialized, *self.resource_id); - ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ResourceMetadata) -> Span { - let mut serialized = ArrayTrait::new(); - Serde::serialize(self.metadata_uri, ref serialized); - ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> Layout { - Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ResourceMetadata) -> Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - Option::None - } -} - -pub impl ResourceMetadataIntrospect<> of Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - #[inline(always)] - fn layout() -> Layout { - Layout::Struct( - [FieldLayout { selector: selector!("metadata_uri"), layout: Layout::ByteArray }].span() - ) - } - - #[inline(always)] - fn ty() -> Ty { - Ty::Struct( - Struct { - name: 'ResourceMetadata', attrs: [].span(), children: [ - Member { - name: 'resource_id', ty: Ty::Primitive('felt252'), attrs: ['key'].span() - }, - Member { name: 'metadata_uri', ty: Ty::ByteArray, attrs: [].span() } - ].span() - } - ) - } -} - -#[starknet::contract] -pub mod resource_metadata { - use super::ResourceMetadata; - use super::ResourceMetadataModel; - - use dojo::model::introspect::{Introspect, Ty}; - use dojo::model::Layout; - - #[storage] - struct Storage {} - - #[external(v0)] - fn selector(self: @ContractState) -> felt252 { - ResourceMetadataModel::selector() - } - - fn name(self: @ContractState) -> ByteArray { - ResourceMetadataModel::name() - } - - fn version(self: @ContractState) -> u8 { - ResourceMetadataModel::version() - } - - fn namespace(self: @ContractState) -> ByteArray { - ResourceMetadataModel::namespace() - } - - #[external(v0)] - fn unpacked_size(self: @ContractState) -> Option { - Introspect::::size() - } - - #[external(v0)] - fn packed_size(self: @ContractState) -> Option { - ResourceMetadataModel::packed_size() - } - - #[external(v0)] - fn layout(self: @ContractState) -> Layout { - ResourceMetadataModel::layout() - } - - #[external(v0)] - fn schema(self: @ContractState) -> Ty { - Introspect::::ty() - } - - #[external(v0)] - fn ensure_abi(self: @ContractState, model: ResourceMetadata) {} -} diff --git a/crates/dojo-core/src/model/model.cairo b/crates/dojo-core/src/model/model.cairo deleted file mode 100644 index 6b11143ca0..0000000000 --- a/crates/dojo-core/src/model/model.cairo +++ /dev/null @@ -1,123 +0,0 @@ -use starknet::SyscallResult; - -use dojo::model::Layout; -use dojo::model::introspect::Ty; -use dojo::world::IWorldDispatcher; - -#[derive(Copy, Drop, Serde, Debug, PartialEq)] -pub enum ModelIndex { - Keys: Span, - Id: felt252, - // (entity_id, member_id) - MemberId: (felt252, felt252) -} - -/// Trait that is implemented at Cairo level for each struct that is a model. -pub trait ModelEntity { - fn id(self: @T) -> felt252; - fn values(self: @T) -> Span; - fn from_values(entity_id: felt252, ref values: Span) -> T; - // Get is always used with the trait path, which results in no ambiguity for the compiler. - fn get(world: IWorldDispatcher, entity_id: felt252) -> T; - // Update and delete can be used directly on the entity, which results in ambiguity. - // Therefore, they are implemented with the `update_entity` and `delete_entity` names. - fn update_entity(self: @T, world: IWorldDispatcher); - fn delete_entity(self: @T, world: IWorldDispatcher); - fn get_member( - world: IWorldDispatcher, entity_id: felt252, member_id: felt252, - ) -> Span; - fn set_member(self: @T, world: IWorldDispatcher, member_id: felt252, values: Span); -} - -pub trait Model { - // Get is always used with the trait path, which results in no ambiguity for the compiler. - fn get(world: IWorldDispatcher, keys: Span) -> T; - // Note: `get` is implemented with a generated trait because it takes - // the list of model keys as separated parameters. - - // Set and delete can be used directly on the entity, which results in ambiguity. - // Therefore, they are implemented with the `set_model` and `delete_model` names. - fn set_model(self: @T, world: IWorldDispatcher); - fn delete_model(self: @T, world: IWorldDispatcher); - - fn get_member( - world: IWorldDispatcher, keys: Span, member_id: felt252, - ) -> Span; - - fn set_member(self: @T, world: IWorldDispatcher, member_id: felt252, values: Span,); - - /// Returns the name of the model as it was written in Cairo code. - fn name() -> ByteArray; - - /// Returns the namespace of the model as it was written in the `dojo::model` attribute. - fn namespace() -> ByteArray; - - // Returns the model tag which combines the namespace and the name. - fn tag() -> ByteArray; - - fn version() -> u8; - - /// Returns the model selector built from its name and its namespace. - /// model selector = hash(namespace_hash, model_hash) - fn selector() -> felt252; - fn instance_selector(self: @T) -> felt252; - - fn name_hash() -> felt252; - fn namespace_hash() -> felt252; - - fn entity_id(self: @T) -> felt252; - fn keys(self: @T) -> Span; - fn values(self: @T) -> Span; - fn layout() -> Layout; - fn instance_layout(self: @T) -> Layout; - fn packed_size() -> Option; -} - -#[starknet::interface] -pub trait IModel { - fn name(self: @T) -> ByteArray; - fn namespace(self: @T) -> ByteArray; - fn tag(self: @T) -> ByteArray; - fn version(self: @T) -> u8; - - fn selector(self: @T) -> felt252; - fn name_hash(self: @T) -> felt252; - fn namespace_hash(self: @T) -> felt252; - fn unpacked_size(self: @T) -> Option; - fn packed_size(self: @T) -> Option; - fn layout(self: @T) -> Layout; - fn schema(self: @T) -> Ty; -} - -/// Deploys a model with the given [`ClassHash`] and retrieves it's name. -/// Currently, the model is expected to already be declared by `sozo`. -/// -/// # Arguments -/// -/// * `salt` - A salt used to uniquely deploy the model. -/// * `class_hash` - Class Hash of the model. -pub fn deploy_and_get_metadata( - salt: felt252, class_hash: starknet::ClassHash -) -> SyscallResult<(starknet::ContractAddress, ByteArray, felt252, ByteArray, felt252)> { - let (contract_address, _) = starknet::syscalls::deploy_syscall( - class_hash, salt, [].span(), false, - )?; - let model = IModelDispatcher { contract_address }; - let name = model.name(); - let selector = model.selector(); - let namespace = model.namespace(); - let namespace_hash = model.namespace_hash(); - Result::Ok((contract_address, name, selector, namespace, namespace_hash)) -} - -#[cfg(target: "test")] -pub trait ModelTest { - fn set_test(self: @T, world: IWorldDispatcher); - fn delete_test(self: @T, world: IWorldDispatcher); -} - -#[cfg(target: "test")] -pub trait ModelEntityTest { - fn update_test(self: @T, world: IWorldDispatcher); - fn delete_test(self: @T, world: IWorldDispatcher); -} diff --git a/crates/dojo-core/src/tests/base.cairo b/crates/dojo-core/src/tests/base.cairo deleted file mode 100644 index 680691b4be..0000000000 --- a/crates/dojo-core/src/tests/base.cairo +++ /dev/null @@ -1,239 +0,0 @@ -use core::option::OptionTrait; -use core::traits::TryInto; - -use starknet::ClassHash; - -use dojo::contract::base; -use dojo::contract::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; -use dojo::utils::test::{spawn_test_world}; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; - - -#[starknet::contract] -pub mod contract_upgrade { - use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, IWorldProvider}; - - #[storage] - struct Storage {} - - #[starknet::interface] - pub trait IQuantumLeap { - fn plz_more_tps(self: @TState) -> felt252; - } - - #[constructor] - fn constructor(ref self: ContractState) {} - - #[abi(embed_v0)] - pub impl QuantumLeap of IQuantumLeap { - fn plz_more_tps(self: @ContractState) -> felt252 { - 'daddy' - } - } - - #[abi(embed_v0)] - pub impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - IWorldDispatcher { contract_address: starknet::contract_address_const::<'world'>() } - } - } -} - -#[starknet::contract] -pub mod contract_invalid_upgrade { - #[storage] - struct Storage {} -} - -use contract_upgrade::{IQuantumLeapDispatcher, IQuantumLeapDispatcherTrait}; - -// Utils -fn deploy_world() -> IWorldDispatcher { - spawn_test_world(["dojo"].span(), [].span()) -} - -// A test contract needs to be used instead of previously used base contract since. -// contracts now require a `dojo_init` method which normal base contract doesn't have -#[dojo::contract] -mod test_contract {} - -#[test] -#[available_gas(6000000)] -fn test_upgrade_from_world() { - let world = deploy_world(); - - let base_address = world - .deploy_contract('salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); - let new_class_hash: ClassHash = contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); - - let selector = selector_from_tag!("dojo-test_contract"); - world.upgrade_contract(selector, new_class_hash); - - let quantum_dispatcher = IQuantumLeapDispatcher { contract_address: base_address }; - assert(quantum_dispatcher.plz_more_tps() == 'daddy', 'quantum leap failed'); -} - -#[test] -#[available_gas(6000000)] -#[should_panic( - expected: ('class_hash not world provider', 'ENTRYPOINT_FAILED', 'ENTRYPOINT_FAILED') -)] -fn test_upgrade_from_world_not_world_provider() { - let world = deploy_world(); - - let _ = world.deploy_contract('salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); - let new_class_hash: ClassHash = contract_invalid_upgrade::TEST_CLASS_HASH.try_into().unwrap(); - - let selector = selector_from_tag!("dojo-test_contract"); - world.upgrade_contract(selector, new_class_hash); -} - -#[test] -#[available_gas(6000000)] -#[should_panic(expected: ('must be called by world', 'ENTRYPOINT_FAILED'))] -fn test_upgrade_direct() { - let world = deploy_world(); - - let base_address = world - .deploy_contract('salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); - let new_class_hash: ClassHash = contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); - - let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address: base_address }; - upgradeable_dispatcher.upgrade(new_class_hash); -} - -#[starknet::interface] -trait IMetadataOnly { - fn selector(self: @T) -> felt252; - fn name(self: @T) -> ByteArray; - fn namespace(self: @T) -> ByteArray; - fn namespace_hash(self: @T) -> felt252; -} - -#[starknet::contract] -mod invalid_legacy_model { - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl InvalidModelMetadata of super::IMetadataOnly { - fn selector(self: @ContractState) -> felt252 { - // Pre-computed address of a contract deployed through the world. - 0x1b1edb46931b1a98d8c6ecf2703e8483ec1d85fb75b3e9c061eab383fc8f8f1 - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo" - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::utils::bytearray_hash(@Self::namespace(self)) - } - - fn name(self: @ContractState) -> ByteArray { - "invalid_legacy_model" - } - } -} - -#[starknet::contract] -mod invalid_legacy_model_world { - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl InvalidModelName of super::IMetadataOnly { - fn selector(self: @ContractState) -> felt252 { - // World address is 0, and not registered as deployed through the world - // as it's itself. - 0 - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo" - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::utils::bytearray_hash(@Self::namespace(self)) - } - - fn name(self: @ContractState) -> ByteArray { - "invalid_legacy_model" - } - } -} - -#[starknet::contract] -mod invalid_model { - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl InvalidModelSelector of super::IMetadataOnly { - fn selector(self: @ContractState) -> felt252 { - // Use the resource identifier of the contract deployed through the world - // instead of the address. - selector_from_tag!("dojo-test_contract") - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo" - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::utils::bytearray_hash(@Self::namespace(self)) - } - - fn name(self: @ContractState) -> ByteArray { - "invalid_model" - } - } -} - -#[starknet::contract] -mod invalid_model_world { - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl InvalidModelSelector of super::IMetadataOnly { - fn selector(self: @ContractState) -> felt252 { - // World address is 0, and not registered as deployed through the world - // as it's itself. - 0 - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo" - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::utils::bytearray_hash(@Self::namespace(self)) - } - - fn name(self: @ContractState) -> ByteArray { - "invalid_model_world" - } - } -} - -#[test] -#[available_gas(6000000)] -#[should_panic( - expected: ("Resource `dojo-invalid_model` is already registered", 'ENTRYPOINT_FAILED',) -)] -fn test_deploy_from_world_invalid_model() { - let world = deploy_world(); - - let _ = world.deploy_contract(0, test_contract::TEST_CLASS_HASH.try_into().unwrap()); - - world.register_model(invalid_model::TEST_CLASS_HASH.try_into().unwrap()); -} - -#[test] -#[available_gas(6000000)] -#[should_panic(expected: ("Invalid resource selector `0`", 'ENTRYPOINT_FAILED',))] -fn test_deploy_from_world_invalid_model_world() { - let world = deploy_world(); - world.register_model(invalid_model_world::TEST_CLASS_HASH.try_into().unwrap()); -} diff --git a/crates/dojo-core/src/tests/helpers.cairo b/crates/dojo-core/src/tests/helpers.cairo deleted file mode 100644 index 54d22cff28..0000000000 --- a/crates/dojo-core/src/tests/helpers.cairo +++ /dev/null @@ -1,224 +0,0 @@ -use starknet::ContractAddress; - -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; - -use dojo::model::Model; -use dojo::utils::test::{deploy_with_world_address, spawn_test_world}; - -#[derive(Copy, Drop, Serde, Debug)] -#[dojo::model] -pub struct Foo { - #[key] - pub caller: ContractAddress, - pub a: felt252, - pub b: u128, -} - -#[derive(Copy, Drop, Serde)] -#[dojo::model(namespace: "another_namespace", nomapping: true)] -pub struct Buzz { - #[key] - pub caller: ContractAddress, - pub a: felt252, - pub b: u128, -} - -#[dojo::interface] -pub trait IFooSetter { - fn set_foo(ref world: IWorldDispatcher, a: felt252, b: u128); -} - -#[dojo::contract] -pub mod foo_setter { - use super::IFooSetter; - use super::Foo; - - #[abi(embed_v0)] - impl IFooSetterImpl of super::IFooSetter { - fn set_foo(ref world: IWorldDispatcher, a: felt252, b: u128) { - set!(world, (Foo { caller: starknet::get_caller_address(), a, b })); - } - } -} - -#[dojo::contract] -pub mod test_contract {} - -#[dojo::contract] -pub mod test_contract_with_dojo_init_args { - fn dojo_init(world: @IWorldDispatcher, _arg1: felt252) { - let _u = world.uuid(); - } -} - -#[dojo::contract(namespace: "buzz_namespace", nomapping: true)] -pub mod buzz_contract {} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -pub struct Sword { - pub swordsmith: ContractAddress, - pub damage: u32, -} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -#[dojo::model] -pub struct Case { - #[key] - pub owner: ContractAddress, - pub sword: Sword, - pub material: felt252, -} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -#[dojo::model] -pub struct Character { - #[key] - pub caller: ContractAddress, - pub heigth: felt252, - pub abilities: Abilities, - pub stats: Stats, - pub weapon: Weapon, - pub gold: u32, -} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -pub struct Abilities { - pub strength: u8, - pub dexterity: u8, - pub constitution: u8, - pub intelligence: u8, - pub wisdom: u8, - pub charisma: u8, -} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -pub struct Stats { - pub kills: u128, - pub deaths: u16, - pub rests: u32, - pub hits: u64, - pub blocks: u32, - pub walked: felt252, - pub runned: felt252, - pub finished: bool, - pub romances: u16, -} - -#[derive(IntrospectPacked, Copy, Drop, Serde)] -pub enum Weapon { - DualWield: (Sword, Sword), - Fists: (Sword, Sword), // Introspect requires same arms -} - -#[starknet::interface] -pub trait Ibar { - fn set_foo(self: @TContractState, a: felt252, b: u128); - fn delete_foo(self: @TContractState); - fn delete_foo_macro(self: @TContractState, foo: Foo); - fn set_char(self: @TContractState, a: felt252, b: u32); -} - -#[starknet::contract] -pub mod bar { - use core::traits::Into; - use starknet::{get_caller_address, ContractAddress}; - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - use dojo::model::{Model, ModelIndex}; - - use super::{Foo, IWorldDispatcher, IWorldDispatcherTrait}; - use super::{Character, Abilities, Stats, Weapon, Sword}; - - #[storage] - struct Storage { - world: IWorldDispatcher, - } - #[constructor] - fn constructor(ref self: ContractState, world: ContractAddress) { - self.world.write(IWorldDispatcher { contract_address: world }) - } - - #[abi(embed_v0)] - impl IbarImpl of super::Ibar { - fn set_foo(self: @ContractState, a: felt252, b: u128) { - set!(self.world.read(), Foo { caller: get_caller_address(), a, b }); - } - - fn delete_foo(self: @ContractState) { - self - .world - .read() - .delete_entity( - Model::::selector(), - ModelIndex::Keys([get_caller_address().into()].span()), - Model::::layout() - ); - } - - fn delete_foo_macro(self: @ContractState, foo: Foo) { - delete!(self.world.read(), Foo { caller: foo.caller, a: foo.a, b: foo.b }); - } - - fn set_char(self: @ContractState, a: felt252, b: u32) { - set!( - self.world.read(), - Character { - caller: get_caller_address(), - heigth: a, - abilities: Abilities { - strength: 0x12, - dexterity: 0x34, - constitution: 0x56, - intelligence: 0x78, - wisdom: 0x9a, - charisma: 0xbc, - }, - stats: Stats { - kills: 0x123456789abcdef, - deaths: 0x1234, - rests: 0x12345678, - hits: 0x123456789abcdef, - blocks: 0x12345678, - walked: 0x123456789abcdef, - runned: 0x123456789abcdef, - finished: true, - romances: 0x1234, - }, - weapon: Weapon::DualWield( - ( - Sword { swordsmith: get_caller_address(), damage: 0x12345678, }, - Sword { swordsmith: get_caller_address(), damage: 0x12345678, } - ) - ), - gold: b, - } - ); - } - } -} - -pub fn deploy_world() -> IWorldDispatcher { - spawn_test_world(["dojo"].span(), [].span()) -} - -pub fn deploy_world_and_bar() -> (IWorldDispatcher, IbarDispatcher) { - // Spawn empty world - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - // System contract - let contract_address = deploy_with_world_address(bar::TEST_CLASS_HASH, world); - let bar_contract = IbarDispatcher { contract_address }; - - world.grant_writer(Model::::selector(), contract_address); - - (world, bar_contract) -} - -pub fn drop_all_events(address: ContractAddress) { - loop { - match starknet::testing::pop_log_raw(address) { - core::option::Option::Some(_) => {}, - core::option::Option::None => { break; }, - }; - } -} diff --git a/crates/dojo-core/src/tests/model/model.cairo b/crates/dojo-core/src/tests/model/model.cairo deleted file mode 100644 index b52ebbfbe7..0000000000 --- a/crates/dojo-core/src/tests/model/model.cairo +++ /dev/null @@ -1,196 +0,0 @@ -use dojo::model::{Model, ModelEntity}; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; - -use dojo::tests::helpers::{deploy_world}; -use dojo::utils::test::{spawn_test_world}; - -#[derive(Copy, Drop, Serde, Debug)] -#[dojo::model] -struct Foo { - #[key] - k1: u8, - #[key] - k2: felt252, - v1: u128, - v2: u32 -} - -#[test] -fn test_id() { - let mvalues = FooEntity { __id: 1, v1: 3, v2: 4 }; - assert!(mvalues.id() == 1); -} - -#[test] -fn test_values() { - let mvalues = FooEntity { __id: 1, v1: 3, v2: 4 }; - let expected_values = [3, 4].span(); - - let values = ModelEntity::::values(@mvalues); - assert!(expected_values == values); -} - -#[test] -fn test_from_values() { - let mut values = [3, 4].span(); - - let model_entity = ModelEntity::::from_values(1, ref values); - assert!(model_entity.__id == 1 && model_entity.v1 == 3 && model_entity.v2 == 4); -} - -#[test] -#[should_panic(expected: "ModelEntity `FooEntity`: deserialization failed.")] -fn test_from_values_bad_data() { - let mut values = [3].span(); - let _ = ModelEntity::::from_values(1, ref values); -} - -#[test] -fn test_get_and_update_entity() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let entity_id = foo.entity_id(); - let mut entity = FooEntityStore::get(world, entity_id); - assert!(entity.__id == entity_id && entity.v1 == entity.v1 && entity.v2 == entity.v2); - - entity.v1 = 12; - entity.v2 = 18; - - entity.update(world); - - let read_values = FooEntityStore::get(world, entity_id); - assert!(read_values.v1 == entity.v1 && read_values.v2 == entity.v2); -} - -#[test] -fn test_delete_entity() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let entity_id = foo.entity_id(); - let mut entity = FooEntityStore::get(world, entity_id); - entity.delete(world); - - let read_values = FooEntityStore::get(world, entity_id); - assert!(read_values.v1 == 0 && read_values.v2 == 0); -} - -#[test] -fn test_get_and_set_member_from_entity() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let v1_raw_value: Span = ModelEntity::< - FooEntity - >::get_member(world, foo.entity_id(), selector!("v1")); - - assert!(v1_raw_value.len() == 1); - assert!(*v1_raw_value.at(0) == 3); - - let entity = FooEntityStore::get(world, foo.entity_id()); - entity.set_member(world, selector!("v1"), [42].span()); - - let entity = FooEntityStore::get(world, foo.entity_id()); - assert!(entity.v1 == 42); -} - -#[test] -fn test_get_and_set_field_name() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let v1 = FooEntityStore::get_v1(world, foo.entity_id()); - assert!(foo.v1 == v1); - - let entity = FooEntityStore::get(world, foo.entity_id()); - entity.set_v1(world, 42); - - let v1 = FooEntityStore::get_v1(world, foo.entity_id()); - assert!(v1 == 42); -} - -#[test] -fn test_get_and_set_from_model() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let read_entity = FooStore::get(world, foo.k1, foo.k2); - - assert!( - foo.k1 == read_entity.k1 - && foo.k2 == read_entity.k2 - && foo.v1 == read_entity.v1 - && foo.v2 == read_entity.v2 - ); -} - -#[test] -fn test_delete_from_model() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - foo.delete(world); - - let read_entity = FooStore::get(world, foo.k1, foo.k2); - assert!( - read_entity.k1 == foo.k1 - && read_entity.k2 == foo.k2 - && read_entity.v1 == 0 - && read_entity.v2 == 0 - ); -} - -#[test] -fn test_get_and_set_member_from_model() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - let keys = [foo.k1.into(), foo.k2.into()].span(); - foo.set(world); - - let v1_raw_value = Model::::get_member(world, keys, selector!("v1")); - - assert!(v1_raw_value.len() == 1); - assert!(*v1_raw_value.at(0) == 3); - - foo.set_member(world, selector!("v1"), [42].span()); - let foo = FooStore::get(world, foo.k1, foo.k2); - assert!(foo.v1 == 42); -} - -#[test] -fn test_get_and_set_field_name_from_model() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; - foo.set(world); - - let v1 = FooStore::get_v1(world, foo.k1, foo.k2); - assert!(v1 == 3); - - foo.set_v1(world, 42); - - let v1 = FooStore::get_v1(world, foo.k1, foo.k2); - assert!(v1 == 42); -} - diff --git a/crates/dojo-core/src/tests/utils.cairo b/crates/dojo-core/src/tests/utils.cairo deleted file mode 100644 index 1c0d239957..0000000000 --- a/crates/dojo-core/src/tests/utils.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use dojo::model::Model; -use dojo::utils::{bytearray_hash, selector_from_names}; - -#[derive(Drop, Copy, Serde)] -#[dojo::model(namespace: "my_namespace")] -struct MyModel { - #[key] - x: u8, - y: u8 -} - -#[test] -fn test_hash_computation() { - // Be sure that the namespace hash computed in `dojo-lang` in Rust is equal - // to the one computed in Cairo by dojo::utils:hash - let namespace = Model::::namespace(); - let namespace_hash = Model::::namespace_hash(); - - assert(bytearray_hash(@namespace) == namespace_hash, 'invalid computed hash'); -} - -#[test] -fn test_selector_computation() { - let namespace = Model::::namespace(); - let name = Model::::name(); - let selector = selector_from_names(@namespace, @name); - assert(selector == Model::::selector(), 'invalid computed selector'); -} diff --git a/crates/dojo-core/src/utils/test.cairo b/crates/dojo-core/src/utils/test.cairo deleted file mode 100644 index b3284ce968..0000000000 --- a/crates/dojo-core/src/utils/test.cairo +++ /dev/null @@ -1,141 +0,0 @@ -use core::array::{ArrayTrait, SpanTrait}; -use core::option::OptionTrait; -use core::result::ResultTrait; -use core::traits::{Into, TryInto}; - -use starknet::{ClassHash, ContractAddress, syscalls::deploy_syscall, get_caller_address}; - -use dojo::contract::base; -use dojo::model::resource_metadata; -use dojo::storage::packing::{shl, shr}; -use dojo::world::{world, IWorldDispatcher, IWorldDispatcherTrait}; - -/// Deploy classhash with calldata for constructor -/// -/// # Arguments -/// -/// * `class_hash` - Class to deploy -/// * `calldata` - calldata for constructor -/// -/// # Returns -/// * address of contract deployed -pub fn deploy_contract(class_hash: felt252, calldata: Span) -> ContractAddress { - let (contract, _) = starknet::syscalls::deploy_syscall( - class_hash.try_into().unwrap(), 0, calldata, false - ) - .unwrap(); - contract -} - -/// Deploy classhash and passes in world address to constructor -/// -/// # Arguments -/// -/// * `class_hash` - Class to deploy -/// * `world` - World dispatcher to pass as world address -/// -/// # Returns -/// * address of contract deployed -pub fn deploy_with_world_address(class_hash: felt252, world: IWorldDispatcher) -> ContractAddress { - deploy_contract(class_hash, [world.contract_address.into()].span()) -} - -/// Spawns a test world registering namespaces and models. -/// -/// # Arguments -/// -/// * `namespaces` - Namespaces to register. -/// * `models` - Models to register. -/// -/// # Returns -/// -/// * World dispatcher -pub fn spawn_test_world(namespaces: Span, models: Span) -> IWorldDispatcher { - let salt = core::testing::get_available_gas(); - - let (world_address, _) = deploy_syscall( - world::TEST_CLASS_HASH.try_into().unwrap(), - salt.into(), - [base::TEST_CLASS_HASH].span(), - false - ) - .unwrap(); - - let world = IWorldDispatcher { contract_address: world_address }; - - // Register all namespaces to ensure correct registration of models. - let mut namespaces = namespaces; - while let Option::Some(namespace) = namespaces.pop_front() { - world.register_namespace(namespace.clone()); - }; - - // Register all models. - let mut index = 0; - loop { - if index == models.len() { - break (); - } - world.register_model((*models[index]).try_into().unwrap()); - index += 1; - }; - - world -} - -#[derive(Drop)] -pub struct GasCounter { - pub start: u128, -} - -#[generate_trait] -pub impl GasCounterImpl of GasCounterTrait { - fn start() -> GasCounter { - let start = core::testing::get_available_gas(); - core::gas::withdraw_gas().unwrap(); - GasCounter { start } - } - - fn end(self: GasCounter, name: ByteArray) { - let end = core::testing::get_available_gas(); - let gas_used = self.start - end; - - println!("# GAS # {}: {}", Self::pad_start(name, 18), gas_used); - core::gas::withdraw_gas().unwrap(); - } - - fn pad_start(str: ByteArray, len: u32) -> ByteArray { - let mut missing: ByteArray = ""; - let missing_len = if str.len() >= len { - 0 - } else { - len - str.len() - }; - - while missing.len() < missing_len { - missing.append(@"."); - }; - missing + str - } -} - -// assert that `value` and `expected` have the same size and the same content -pub fn assert_array(value: Span, expected: Span) { - assert!(value.len() == expected.len(), "Bad array length"); - - let mut i = 0; - loop { - if i >= value.len() { - break; - } - - assert!( - *value.at(i) == *expected.at(i), - "Bad array value [{}] (expected: {} got: {})", - i, - *expected.at(i), - *value.at(i) - ); - - i += 1; - } -} diff --git a/crates/dojo-core/src/utils/utils.cairo b/crates/dojo-core/src/utils/utils.cairo deleted file mode 100644 index 59a42ef7fb..0000000000 --- a/crates/dojo-core/src/utils/utils.cairo +++ /dev/null @@ -1,111 +0,0 @@ -use core::num::traits::Zero; -use core::ops::AddAssign; -use core::option::Option; -use core::poseidon::poseidon_hash_span; -use core::serde::Serde; - -use dojo::model::{Layout, FieldLayout}; - -/// Compute the poseidon hash of a serialized ByteArray -pub fn bytearray_hash(data: @ByteArray) -> felt252 { - let mut serialized = ArrayTrait::new(); - Serde::serialize(data, ref serialized); - poseidon_hash_span(serialized.span()) -} - -/// Computes the selector of a resource from the namespace and the name. -pub fn selector_from_names(namespace: @ByteArray, name: @ByteArray) -> felt252 { - poseidon_hash_span([bytearray_hash(namespace), bytearray_hash(name)].span()) -} - -/// Computes the entity id from the keys. -/// -/// # Arguments -/// -/// * `keys` - The keys of the entity. -/// -/// # Returns -/// -/// The entity id. -pub fn entity_id_from_keys(keys: Span) -> felt252 { - poseidon_hash_span(keys) -} - -/// find a field with its selector in a list of layouts -pub fn find_field_layout( - field_selector: felt252, field_layouts: Span -) -> Option { - let mut i = 0; - let layout = loop { - if i >= field_layouts.len() { - break Option::None; - } - - let field_layout = *field_layouts.at(i); - if field_selector == field_layout.selector { - break Option::Some(field_layout.layout); - } - - i += 1; - }; - - layout -} - -/// Find the layout of a model field based on its selector. -/// -/// # Arguments -/// -/// * `model_layout` - The full model layout (must be a Layout::Struct). -/// * `member_selector` - The model field selector. -/// -/// # Returns -/// Some(Layout) if the field layout has been found, None otherwise. -pub fn find_model_field_layout(model_layout: Layout, member_selector: felt252) -> Option { - match model_layout { - Layout::Struct(field_layouts) => { find_field_layout(member_selector, field_layouts) }, - _ => { - // should never happen as model layouts are always struct layouts. - core::panic_with_felt252('Unexpected model layout'); - Option::None - } - } -} - -/// Indicates if at least of array item is None. -pub fn any_none(arr: @Array>) -> bool { - let mut i = 0; - let mut res = false; - loop { - if i >= arr.len() { - break; - } - - if arr.at(i).is_none() { - res = true; - break; - } - i += 1; - }; - res -} - -/// Compute the sum of array items. -/// Note that there is no overflow check as we expect small array items. -pub fn sum, +Copy, +AddAssign, +Zero>(arr: Array>) -> T { - let mut i = 0; - let mut res = Zero::::zero(); - - loop { - if i >= arr.len() { - break res; - } - res += (*arr.at(i)).unwrap(); - i += 1; - } -} - -/// Combine parent and child keys to build one full key. -pub fn combine_key(parent_key: felt252, child_key: felt252) -> felt252 { - poseidon_hash_span([parent_key, child_key].span()) -} diff --git a/crates/dojo-core/src/world/config.cairo b/crates/dojo-core/src/world/config.cairo deleted file mode 100644 index 5b97233360..0000000000 --- a/crates/dojo-core/src/world/config.cairo +++ /dev/null @@ -1,135 +0,0 @@ -use starknet::ContractAddress; - -pub mod errors { - pub const INVALID_CALLER: felt252 = 'Config: not owner or operator'; - pub const ALREADY_REGISTERED: felt252 = 'Config: already operator'; - pub const NOT_OPERATOR: felt252 = 'Config: not operator'; -} - -#[starknet::interface] -pub trait IConfig { - /// Sets the information of the program that generates the - /// state transition trace (namely DojoOS). - /// - /// # Arguments - /// - /// * `program_hash` - The program hash. - /// * `config_hash` - The program's config hash. - fn set_differ_program_hash(ref self: T, program_hash: felt252); - fn set_merger_program_hash(ref self: T, program_hash: felt252); - - /// Gets the information of the program that generates the - /// state transition trace (namely DojoOS). - /// - /// # Returns - /// - /// The program hash and it's configuration hash. - fn get_differ_program_hash(self: @T) -> felt252; - fn get_merger_program_hash(self: @T) -> felt252; - - /// Sets the facts registry contract address, which is already - /// initialized with the verifier information. - /// - /// # Arguments - /// - /// * `address` - The facts registry contract's address. - fn set_facts_registry(ref self: T, address: ContractAddress); - - /// Gets the facts registry contract address. - /// - /// # Returns - /// - /// The contract address of the facts registry. - fn get_facts_registry(self: @T) -> ContractAddress; -} - -#[starknet::component] -pub mod Config { - use starknet::ContractAddress; - use starknet::get_caller_address; - use starknet::event::EventEmitter; - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - - use super::errors; - use super::IConfig; - - #[event] - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub enum Event { - DifferProgramHashUpdate: DifferProgramHashUpdate, - MergerProgramHashUpdate: MergerProgramHashUpdate, - FactsRegistryUpdate: FactsRegistryUpdate - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct DifferProgramHashUpdate { - pub program_hash: felt252, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct MergerProgramHashUpdate { - pub program_hash: felt252, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct FactsRegistryUpdate { - pub address: ContractAddress - } - - #[storage] - pub struct Storage { - differ_program_hash: felt252, - merger_program_hash: felt252, - facts_registry: ContractAddress, - owner: ContractAddress - } - - #[generate_trait] - pub impl InternalImpl< - TContractState, +HasComponent - > of InternalTrait { - fn initializer(ref self: ComponentState, owner: ContractAddress) { - self.owner.write(owner); - } - } - - #[embeddable_as(ConfigImpl)] - impl Config< - TContractState, +HasComponent - > of IConfig> { - fn set_differ_program_hash( - ref self: ComponentState, program_hash: felt252 - ) { - assert(get_caller_address() == self.owner.read(), errors::INVALID_CALLER); - self.differ_program_hash.write(program_hash); - self.emit(DifferProgramHashUpdate { program_hash }); - } - - fn set_merger_program_hash( - ref self: ComponentState, program_hash: felt252 - ) { - assert(get_caller_address() == self.owner.read(), errors::INVALID_CALLER); - self.merger_program_hash.write(program_hash); - self.emit(MergerProgramHashUpdate { program_hash }); - } - - fn get_differ_program_hash(self: @ComponentState) -> felt252 { - self.differ_program_hash.read() - } - - fn get_merger_program_hash(self: @ComponentState) -> felt252 { - self.merger_program_hash.read() - } - - fn set_facts_registry(ref self: ComponentState, address: ContractAddress) { - assert(get_caller_address() == self.owner.read(), errors::INVALID_CALLER); - self.facts_registry.write(address); - self.emit(FactsRegistryUpdate { address: address }); - } - - fn get_facts_registry(self: @ComponentState) -> ContractAddress { - self.facts_registry.read() - } - } -} - diff --git a/crates/dojo-core/src/world/update.cairo b/crates/dojo-core/src/world/update.cairo deleted file mode 100644 index 045a2d70a3..0000000000 --- a/crates/dojo-core/src/world/update.cairo +++ /dev/null @@ -1,35 +0,0 @@ -use starknet::ContractAddress; - -#[derive(Drop, Serde)] -pub struct StorageUpdate { - pub key: felt252, - pub value: felt252, -} - -#[derive(Drop, Serde)] -pub struct ProgramOutput { - pub prev_state_root: felt252, - pub new_state_root: felt252, - pub block_number: felt252, - pub block_hash: felt252, - pub config_hash: felt252, - pub world_da_hash: felt252, - pub message_to_starknet_segment: Span, - pub message_to_appchain_segment: Span, -} - -#[starknet::interface] -pub trait IUpgradeableState { - fn upgrade_state( - ref self: TContractState, - new_state: Span, - program_output: ProgramOutput, - program_hash: felt252 - ); -} - -#[starknet::interface] -pub trait IFactRegistry { - fn is_valid(self: @TContractState, fact: felt252) -> bool; -} - diff --git a/crates/dojo-core/src/world/world_contract.cairo b/crates/dojo-core/src/world/world_contract.cairo deleted file mode 100644 index c9675a1b41..0000000000 --- a/crates/dojo-core/src/world/world_contract.cairo +++ /dev/null @@ -1,1285 +0,0 @@ -use core::option::OptionTrait; -use core::traits::{Into, TryInto}; -use starknet::{ContractAddress, ClassHash, storage_access::StorageBaseAddress, SyscallResult}; - -use dojo::model::{ModelIndex, ResourceMetadata}; -use dojo::model::{Layout}; -use dojo::utils::bytearray_hash; - -#[derive(Drop, starknet::Store, Serde, Default, Debug)] -pub enum Resource { - Model: (ClassHash, ContractAddress), - Contract: (ClassHash, ContractAddress), - Namespace, - World, - #[default] - Unregistered, -} - -#[starknet::interface] -pub trait IWorld { - fn metadata(self: @T, resource_selector: felt252) -> ResourceMetadata; - fn set_metadata(ref self: T, metadata: ResourceMetadata); - - fn register_namespace(ref self: T, namespace: ByteArray); - - fn register_model(ref self: T, class_hash: ClassHash); - fn upgrade_model(ref self: T, class_hash: ClassHash); - - fn deploy_contract(ref self: T, salt: felt252, class_hash: ClassHash) -> ContractAddress; - fn upgrade_contract(ref self: T, selector: felt252, class_hash: ClassHash) -> ClassHash; - fn init_contract(ref self: T, selector: felt252, init_calldata: Span); - - fn uuid(ref self: T) -> usize; - fn emit(self: @T, keys: Array, values: Span); - - fn entity( - self: @T, model_selector: felt252, index: ModelIndex, layout: Layout - ) -> Span; - fn set_entity( - ref self: T, - model_selector: felt252, - index: ModelIndex, - values: Span, - layout: Layout - ); - fn delete_entity(ref self: T, model_selector: felt252, index: ModelIndex, layout: Layout); - - fn base(self: @T) -> ClassHash; - fn resource(self: @T, selector: felt252) -> Resource; - - /// In Dojo, there are 2 levels of authorization: `owner` and `writer`. - /// Only accounts can own a resource while any contract can write to a resource, - /// as soon as it has granted the write access from an owner of the resource. - fn is_owner(self: @T, resource: felt252, address: ContractAddress) -> bool; - fn grant_owner(ref self: T, resource: felt252, address: ContractAddress); - fn revoke_owner(ref self: T, resource: felt252, address: ContractAddress); - - fn is_writer(self: @T, resource: felt252, contract: ContractAddress) -> bool; - fn grant_writer(ref self: T, resource: felt252, contract: ContractAddress); - fn revoke_writer(ref self: T, resource: felt252, contract: ContractAddress); -} - -#[starknet::interface] -#[cfg(target: "test")] -pub trait IWorldTest { - fn set_entity_test( - ref self: T, - model_selector: felt252, - index: ModelIndex, - values: Span, - layout: Layout - ); - - fn delete_entity_test(ref self: T, model_selector: felt252, index: ModelIndex, layout: Layout); -} - -#[starknet::interface] -pub trait IUpgradeableWorld { - fn upgrade(ref self: T, new_class_hash: ClassHash); -} - -#[starknet::interface] -pub trait IWorldProvider { - fn world(self: @T) -> IWorldDispatcher; -} - -#[starknet::contract] -pub mod world { - use core::array::{ArrayTrait, SpanTrait}; - use core::box::BoxTrait; - use core::hash::{HashStateExTrait, HashStateTrait}; - use core::num::traits::Zero; - use core::option::OptionTrait; - use core::pedersen::PedersenTrait; - use core::serde::Serde; - use core::to_byte_array::FormatAsByteArray; - use core::traits::TryInto; - use core::traits::Into; - use core::panic_with_felt252; - use core::panics::panic_with_byte_array; - - use starknet::event::EventEmitter; - use starknet::{ - contract_address_const, get_caller_address, get_contract_address, get_tx_info, ClassHash, - ContractAddress, syscalls::{deploy_syscall, emit_event_syscall, replace_class_syscall}, - SyscallResult, SyscallResultTrait, storage::Map, - }; - pub use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, - StoragePointerWriteAccess - }; - - use dojo::world::errors; - use dojo::world::config::{Config, IConfig}; - use dojo::contract::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; - use dojo::contract::{IContractDispatcher, IContractDispatcherTrait}; - use dojo::world::update::{ - IUpgradeableState, IFactRegistryDispatcher, IFactRegistryDispatcherTrait, StorageUpdate, - ProgramOutput - }; - use dojo::model::{ - Model, IModelDispatcher, IModelDispatcherTrait, Layout, ResourceMetadata, - ResourceMetadataTrait, metadata - }; - use dojo::storage; - use dojo::utils::{entity_id_from_keys, bytearray_hash}; - - use super::{ - ModelIndex, IWorldDispatcher, IWorldDispatcherTrait, IWorld, IUpgradeableWorld, Resource - }; - - const WORLD: felt252 = 0; - - const DOJO_INIT_SELECTOR: felt252 = selector!("dojo_init"); - - component!(path: Config, storage: config, event: ConfigEvent); - - #[abi(embed_v0)] - impl ConfigImpl = Config::ConfigImpl; - impl ConfigInternalImpl = Config::InternalImpl; - - #[event] - #[derive(Drop, starknet::Event)] - pub enum Event { - WorldSpawned: WorldSpawned, - ContractDeployed: ContractDeployed, - ContractUpgraded: ContractUpgraded, - ContractInitialized: ContractInitialized, - WorldUpgraded: WorldUpgraded, - MetadataUpdate: MetadataUpdate, - NamespaceRegistered: NamespaceRegistered, - ModelRegistered: ModelRegistered, - ModelUpgraded: ModelUpgraded, - StoreSetRecord: StoreSetRecord, - StoreUpdateRecord: StoreUpdateRecord, - StoreUpdateMember: StoreUpdateMember, - StoreDelRecord: StoreDelRecord, - WriterUpdated: WriterUpdated, - OwnerUpdated: OwnerUpdated, - ConfigEvent: Config::Event, - StateUpdated: StateUpdated - } - - #[derive(Drop, starknet::Event)] - pub struct StateUpdated { - pub da_hash: felt252, - } - - #[derive(Drop, starknet::Event)] - pub struct WorldSpawned { - pub address: ContractAddress, - pub creator: ContractAddress - } - - #[derive(Drop, starknet::Event)] - pub struct WorldUpgraded { - pub class_hash: ClassHash, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct ContractDeployed { - pub salt: felt252, - pub class_hash: ClassHash, - pub address: ContractAddress, - pub namespace: ByteArray, - pub name: ByteArray - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct ContractUpgraded { - pub class_hash: ClassHash, - pub address: ContractAddress, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct ContractInitialized { - pub selector: felt252, - pub init_calldata: Span, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct MetadataUpdate { - pub resource: felt252, - pub uri: ByteArray - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct NamespaceRegistered { - pub namespace: ByteArray, - pub hash: felt252 - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct ModelRegistered { - pub name: ByteArray, - pub namespace: ByteArray, - pub class_hash: ClassHash, - pub address: ContractAddress, - } - - #[derive(Drop, starknet::Event, Debug, PartialEq)] - pub struct ModelUpgraded { - pub name: ByteArray, - pub namespace: ByteArray, - pub class_hash: ClassHash, - pub prev_class_hash: ClassHash, - pub address: ContractAddress, - pub prev_address: ContractAddress, - } - - #[derive(Drop, starknet::Event)] - pub struct StoreSetRecord { - pub table: felt252, - pub entity_id: felt252, - pub keys: Span, - pub values: Span, - } - - #[derive(Drop, starknet::Event)] - pub struct StoreUpdateRecord { - pub table: felt252, - pub entity_id: felt252, - pub values: Span, - } - - #[derive(Drop, starknet::Event)] - pub struct StoreUpdateMember { - pub table: felt252, - pub entity_id: felt252, - pub member_selector: felt252, - pub values: Span, - } - - #[derive(Drop, starknet::Event)] - pub struct StoreDelRecord { - pub table: felt252, - pub entity_id: felt252, - } - - #[derive(Drop, starknet::Event)] - pub struct WriterUpdated { - pub resource: felt252, - pub contract: ContractAddress, - pub value: bool - } - - #[derive(Drop, starknet::Event)] - pub struct OwnerUpdated { - pub address: ContractAddress, - pub resource: felt252, - pub value: bool, - } - - #[storage] - struct Storage { - contract_base: ClassHash, - nonce: usize, - models_salt: usize, - resources: Map::, - owners: Map::<(felt252, ContractAddress), bool>, - writers: Map::<(felt252, ContractAddress), bool>, - #[substorage(v0)] - config: Config::Storage, - initialized_contract: Map::, - } - - #[generate_trait] - impl ResourceIsNoneImpl of ResourceIsNoneTrait { - fn is_unregistered(self: @Resource) -> bool { - match self { - Resource::Unregistered => true, - _ => false - } - } - } - - #[constructor] - fn constructor(ref self: ContractState, contract_base: ClassHash) { - let creator = starknet::get_tx_info().unbox().account_contract_address; - self.contract_base.write(contract_base); - - self.resources.write(WORLD, Resource::World); - self - .resources - .write( - Model::::selector(), - Resource::Model((metadata::initial_class_hash(), metadata::initial_address())) - ); - self.owners.write((WORLD, creator), true); - - let dojo_namespace_hash = bytearray_hash(@"__DOJO__"); - - self.resources.write(dojo_namespace_hash, Resource::Namespace); - self.owners.write((dojo_namespace_hash, creator), true); - - self.config.initializer(creator); - - EventEmitter::emit(ref self, WorldSpawned { address: get_contract_address(), creator }); - } - - #[cfg(target: "test")] - #[abi(embed_v0)] - impl WorldTestImpl of super::IWorldTest { - fn set_entity_test( - ref self: ContractState, - model_selector: felt252, - index: ModelIndex, - values: Span, - layout: Layout - ) { - self.set_entity_internal(model_selector, index, values, layout); - } - - fn delete_entity_test( - ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout - ) { - self.delete_entity_internal(model_selector, index, layout); - } - } - - #[abi(embed_v0)] - impl World of IWorld { - /// Returns the metadata of the resource. - /// - /// # Arguments - /// - /// `resource_selector` - The resource selector. - fn metadata(self: @ContractState, resource_selector: felt252) -> ResourceMetadata { - let mut values = self - .read_model_entity( - Model::::selector(), - entity_id_from_keys([resource_selector].span()), - Model::::layout() - ); - - ResourceMetadataTrait::from_values(resource_selector, ref values) - } - - /// Sets the metadata of the resource. - /// - /// # Arguments - /// - /// `metadata` - The metadata content for the resource. - fn set_metadata(ref self: ContractState, metadata: ResourceMetadata) { - self.assert_caller_is_resource_owner(metadata.resource_id); - - self - .write_model_entity( - metadata.instance_selector(), - metadata.entity_id(), - metadata.values(), - metadata.instance_layout() - ); - - EventEmitter::emit( - ref self, - MetadataUpdate { resource: metadata.resource_id, uri: metadata.metadata_uri } - ); - } - - /// Checks if the provided account is an owner of the resource. - /// - /// # Arguments - /// - /// * `resource` - The resource. - /// * `address` - The contract address. - /// - /// # Returns - /// - /// * `bool` - True if the address is an owner of the resource, false otherwise. - fn is_owner(self: @ContractState, resource: felt252, address: ContractAddress) -> bool { - self.owners.read((resource, address)) - } - - /// Grants ownership of the resource to the address. - /// Can only be called by an existing owner or the world admin. - /// - /// Note that this resource must have been registered to the world first. - /// - /// # Arguments - /// - /// * `resource` - The resource. - /// * `address` - The contract address. - fn grant_owner(ref self: ContractState, resource: felt252, address: ContractAddress) { - if self.resources.read(resource).is_unregistered() { - panic_with_byte_array(@errors::resource_not_registered(resource)); - } - - self.assert_caller_is_resource_owner(resource); - - self.owners.write((resource, address), true); - - EventEmitter::emit(ref self, OwnerUpdated { address, resource, value: true }); - } - - /// Revokes owner permission to the contract for the model. - /// Can only be called by an existing owner or the world admin. - /// - /// Note that this resource must have been registered to the world first. - /// - /// # Arguments - /// - /// * `resource` - The resource. - /// * `address` - The contract address. - fn revoke_owner(ref self: ContractState, resource: felt252, address: ContractAddress) { - if self.resources.read(resource).is_unregistered() { - panic_with_byte_array(@errors::resource_not_registered(resource)); - } - - self.assert_caller_is_resource_owner(resource); - - self.owners.write((resource, address), false); - - EventEmitter::emit(ref self, OwnerUpdated { address, resource, value: false }); - } - - /// Checks if the provided contract is a writer of the resource. - /// - /// # Arguments - /// - /// * `resource` - The hash of the resource name. - /// * `contract` - The name of the contract. - /// - /// # Returns - /// - /// * `bool` - True if the contract is a writer of the resource, false otherwise - fn is_writer(self: @ContractState, resource: felt252, contract: ContractAddress) -> bool { - self.writers.read((resource, contract)) - } - - /// Grants writer permission to the contract for the resource. - /// Can only be called by an existing resource owner or the world admin. - /// - /// Note that this resource must have been registered to the world first. - /// - /// # Arguments - /// - /// * `resource` - The hash of the resource name. - /// * `contract` - The name of the contract. - fn grant_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { - if self.resources.read(resource).is_unregistered() { - panic_with_byte_array(@errors::resource_not_registered(resource)); - } - - self.assert_caller_is_resource_owner(resource); - - self.writers.write((resource, contract), true); - - EventEmitter::emit(ref self, WriterUpdated { resource, contract, value: true }); - } - - /// Revokes writer permission to the contract for the model. - /// Can only be called by an existing model owner or the world admin. - /// - /// Note that this resource must have been registered to the world first. - /// - /// # Arguments - /// - /// * `model` - The name of the model. - /// * `contract` - The name of the contract. - fn revoke_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { - if self.resources.read(resource).is_unregistered() { - panic_with_byte_array(@errors::resource_not_registered(resource)); - } - - self.assert_caller_is_resource_owner(resource); - - self.writers.write((resource, contract), false); - - EventEmitter::emit(ref self, WriterUpdated { resource, contract, value: false }); - } - - /// Registers a model in the world. If the model is already registered, - /// the implementation will be updated. - /// - /// # Arguments - /// - /// * `class_hash` - The class hash of the model to be registered. - fn register_model(ref self: ContractState, class_hash: ClassHash) { - let caller = get_caller_address(); - - let salt = self.models_salt.read(); - let (address, name, selector, namespace, namespace_hash) = - dojo::model::deploy_and_get_metadata( - salt.into(), class_hash - ) - .unwrap_syscall(); - self.models_salt.write(salt + 1); - - if selector.is_zero() { - panic_with_byte_array(@errors::invalid_resource_selector(selector)); - } - - if !self.is_namespace_registered(namespace_hash) { - panic_with_byte_array(@errors::namespace_not_registered(@namespace)); - } - - self.assert_caller_namespace_write_access(@namespace, namespace_hash); - - let model = self.resources.read(selector); - if !model.is_unregistered() { - panic_with_byte_array(@errors::model_already_registered(@namespace, @name)); - } - - self.resources.write(selector, Resource::Model((class_hash, address))); - self.owners.write((selector, caller), true); - - EventEmitter::emit(ref self, ModelRegistered { name, namespace, address, class_hash }); - } - - fn upgrade_model(ref self: ContractState, class_hash: ClassHash) { - let caller = get_caller_address(); - - let salt = self.models_salt.read(); - let (address, name, selector, namespace, namespace_hash) = - dojo::model::deploy_and_get_metadata( - salt.into(), class_hash - ) - .unwrap_syscall(); - self.models_salt.write(salt + 1); - - if !self.is_namespace_registered(namespace_hash) { - panic_with_byte_array(@errors::namespace_not_registered(@namespace)); - } - - self.assert_caller_namespace_write_access(@namespace, namespace_hash); - - if selector.is_zero() { - panic_with_byte_array(@errors::invalid_resource_selector(selector)); - } - - let mut prev_class_hash = core::num::traits::Zero::::zero(); - let mut prev_address = core::num::traits::Zero::::zero(); - - match self.resources.read(selector) { - // If model is already registered, validate permission to update. - Resource::Model(( - model_hash, model_address - )) => { - if !self.is_owner(selector, caller) { - panic_with_byte_array(@errors::not_owner_upgrade(caller, selector)); - } - - prev_class_hash = model_hash; - prev_address = model_address; - }, - Resource::Unregistered => { - panic_with_byte_array(@errors::model_not_registered(@namespace, @name)) - }, - _ => panic_with_byte_array( - @errors::resource_conflict(@format!("{}-{}", namespace, name), @"model") - ) - }; - - self.resources.write(selector, Resource::Model((class_hash, address))); - - EventEmitter::emit( - ref self, - ModelUpgraded { - name, namespace, prev_address, address, class_hash, prev_class_hash - } - ); - } - - /// Registers a namespace in the world. - /// - /// # Arguments - /// - /// * `namespace` - The name of the namespace to be registered. - fn register_namespace(ref self: ContractState, namespace: ByteArray) { - let caller = get_caller_address(); - - let hash = bytearray_hash(@namespace); - - match self.resources.read(hash) { - Resource::Namespace => panic_with_byte_array( - @errors::namespace_already_registered(@namespace) - ), - Resource::Unregistered => { - self.resources.write(hash, Resource::Namespace); - self.owners.write((hash, caller), true); - - EventEmitter::emit(ref self, NamespaceRegistered { namespace, hash }); - }, - _ => { - panic_with_byte_array(@errors::resource_conflict(@namespace, @"namespace")); - } - }; - } - - /// Deploys a contract associated with the world. - /// - /// # Arguments - /// - /// * `salt` - The salt use for contract deployment. - /// * `class_hash` - The class hash of the contract. - /// * `init_calldata` - Calldata used to initialize the contract. - /// - /// # Returns - /// - /// * `ContractAddress` - The address of the newly deployed contract. - fn deploy_contract( - ref self: ContractState, salt: felt252, class_hash: ClassHash, - ) -> ContractAddress { - let caller = get_caller_address(); - - let (contract_address, _) = deploy_syscall( - self.contract_base.read(), salt, [].span(), false - ) - .unwrap_syscall(); - let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address }; - upgradeable_dispatcher.upgrade(class_hash); - - let dispatcher = IContractDispatcher { contract_address }; - let namespace = dispatcher.namespace(); - let name = dispatcher.name(); - let namespace_hash = dispatcher.namespace_hash(); - - if !self.is_namespace_registered(namespace_hash) { - panic_with_byte_array(@errors::namespace_not_registered(@namespace)); - } - - self.assert_caller_namespace_write_access(@namespace, namespace_hash); - - let selector = dispatcher.selector(); - - match self.resources.read(selector) { - Resource::Unregistered => {}, - _ => panic_with_byte_array(@errors::resource_already_registered(selector)) - }; - - self.owners.write((selector, caller), true); - self.resources.write(selector, Resource::Contract((class_hash, contract_address))); - - EventEmitter::emit( - ref self, - ContractDeployed { salt, class_hash, address: contract_address, namespace, name } - ); - - contract_address - } - - /// Upgrades an already deployed contract associated with the world. - /// - /// # Arguments - /// - /// * `selector` - The selector of the contract to upgrade. - /// * `class_hash` - The class hash of the contract. - /// - /// # Returns - /// - /// * `ClassHash` - The new class hash of the contract. - fn upgrade_contract( - ref self: ContractState, selector: felt252, class_hash: ClassHash - ) -> ClassHash { - self.assert_caller_is_resource_owner(selector); - - if let Resource::Contract((_, contract_address)) = self.resources.read(selector) { - IUpgradeableDispatcher { contract_address }.upgrade(class_hash); - EventEmitter::emit( - ref self, ContractUpgraded { class_hash, address: contract_address } - ); - class_hash - } else { - panic_with_byte_array(@errors::invalid_resource_selector(selector)) - } - } - - /// Initializes a contract associated with the world. - /// - /// # Arguments - /// - /// * `selector` - The selector of the contract to initialize. - /// * `init_calldata` - Calldata used to initialize the contract. - fn init_contract(ref self: ContractState, selector: felt252, init_calldata: Span) { - if let Resource::Contract((_, contract_address)) = self.resources.read(selector) { - let caller = get_caller_address(); - - let dispatcher = IContractDispatcher { contract_address }; - let tag = dispatcher.tag(); - - if self.initialized_contract.read(selector) { - panic_with_byte_array(@errors::contract_already_initialized(@tag)); - } else { - if !self.is_owner(selector, caller) { - panic_with_byte_array(@errors::not_owner_init(@tag, caller)); - } - - // For the init, to ensure only the world can call the init function, - // the verification is done in the init function of the contract: - // `crates/dojo-lang/src/contract.rs#L140` - // `crates/dojo-lang/src/contract.rs#L331` - - starknet::syscalls::call_contract_syscall( - contract_address, DOJO_INIT_SELECTOR, init_calldata - ) - .unwrap_syscall(); - - self.initialized_contract.write(selector, true); - - EventEmitter::emit(ref self, ContractInitialized { selector, init_calldata }); - } - } else { - panic_with_byte_array( - @errors::resource_conflict(@format!("{selector}"), @"contract") - ); - } - } - - /// Issues an autoincremented id to the caller. - /// - /// # Returns - /// - /// * `usize` - The autoincremented id. - fn uuid(ref self: ContractState) -> usize { - let current = self.nonce.read(); - self.nonce.write(current + 1); - current - } - - /// Emits a custom event. - /// - /// # Arguments - /// - /// * `keys` - The keys of the event. - /// * `values` - The data to be logged by the event. - fn emit(self: @ContractState, mut keys: Array, values: Span) { - let system = get_caller_address(); - system.serialize(ref keys); - - emit_event_syscall(keys.span(), values).unwrap_syscall(); - } - - /// Gets the values of a model record/entity/member. - /// Returns a zero initialized model value if the record/entity/member has not been set. - /// - /// # Arguments - /// - /// * `model_selector` - The selector of the model to be retrieved. - /// * `index` - The index of the record/entity/member to read. - /// * `layout` - The memory layout of the model. - /// - /// # Returns - /// - /// * `Span` - The serialized value of the model, zero initialized if not set. - fn entity( - self: @ContractState, model_selector: felt252, index: ModelIndex, layout: Layout - ) -> Span { - match index { - ModelIndex::Keys(keys) => { - let entity_id = entity_id_from_keys(keys); - self.read_model_entity(model_selector, entity_id, layout) - }, - ModelIndex::Id(entity_id) => { - self.read_model_entity(model_selector, entity_id, layout) - }, - ModelIndex::MemberId(( - entity_id, member_id - )) => { self.read_model_member(model_selector, entity_id, member_id, layout) } - } - } - - /// Sets the model value for a model record/entity/member. - /// - /// # Arguments - /// - /// * `model_selector` - The selector of the model to be set. - /// * `index` - The index of the record/entity/member to write. - /// * `values` - The value to be set, serialized using the model layout format. - /// * `layout` - The memory layout of the model. - fn set_entity( - ref self: ContractState, - model_selector: felt252, - index: ModelIndex, - values: Span, - layout: Layout - ) { - self.assert_caller_model_write_access(model_selector); - self.set_entity_internal(model_selector, index, values, layout); - } - - /// Deletes a record/entity of a model.. - /// Deleting is setting all the values to 0 in the given layout. - /// - /// # Arguments - /// - /// * `model_selector` - The selector of the model to be deleted. - /// * `index` - The index of the record/entity to delete. - /// * `layout` - The memory layout of the model. - fn delete_entity( - ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout - ) { - self.assert_caller_model_write_access(model_selector); - self.delete_entity_internal(model_selector, index, layout); - } - - /// Gets the base contract class hash. - /// - /// # Returns - /// - /// * `ClassHash` - The class_hash of the contract_base contract. - fn base(self: @ContractState) -> ClassHash { - self.contract_base.read() - } - - /// Gets resource data from its selector. - /// - /// # Arguments - /// * `selector` - the resource selector - /// - /// # Returns - /// * `Resource` - the resource data associated with the selector. - fn resource(self: @ContractState, selector: felt252) -> Resource { - self.resources.read(selector) - } - } - - - #[abi(embed_v0)] - impl UpgradeableWorld of IUpgradeableWorld { - /// Upgrades the world with new_class_hash - /// - /// # Arguments - /// - /// * `new_class_hash` - The new world class hash. - fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { - assert(new_class_hash.is_non_zero(), 'invalid class_hash'); - - if !self.is_caller_world_owner() { - panic_with_byte_array(@errors::not_owner_upgrade(get_caller_address(), WORLD)); - } - - // upgrade to new_class_hash - replace_class_syscall(new_class_hash).unwrap(); - - // emit Upgrade Event - EventEmitter::emit(ref self, WorldUpgraded { class_hash: new_class_hash }); - } - } - - #[abi(embed_v0)] - impl UpgradeableState of IUpgradeableState { - fn upgrade_state( - ref self: ContractState, - new_state: Span, - program_output: ProgramOutput, - program_hash: felt252 - ) { - if !self.is_caller_world_owner() { - panic_with_byte_array( - @errors::no_world_owner(get_caller_address(), @"upgrade state") - ); - } - - let mut da_hasher = PedersenTrait::new(0); - let mut i = 0; - loop { - if i == new_state.len() { - break; - } - da_hasher = da_hasher.update(*new_state.at(i).key); - da_hasher = da_hasher.update(*new_state.at(i).value); - i += 1; - }; - let da_hash = da_hasher.finalize(); - assert(da_hash == program_output.world_da_hash, 'wrong output hash'); - - assert( - program_hash == self.config.get_differ_program_hash() - || program_hash == self.config.get_merger_program_hash(), - 'wrong program hash' - ); - - let mut program_output_array = array![]; - program_output.serialize(ref program_output_array); - let program_output_hash = core::poseidon::poseidon_hash_span( - program_output_array.span() - ); - - let fact = core::poseidon::PoseidonImpl::new() - .update(program_hash) - .update(program_output_hash) - .finalize(); - let fact_registry = IFactRegistryDispatcher { - contract_address: self.config.get_facts_registry() - }; - assert(fact_registry.is_valid(fact), 'no state transition proof'); - - let mut i = 0; - loop { - if i >= new_state.len() { - break; - } - let base = starknet::storage_access::storage_base_address_from_felt252( - *new_state.at(i).key - ); - starknet::syscalls::storage_write_syscall( - 0, - starknet::storage_access::storage_address_from_base(base), - *new_state.at(i).value - ) - .unwrap_syscall(); - i += 1; - }; - EventEmitter::emit(ref self, StateUpdated { da_hash: da_hash }); - } - } - - #[generate_trait] - impl SelfImpl of SelfTrait { - #[inline(always)] - /// Indicates if the caller is the owner of the world. - fn is_caller_world_owner(self: @ContractState) -> bool { - self.is_owner(WORLD, get_caller_address()) - } - - /// Panics if the caller is NOT an owner of the resource. - /// - /// # Arguments - /// * `resource_selector` - the selector of the resource. - #[inline(always)] - fn assert_caller_is_resource_owner(self: @ContractState, resource_selector: felt252) { - let caller = get_caller_address(); - - if self.is_owner(resource_selector, caller) { - return; - } - - if self.is_caller_world_owner() { - return; - } - - panic_with_byte_array(@errors::not_owner(caller, resource_selector)); - } - - /// Panics if the caller has NOT the writer role on the model. - /// - /// # Arguments - /// * `model_selector` - the selector of the model. - #[inline(always)] - fn assert_caller_model_write_access(self: @ContractState, model_selector: felt252) { - let caller = get_caller_address(); - - // Must have owner or writer role on the namespace or on the model. - match self.resources.read(model_selector) { - Resource::Model(( - _, model_address - )) => { - let model = IModelDispatcher { contract_address: model_address }; - let namespace_selector = model.namespace_hash(); - - // - use several single if because it seems more efficient than a big one with - // several conditions. - // - sort conditions by order of probability so once a condition is met, the - // function returns. - if self.is_writer(namespace_selector, caller) { - return; - } - if self.is_writer(model_selector, caller) { - return; - } - if self.is_owner(namespace_selector, caller) { - return; - } - if self.is_owner(model_selector, caller) { - return; - } - if self.is_caller_world_owner() { - return; - } - - let model_tag = model.tag(); - let d = IContractDispatcher { contract_address: caller }; - - // If the caller is not a dojo contract, the `d.selector()` will fail. In the - // future use the SRC5 to first query the contract to see if it implements the - // `IContract` interface. - // For now, we just assume that the caller is a dojo contract as it's 100% of - // the dojo use cases at the moment. - if let Resource::Contract((_, contract_address)) = self - .resources - .read(d.selector()) { - let d = IContractDispatcher { contract_address }; - panic_with_byte_array( - @errors::no_write_access_with_tags( - @d.tag(), @"model (or it's namespace)", @model_tag - ) - ); - } else { - panic_with_byte_array(@errors::no_model_write_access(@model_tag, caller)); - } - }, - Resource::Unregistered => { - panic_with_byte_array(@errors::resource_not_registered(model_selector)); - }, - _ => panic_with_byte_array( - @errors::resource_conflict(@format!("{}", model_selector), @"model") - ) - } - } - - /// Panics if the caller has NOT the writer role on the namespace. - /// - /// # Arguments - /// * `namespace` - the namespace name. - /// * `namespace_hash` - the hash of the namespace. - #[inline(always)] - fn assert_caller_namespace_write_access( - self: @ContractState, namespace: @ByteArray, namespace_hash: felt252 - ) { - let caller = get_caller_address(); - - if self.is_writer(namespace_hash, caller) { - return; - } - if self.is_owner(namespace_hash, caller) { - return; - } - if self.is_caller_world_owner() { - return; - } - - // We know it's an account and return the explicit error message as no tag will match - // the account. - if caller == get_tx_info().account_contract_address { - panic_with_byte_array(@errors::no_namespace_write_access(caller, namespace)); - } - - // If the caller is not a dojo contract, the `d.selector()` will fail. In the future use - // the SRC5 to first query the contract to see if it implements the `IContract` - // interface. - // For now, we just assume that the caller is a dojo contract as it's 100% of the dojo - // use cases at the moment. - let d = IContractDispatcher { contract_address: caller }; - - if let Resource::Contract((_, contract_address)) = self.resources.read(d.selector()) { - let d = IContractDispatcher { contract_address }; - panic_with_byte_array( - @errors::no_write_access_with_tags(@d.tag(), @"namespace", namespace) - ); - } else { - // This is in theory unreachable code as the contract call syscall made by the - // dispatcher will panic. Which may lead to a bad user experience in testing as the - // error will be something like "CONTRACT_NOT_DEPLOYED". - panic_with_byte_array(@errors::no_namespace_write_access(caller, namespace)); - } - } - - /// Indicates if the provided namespace is already registered - /// - /// # Arguments - /// * `namespace_hash` - the hash of the namespace. - #[inline(always)] - fn is_namespace_registered(self: @ContractState, namespace_hash: felt252) -> bool { - match self.resources.read(namespace_hash) { - Resource::Namespace => true, - _ => false - } - } - - /// Sets the model value for a model record/entity/member. - /// - /// # Arguments - /// - /// * `model_selector` - The selector of the model to be set. - /// * `index` - The index of the record/entity/member to write. - /// * `values` - The value to be set, serialized using the model layout format. - /// * `layout` - The memory layout of the model. - fn set_entity_internal( - ref self: ContractState, - model_selector: felt252, - index: ModelIndex, - values: Span, - layout: Layout - ) { - match index { - ModelIndex::Keys(keys) => { - let entity_id = entity_id_from_keys(keys); - self.write_model_entity(model_selector, entity_id, values, layout); - EventEmitter::emit( - ref self, StoreSetRecord { table: model_selector, keys, values, entity_id } - ); - }, - ModelIndex::Id(entity_id) => { - self.write_model_entity(model_selector, entity_id, values, layout); - EventEmitter::emit( - ref self, StoreUpdateRecord { table: model_selector, entity_id, values } - ); - }, - ModelIndex::MemberId(( - entity_id, member_selector - )) => { - self - .write_model_member( - model_selector, entity_id, member_selector, values, layout - ); - EventEmitter::emit( - ref self, - StoreUpdateMember { - table: model_selector, entity_id, member_selector, values - } - ); - } - } - } - - /// Deletes an entity for the given model, setting all the values to 0 in the given layout. - /// - /// # Arguments - /// - /// * `model_selector` - The selector of the model to be deleted. - /// * `index` - The index of the record/entity to delete. - /// * `layout` - The memory layout of the model. - fn delete_entity_internal( - ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout - ) { - match index { - ModelIndex::Keys(keys) => { - let entity_id = entity_id_from_keys(keys); - self.delete_model_entity(model_selector, entity_id, layout); - EventEmitter::emit( - ref self, StoreDelRecord { table: model_selector, entity_id } - ); - }, - ModelIndex::Id(entity_id) => { - self.delete_model_entity(model_selector, entity_id, layout); - EventEmitter::emit( - ref self, StoreDelRecord { table: model_selector, entity_id } - ); - }, - ModelIndex::MemberId(_) => { panic_with_felt252(errors::DELETE_ENTITY_MEMBER); } - } - } - - /// Write a new entity. - /// - /// # Arguments - /// * `model_selector` - the model selector - /// * `entity_id` - the id used to identify the record - /// * `values` - the field values of the record - /// * `layout` - the model layout - fn write_model_entity( - ref self: ContractState, - model_selector: felt252, - entity_id: felt252, - values: Span, - layout: Layout - ) { - let mut offset = 0; - - match layout { - Layout::Fixed(layout) => { - storage::layout::write_fixed_layout( - model_selector, entity_id, values, ref offset, layout - ); - }, - Layout::Struct(layout) => { - storage::layout::write_struct_layout( - model_selector, entity_id, values, ref offset, layout - ); - }, - _ => { panic!("Unexpected layout type for a model."); } - }; - } - - /// Delete an entity. - /// - /// # Arguments - /// * `model_selector` - the model selector - /// * `entity_id` - the ID of the entity to remove. - /// * `layout` - the model layout - fn delete_model_entity( - ref self: ContractState, model_selector: felt252, entity_id: felt252, layout: Layout - ) { - match layout { - Layout::Fixed(layout) => { - storage::layout::delete_fixed_layout(model_selector, entity_id, layout); - }, - Layout::Struct(layout) => { - storage::layout::delete_struct_layout(model_selector, entity_id, layout); - }, - _ => { panic!("Unexpected layout type for a model."); } - }; - } - - /// Read an entity. - /// - /// # Arguments - /// * `model_selector` - the model selector - /// * `entity_id` - the ID of the entity to read. - /// * `layout` - the model layout - fn read_model_entity( - self: @ContractState, model_selector: felt252, entity_id: felt252, layout: Layout - ) -> Span { - let mut read_data = ArrayTrait::::new(); - - match layout { - Layout::Fixed(layout) => { - storage::layout::read_fixed_layout( - model_selector, entity_id, ref read_data, layout - ); - }, - Layout::Struct(layout) => { - storage::layout::read_struct_layout( - model_selector, entity_id, ref read_data, layout - ); - }, - _ => { panic!("Unexpected layout type for a model."); } - }; - - read_data.span() - } - - /// Read a model member value. - /// - /// # Arguments - /// * `model_selector` - the model selector - /// * `entity_id` - the ID of the entity for which to read a member. - /// * `member_id` - the selector of the model member to read. - /// * `layout` - the model layout - fn read_model_member( - self: @ContractState, - model_selector: felt252, - entity_id: felt252, - member_id: felt252, - layout: Layout - ) -> Span { - let mut read_data = ArrayTrait::::new(); - storage::layout::read_layout( - model_selector, - dojo::utils::combine_key(entity_id, member_id), - ref read_data, - layout - ); - - read_data.span() - } - - /// Write a model member value. - /// - /// # Arguments - /// * `model_selector` - the model selector - /// * `entity_id` - the ID of the entity for which to write a member. - /// * `member_id` - the selector of the model member to write. - /// * `values` - the new member value. - /// * `layout` - the model layout - fn write_model_member( - self: @ContractState, - model_selector: felt252, - entity_id: felt252, - member_id: felt252, - values: Span, - layout: Layout - ) { - let mut offset = 0; - storage::layout::write_layout( - model_selector, - dojo::utils::combine_key(entity_id, member_id), - values, - ref offset, - layout - ) - } - } -} diff --git a/crates/dojo-lang/README.md b/crates/dojo-lang/README.md deleted file mode 100644 index 8f1f5da0b5..0000000000 --- a/crates/dojo-lang/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# dojo-lang - -Cairo language plugin for compiling the Dojo Entity Component System to Starknet contracts. - -## Testing - -Expected test outputs are defined in `crates/dojo-lang/src/plugin_test_data/model`. - -To run the tests, run: - -``` -cargo test --package dojo-lang --lib -- plugin::test::expand_contract::model --exact --nocapture -``` - -To regenerate, set `CAIRO_FIX_TESTS=1`: - -``` -CAIRO_FIX_TESTS=1 cargo test --package dojo-lang -``` diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs deleted file mode 100644 index b4b9ab312f..0000000000 --- a/crates/dojo-lang/src/compiler.rs +++ /dev/null @@ -1,730 +0,0 @@ -use std::collections::{BTreeMap, HashMap}; -use std::fs; -use std::io::Write; -use std::ops::DerefMut; -use std::rc::Rc; - -use anyhow::{anyhow, Context, Result}; -use cairo_lang_compiler::db::RootDatabase; -use cairo_lang_defs::db::DefsGroup; -use cairo_lang_defs::ids::{ - ModuleId, ModuleItemId, NamedLanguageElementId, TopLevelLanguageElementId, -}; -use cairo_lang_filesystem::db::FilesGroup; -use cairo_lang_filesystem::ids::{CrateId, CrateLongId}; -use cairo_lang_formatter::format_string; -use cairo_lang_semantic::db::SemanticGroup; -use cairo_lang_starknet::compile::compile_prepared_db; -use cairo_lang_starknet::contract::{find_contracts, ContractDeclaration}; -use cairo_lang_starknet_classes::abi; -use cairo_lang_starknet_classes::allowed_libfuncs::{AllowedLibfuncsError, ListSelector}; -use cairo_lang_starknet_classes::contract_class::ContractClass; -use cairo_lang_utils::UpcastMut; -use camino::Utf8PathBuf; -use convert_case::{Case, Casing}; -use dojo_world::contracts::naming; -use dojo_world::manifest::{ - AbiFormat, Class, DojoContract, DojoModel, Manifest, ManifestMethods, ABIS_DIR, - BASE_CONTRACT_TAG, BASE_DIR, BASE_QUALIFIED_PATH, CONTRACTS_DIR, MANIFESTS_DIR, MODELS_DIR, - WORLD_CONTRACT_TAG, WORLD_QUALIFIED_PATH, -}; -use itertools::{izip, Itertools}; -use scarb::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; -use scarb::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; -use scarb::core::{PackageName, TargetKind, Workspace}; -use scarb::flock::Filesystem; -use serde::de::DeserializeOwned; -use serde::{Deserialize, Serialize}; -use smol_str::SmolStr; -use starknet::core::types::contract::SierraClass; -use starknet::core::types::Felt; -use tracing::{debug, trace, trace_span}; - -use crate::plugin::{DojoAuxData, Model}; -use crate::scarb_internal::debug::SierraToCairoDebugInfo; - -#[derive(Debug, Clone)] -pub struct CompiledArtifact { - /// THe class hash of the Sierra contract. - class_hash: Felt, - /// The actual compiled Sierra contract class. - contract_class: Rc, - debug_info: Option>, -} - -/// A type alias for a map of compiled artifacts by their path. -type CompiledArtifactByPath = HashMap; - -const CAIRO_PATH_SEPARATOR: &str = "::"; - -pub(crate) const LOG_TARGET: &str = "dojo_lang::compiler"; - -#[cfg(test)] -#[path = "compiler_test.rs"] -mod test; - -#[derive(Debug, Default)] -pub struct DojoCompiler { - /// Output the debug information of the compiled Sierra contracts. - /// - /// Mainly used for the Walnut debugger integration. It is used - /// internally by Walnut to build the Dojo project with the Sierra - /// debug information. This flag has no use outside of that. - output_debug_info: bool, -} - -impl DojoCompiler { - pub fn new(output_debug_info: bool) -> Self { - Self { output_debug_info } - } -} - -#[derive(Debug, Default, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub struct Props { - pub build_external_contracts: Option>, -} - -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct ContractSelector(String); - -impl ContractSelector { - fn package(&self) -> PackageName { - let parts = self.0.split_once(CAIRO_PATH_SEPARATOR).unwrap_or((self.0.as_str(), "")); - PackageName::new(parts.0) - } - - /// Returns the path with the model name in snake case. - /// This is used to match the output of the `compile()` function and Dojo plugin naming for - /// models contracts. - fn path_with_model_snake_case(&self) -> String { - let (path, last_segment) = - self.0.rsplit_once(CAIRO_PATH_SEPARATOR).unwrap_or(("", &self.0)); - - // We don't want to snake case the whole path because some of names like `erc20` - // will be changed to `erc_20`, and leading to invalid paths. - // The model name has to be snaked case as it's how the Dojo plugin names the Model's - // contract. - format!("{}{}{}", path, CAIRO_PATH_SEPARATOR, last_segment.to_case(Case::Snake)) - } -} - -impl Compiler for DojoCompiler { - fn target_kind(&self) -> TargetKind { - TargetKind::new("dojo") - } - - // TODO: refacto the main loop here, could be much more simpler and efficient. - fn compile( - &self, - unit: CairoCompilationUnit, - db: &mut RootDatabase, - ws: &Workspace<'_>, - ) -> Result<()> { - let props: Props = unit.main_component().target_props()?; - let target_dir = unit.target_dir(ws); - - // TODO: if we want to output the manifests at the package level, - // we must iterate on the ws members, to find the location of the - // sole package with the `dojo` target. - // In this case, we can use this path to output the manifests. - - let compiler_config = build_compiler_config(&unit, ws); - - trace!(target: LOG_TARGET, unit = %unit.name(), ?props, "Compiling unit dojo compiler."); - - let mut main_crate_ids = collect_main_crate_ids(&unit, db); - let core_crate_ids: Vec = collect_core_crate_ids(db); - main_crate_ids.extend(core_crate_ids); - - let contracts = find_project_contracts( - db.upcast_mut(), - main_crate_ids.clone(), - props.build_external_contracts.clone(), - )?; - - let contract_paths = contracts - .iter() - .map(|decl| decl.module_id().full_path(db.upcast_mut())) - .collect::>(); - trace!(target: LOG_TARGET, contracts = ?contract_paths); - - let contracts = contracts.iter().collect::>(); - - let classes = { - let _ = trace_span!("compile_starknet").enter(); - compile_prepared_db(db, &contracts, compiler_config)? - }; - - let debug_info_classes: Vec> = if self.output_debug_info { - let debug_classes = - crate::scarb_internal::debug::compile_prepared_db_to_debug_info(db, &contracts)?; - - debug_classes - .into_iter() - .map(|d| Some(crate::scarb_internal::debug::get_sierra_to_cairo_debug_info(&d, db))) - .collect() - } else { - vec![None; contracts.len()] - }; - - let mut compiled_classes: CompiledArtifactByPath = HashMap::new(); - let list_selector = ListSelector::default(); - - for (decl, contract_class, debug_info) in izip!(contracts, classes, debug_info_classes) { - let contract_name = decl.submodule_id.name(db.upcast_mut()); - // note that the qualified path is in snake case while - // the `full_path()` method of StructId uses the original struct name case. - // (see in `get_dojo_model_artifacts`) - let qualified_path = decl.module_id().full_path(db.upcast_mut()); - - match contract_class.validate_version_compatible(list_selector.clone()) { - Ok(()) => {} - Err(AllowedLibfuncsError::UnsupportedLibfunc { - invalid_libfunc, - allowed_libfuncs_list_name: _, - }) => { - let diagnostic = format! {r#" - Contract `{contract_name}` ({qualified_path}) includes `{invalid_libfunc}` function that is not allowed in the default libfuncs for public Starknet networks (mainnet, sepolia). - It will work on Katana, but don't forget to remove it before deploying on a public Starknet network. - "#}; - - ws.config().ui().warn(diagnostic); - } - Err(e) => { - return Err(e).with_context(|| { - format!("Failed to check allowed libfuncs for contract: {}", contract_name) - }); - } - } - - let class_hash = - compute_class_hash_of_contract_class(&contract_class).with_context(|| { - format!( - "problem computing class hash for contract `{}`", - qualified_path.clone() - ) - })?; - - compiled_classes.insert( - qualified_path, - CompiledArtifact { - class_hash, - contract_class: Rc::new(contract_class), - debug_info: debug_info.map(Rc::new), - }, - ); - } - - update_files( - db, - ws, - &target_dir, - &main_crate_ids, - compiled_classes, - props.build_external_contracts, - )?; - Ok(()) - } -} - -fn compute_class_hash_of_contract_class(class: &ContractClass) -> Result { - let class_str = serde_json::to_string(&class)?; - let sierra_class = serde_json::from_str::(&class_str) - .map_err(|e| anyhow!("error parsing Sierra class: {e}"))?; - sierra_class.class_hash().map_err(|e| anyhow!("problem hashing sierra contract: {e}")) -} - -fn find_project_contracts( - mut db: &dyn SemanticGroup, - main_crate_ids: Vec, - external_contracts: Option>, -) -> Result> { - let internal_contracts = { - let _ = trace_span!("find_internal_contracts").enter(); - find_contracts(db, &main_crate_ids) - }; - - let external_contracts = if let Some(external_contracts) = external_contracts { - let _ = trace_span!("find_external_contracts").enter(); - debug!(target: LOG_TARGET, external_contracts = ?external_contracts, "External contracts selectors."); - - let crate_ids = external_contracts - .iter() - .map(|selector| selector.package().into()) - .unique() - .map(|package_name: SmolStr| { - debug!(target: LOG_TARGET, %package_name, "Looking for internal crates."); - db.upcast_mut().intern_crate(CrateLongId::Real(package_name)) - }) - .collect::>(); - - find_contracts(db, crate_ids.as_ref()) - .into_iter() - .filter(|decl| { - let contract_path = decl.module_id().full_path(db.upcast()); - external_contracts - .iter() - .any(|selector| contract_path == selector.path_with_model_snake_case()) - }) - .collect::>() - } else { - debug!(target: LOG_TARGET, "No external contracts selected."); - Vec::new() - }; - - Ok(internal_contracts.into_iter().chain(external_contracts).collect()) -} - -pub fn collect_core_crate_ids(db: &RootDatabase) -> Vec { - [ - ContractSelector(BASE_QUALIFIED_PATH.to_string()), - ContractSelector(WORLD_QUALIFIED_PATH.to_string()), - ] - .iter() - .map(|selector| selector.package().into()) - .unique() - .map(|package_name: SmolStr| db.intern_crate(CrateLongId::Real(package_name))) - .collect::>() -} - -pub fn collect_external_crate_ids( - db: &RootDatabase, - external_contracts: Vec, -) -> Vec { - external_contracts - .iter() - .map(|selector| selector.package().into()) - .unique() - .map(|package_name: SmolStr| db.intern_crate(CrateLongId::Real(package_name))) - .collect::>() -} - -fn update_files( - db: &RootDatabase, - ws: &Workspace<'_>, - target_dir: &Filesystem, - crate_ids: &[CrateId], - compiled_artifacts: CompiledArtifactByPath, - external_contracts: Option>, -) -> anyhow::Result<()> { - let profile_name = - ws.current_profile().expect("Scarb profile expected to be defined.").to_string(); - let relative_manifest_dir = Utf8PathBuf::new().join(MANIFESTS_DIR).join(profile_name); - - // relative path to manifests and abi - let base_manifests_dir = Utf8PathBuf::new().join(relative_manifest_dir).join(BASE_DIR); - let base_abis_dir = Utf8PathBuf::new().join(&base_manifests_dir).join(ABIS_DIR); - - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - - fn get_compiled_artifact_from_map<'a>( - artifacts: &'a CompiledArtifactByPath, - qualified_artifact_path: &str, - ) -> anyhow::Result<&'a CompiledArtifact> { - artifacts.get(qualified_artifact_path).context(format!( - "Contract `{qualified_artifact_path}` not found. Did you include `dojo` as a \ - dependency?", - )) - } - - let mut crate_ids = crate_ids.to_vec(); - - // World and base contracts from Dojo core. - for (qualified_path, tag) in - [(WORLD_QUALIFIED_PATH, WORLD_CONTRACT_TAG), (BASE_QUALIFIED_PATH, BASE_CONTRACT_TAG)] - { - let artifact = get_compiled_artifact_from_map(&compiled_artifacts, qualified_path)?; - let filename = naming::get_filename_from_tag(tag); - write_manifest_and_abi( - &base_manifests_dir, - &base_abis_dir, - &manifest_dir, - &mut Manifest::new( - // abi path will be written by `write_manifest` - Class { - class_hash: artifact.class_hash, - abi: None, - original_class_hash: artifact.class_hash, - tag: tag.to_string(), - }, - filename.clone(), - ), - &artifact.contract_class.abi, - )?; - save_json_artifact_file(ws, target_dir, &artifact.contract_class, &filename, tag)?; - - if let Some(debug_info) = &artifact.debug_info { - save_json_artifact_debug_file(ws, target_dir, debug_info, &filename, tag)?; - } - } - - let mut models = BTreeMap::new(); - let mut contracts = BTreeMap::new(); - - if let Some(external_contracts) = external_contracts { - let external_crate_ids = collect_external_crate_ids(db, external_contracts); - crate_ids.extend(external_crate_ids); - } - - for crate_id in crate_ids { - for module_id in db.crate_modules(crate_id).as_ref() { - let file_infos = - db.module_generated_file_infos(*module_id).unwrap_or(std::sync::Arc::new([])); - for aux_data in file_infos - .iter() - .skip(1) - .filter_map(|info| info.as_ref().map(|i| &i.aux_data)) - .filter_map(|aux_data| aux_data.as_ref().map(|aux_data| aux_data.0.as_any())) - { - if let Some(dojo_aux_data) = aux_data.downcast_ref::() { - // For the contracts, the `module_id` is the parent module of the actual - // contract. Hence, the full path of the contract must be - // reconstructed with the contract's name inside the - // `get_dojo_contract_artifacts` function. - for contract in &dojo_aux_data.contracts { - contracts.extend(get_dojo_contract_artifacts( - db, - module_id, - &naming::get_tag(&contract.namespace, &contract.name), - &compiled_artifacts, - &contract.systems, - )?); - } - - // For the models, the `struct_id` is the full path including the struct's name - // already. The `get_dojo_model_artifacts` function handles - // the reconstruction of the full path by also using lower - // case for the model's name to match the compiled artifacts of the generated - // contract. - models.extend(get_dojo_model_artifacts( - db, - &dojo_aux_data.models, - *module_id, - &compiled_artifacts, - )?); - } - - // StarknetAuxData shouldn't be required. Every dojo contract and model are starknet - // contracts under the hood. But the dojo aux data are attached to - // the parent module of the actual contract, so StarknetAuxData will - // only contain the contract's name. - } - } - } - - for model in &models { - contracts.remove(model.0.as_str()); - } - - let contracts_dir = target_dir.child(CONTRACTS_DIR); - if !contracts.is_empty() && !contracts_dir.exists() { - fs::create_dir_all(contracts_dir.path_unchecked())?; - } - - // Ensure `contracts` dir exist event if no contracts are compiled - // to avoid errors when loading manifests. - let base_contracts_dir = base_manifests_dir.join(CONTRACTS_DIR); - let base_contracts_abis_dir = base_abis_dir.join(CONTRACTS_DIR); - if !base_contracts_dir.exists() { - std::fs::create_dir_all(&base_contracts_dir)?; - } - if !base_contracts_abis_dir.exists() { - std::fs::create_dir_all(&base_contracts_abis_dir)?; - } - - for (_, (manifest, module_id, artifact)) in contracts.iter_mut() { - write_manifest_and_abi( - &base_contracts_dir, - &base_contracts_abis_dir, - &manifest_dir, - manifest, - &artifact.contract_class.abi, - )?; - - let filename = naming::get_filename_from_tag(&manifest.inner.tag); - save_expanded_source_file( - ws, - *module_id, - db, - &contracts_dir, - &filename, - &manifest.inner.tag, - )?; - save_json_artifact_file( - ws, - &contracts_dir, - &artifact.contract_class, - &filename, - &manifest.inner.tag, - )?; - - if let Some(debug_info) = &artifact.debug_info { - save_json_artifact_debug_file( - ws, - &contracts_dir, - debug_info, - &filename, - &manifest.inner.tag, - )?; - } - } - - let models_dir = target_dir.child(MODELS_DIR); - if !models.is_empty() && !models_dir.exists() { - fs::create_dir_all(models_dir.path_unchecked())?; - } - - // Ensure `models` dir exist event if no models are compiled - // to avoid errors when loading manifests. - let base_models_dir = base_manifests_dir.join(MODELS_DIR); - let base_models_abis_dir = base_abis_dir.join(MODELS_DIR); - if !base_models_dir.exists() { - std::fs::create_dir_all(&base_models_dir)?; - } - if !base_models_abis_dir.exists() { - std::fs::create_dir_all(&base_models_abis_dir)?; - } - - for (_, (manifest, module_id, artifact)) in models.iter_mut() { - write_manifest_and_abi( - &base_models_dir, - &base_models_abis_dir, - &manifest_dir, - manifest, - &artifact.contract_class.abi, - )?; - - let filename = naming::get_filename_from_tag(&manifest.inner.tag); - save_expanded_source_file(ws, *module_id, db, &models_dir, &filename, &manifest.inner.tag)?; - save_json_artifact_file( - ws, - &models_dir, - &artifact.contract_class, - &filename, - &manifest.inner.tag, - )?; - - if let Some(debug_info) = &artifact.debug_info { - save_json_artifact_debug_file( - ws, - &models_dir, - debug_info, - &filename, - &manifest.inner.tag, - )?; - } - } - - Ok(()) -} - -/// Finds the inline modules annotated as models in the given crate_ids and -/// returns the corresponding Models. -#[allow(clippy::type_complexity)] -fn get_dojo_model_artifacts( - db: &RootDatabase, - aux_data: &Vec, - module_id: ModuleId, - compiled_classes: &CompiledArtifactByPath, -) -> anyhow::Result, ModuleId, CompiledArtifact)>> { - let mut models = HashMap::with_capacity(aux_data.len()); - - for model in aux_data { - if let Ok(Some(ModuleItemId::Struct(struct_id))) = - db.module_item_by_name(module_id, model.name.clone().into()) - { - // Leverages the contract selector function to only snake case the model name and - // not the full path. - let contract_selector = ContractSelector(struct_id.full_path(db)); - let qualified_path = contract_selector.path_with_model_snake_case(); - let compiled_class = compiled_classes.get(&qualified_path).cloned(); - let tag = naming::get_tag(&model.namespace, &model.name); - - if let Some(artifact) = compiled_class { - let dojo_model = DojoModel { - abi: None, - tag: tag.clone(), - members: model.members.clone(), - class_hash: artifact.class_hash, - qualified_path: qualified_path.clone(), - original_class_hash: artifact.class_hash, - }; - - let manifest = Manifest::new(dojo_model, naming::get_filename_from_tag(&tag)); - models.insert(qualified_path, (manifest, module_id, artifact.clone())); - } else { - println!("Model {} not found in target.", tag.clone()); - } - } - } - - Ok(models) -} - -#[allow(clippy::type_complexity)] -fn get_dojo_contract_artifacts( - db: &RootDatabase, - module_id: &ModuleId, - tag: &str, - compiled_classes: &CompiledArtifactByPath, - systems: &[String], -) -> Result, ModuleId, CompiledArtifact)>> { - let mut result = HashMap::new(); - - if !matches!(naming::get_name_from_tag(tag).as_str(), "world" | "resource_metadata" | "base") { - // For the contracts, the `module_id` is the parent module of the actual contract. - // Hence, the full path of the contract must be reconstructed with the contract's name. - let (_, contract_name) = naming::split_tag(tag)?; - let contract_qualified_path = - format!("{}{}{}", module_id.full_path(db), CAIRO_PATH_SEPARATOR, contract_name); - - if let Some(artifact) = compiled_classes.get(&contract_qualified_path.to_string()) { - let manifest = Manifest::new( - DojoContract { - tag: tag.to_string(), - writes: vec![], - reads: vec![], - class_hash: artifact.class_hash, - original_class_hash: artifact.class_hash, - systems: systems.to_vec(), - ..Default::default() - }, - naming::get_filename_from_tag(tag), - ); - - result.insert( - contract_qualified_path.to_string(), - (manifest, *module_id, artifact.clone()), - ); - } - } - - Ok(result) -} - -fn write_manifest_and_abi( - relative_manifest_dir: &Utf8PathBuf, - relative_abis_dir: &Utf8PathBuf, - manifest_dir: &Utf8PathBuf, - manifest: &mut Manifest, - abi: &Option, -) -> anyhow::Result<()> -where - T: Serialize + DeserializeOwned + ManifestMethods, -{ - let relative_manifest_path = - relative_manifest_dir.join(manifest.manifest_name.clone()).with_extension("toml"); - let relative_abi_path = - relative_abis_dir.join(manifest.manifest_name.clone()).with_extension("json"); - - if abi.is_some() { - manifest.inner.set_abi(Some(AbiFormat::Path(relative_abi_path.clone()))); - } - - let manifest_toml = toml::to_string_pretty(&manifest)?; - let abi_json = serde_json::to_string_pretty(&abi)?; - - let full_manifest_path = manifest_dir.join(relative_manifest_path); - let full_abi_path = manifest_dir.join(&relative_abi_path); - - // Create the directory if it doesn't exist - if let Some(parent) = full_manifest_path.parent() { - if !parent.exists() { - std::fs::create_dir_all(parent)?; - } - } - - std::fs::write(full_manifest_path.clone(), manifest_toml) - .unwrap_or_else(|_| panic!("Unable to write manifest file to path: {full_manifest_path}")); - - if abi.is_some() { - // Create the directory if it doesn't exist - if let Some(parent) = full_abi_path.parent() { - if !parent.exists() { - std::fs::create_dir_all(parent)?; - } - } - - std::fs::write(full_abi_path.clone(), abi_json) - .unwrap_or_else(|_| panic!("Unable to write abi file to path: {full_abi_path}")); - } - Ok(()) -} - -fn save_expanded_source_file( - ws: &Workspace<'_>, - module_id: ModuleId, - db: &RootDatabase, - contract_dir: &Filesystem, - contract_basename: &str, - contract_tag: &str, -) -> anyhow::Result<()> { - if let Ok(files) = db.module_files(module_id) { - let contract_name = naming::get_name_from_tag(contract_tag); - - // search among all the module files (real and virtual), the one named with - // the contract/model name. This is the file containing the Cairo code generated - // from Dojo plugins. - let res = files.iter().filter(|f| f.file_name(db).eq(&contract_name)).collect::>(); - - let file_id = if res.is_empty() { - // if there is no virtual file with the name of the contract/model, just use the main - // module file - match db.module_main_file(module_id) { - Ok(f) => f, - Err(_) => return Err(anyhow!("failed to get source file: {contract_tag}")), - } - } else { - *res[0] - }; - - if let Some(file_content) = db.file_content(file_id) { - let src_file_name = format!("{contract_basename}.cairo"); - - let mut file = - contract_dir.open_rw(src_file_name.clone(), "source file", ws.config())?; - file.write(format_string(db, file_content.to_string()).as_bytes()) - .with_context(|| format!("failed to serialize contract source: {contract_tag}"))?; - } else { - return Err(anyhow!("failed to get source file content: {contract_tag}")); - } - } else { - return Err(anyhow!("failed to get source file: {contract_tag}")); - } - - Ok(()) -} - -fn save_json_artifact_file( - ws: &Workspace<'_>, - contract_dir: &Filesystem, - contract_class: &ContractClass, - contract_basename: &str, - contract_tag: &str, -) -> anyhow::Result<()> { - let mut file = - contract_dir.open_rw(format!("{contract_basename}.json"), "class file", ws.config())?; - serde_json::to_writer_pretty(file.deref_mut(), &contract_class) - .with_context(|| format!("failed to serialize contract artifact: {contract_tag}"))?; - Ok(()) -} - -fn save_json_artifact_debug_file( - ws: &Workspace<'_>, - contract_dir: &Filesystem, - debug_info: &SierraToCairoDebugInfo, - contract_basename: &str, - contract_tag: &str, -) -> anyhow::Result<()> { - let mut file = contract_dir.open_rw( - format!("{contract_basename}.debug.json"), - "class file", - ws.config(), - )?; - - serde_json::to_writer_pretty(file.deref_mut(), debug_info) - .with_context(|| format!("failed to serialize contract debug artifact: {contract_tag}"))?; - - Ok(()) -} diff --git a/crates/dojo-lang/src/compiler_test.rs b/crates/dojo-lang/src/compiler_test.rs deleted file mode 100644 index 55d99f3908..0000000000 --- a/crates/dojo-lang/src/compiler_test.rs +++ /dev/null @@ -1,63 +0,0 @@ -use dojo_test_utils::compiler::build_test_config; -use scarb::compiler::Profile; -use scarb::core::{PackageName, TargetKind}; -use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; - -use crate::compiler::ContractSelector; -use crate::scarb_internal; - -// Ignored as scarb takes too much time to compile in debug mode. -// It's anyway run in the CI in the `test` job. -#[test] -#[ignore] -fn test_compiler_cairo_features() { - let config = - build_test_config("./src/manifest_test_data/compiler_cairo/Scarb.toml", Profile::DEV) - .unwrap(); - - let features_opts = - FeaturesOpts { features: FeaturesSelector::AllFeatures, no_default_features: false }; - let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let packages: Vec = ws.members().map(|p| p.id).collect(); - - let compile_info = scarb_internal::compile_workspace( - &config, - CompileOpts { - include_target_names: vec![], - include_target_kinds: vec![], - exclude_target_kinds: vec![TargetKind::TEST], - features: features_opts, - }, - packages, - ) - .unwrap(); - - assert_eq!(compile_info.compile_error_units, Vec::::default()); -} - -#[test] -fn test_package() { - let selector = ContractSelector("my_package::my_contract".to_string()); - assert_eq!(selector.package(), PackageName::new("my_package")); - - let selector_no_separator = ContractSelector("my_package".to_string()); - assert_eq!(selector_no_separator.package(), PackageName::new("my_package")); -} - -#[test] -fn test_path_with_model_snake_case() { - let selector = ContractSelector("my_package::MyContract".to_string()); - assert_eq!(selector.path_with_model_snake_case(), "my_package::my_contract"); - - let selector_multiple_segments = - ContractSelector("my_package::sub_package::MyContract".to_string()); - assert_eq!( - selector_multiple_segments.path_with_model_snake_case(), - "my_package::sub_package::my_contract" - ); - - // In snake case, erc20 should be erc_20. This test ensures that the path is converted to snake - // case only for the model's name. - let selector_erc20 = ContractSelector("my_package::erc20::Token".to_string()); - assert_eq!(selector_erc20.path_with_model_snake_case(), "my_package::erc20::token"); -} diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs deleted file mode 100644 index 1617d34ddf..0000000000 --- a/crates/dojo-lang/src/contract.rs +++ /dev/null @@ -1,734 +0,0 @@ -use std::collections::HashMap; - -use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; -use cairo_lang_defs::plugin::{ - DynGeneratedFileAuxData, MacroPluginMetadata, PluginDiagnostic, PluginGeneratedFile, - PluginResult, -}; -use cairo_lang_diagnostics::Severity; -use cairo_lang_plugins::plugins::HasItemsInCfgEx; -use cairo_lang_syntax::node::ast::{ - ArgClause, Expr, MaybeModuleBody, OptionArgListParenthesized, OptionReturnTypeClause, -}; -use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::helpers::QueryAttrs; -use cairo_lang_syntax::node::{ast, ids, Terminal, TypedStablePtr, TypedSyntaxNode}; -use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; -use dojo_types::system::Dependency; -use dojo_world::config::NamespaceConfig; -use dojo_world::contracts::naming; - -use crate::plugin::{ContractAuxData, DojoAuxData, DOJO_CONTRACT_ATTR}; -use crate::syntax::world_param::{self, WorldParamInjectionKind}; -use crate::syntax::{self_param, utils as syntax_utils}; - -const DOJO_INIT_FN: &str = "dojo_init"; -const CONTRACT_NAMESPACE: &str = "namespace"; -const CONTRACT_NOMAPPING: &str = "nomapping"; - -#[derive(Debug, Clone, Default)] -pub struct ContractParameters { - namespace: Option, - nomapping: bool, -} - -#[derive(Debug)] -pub struct DojoContract { - diagnostics: Vec, - dependencies: HashMap, - systems: Vec, -} - -impl DojoContract { - pub fn from_module( - db: &dyn SyntaxGroup, - module_ast: &ast::ItemModule, - namespace_config: &NamespaceConfig, - metadata: &MacroPluginMetadata<'_>, - ) -> PluginResult { - let name = module_ast.name(db).text(db); - - let mut diagnostics = vec![]; - let parameters = get_parameters(db, module_ast, &mut diagnostics); - - let mut contract = - DojoContract { diagnostics, dependencies: HashMap::new(), systems: vec![] }; - - let mut has_event = false; - let mut has_storage = false; - let mut has_init = false; - - let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); - - let contract_namespace = if parameters.nomapping { - unmapped_namespace - } else { - // Maps namespace from the tag to ensure higher precision on matching namespace - // mappings. - namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &name)) - }; - - for (id, value) in [("name", &name.to_string()), ("namespace", &contract_namespace)] { - if !NamespaceConfig::is_name_valid(value) { - return PluginResult { - code: None, - diagnostics: vec![PluginDiagnostic { - stable_ptr: module_ast.stable_ptr().0, - message: format!( - "The contract {id} '{value}' can only contain characters (a-z/A-Z), \ - digits (0-9) and underscore (_)." - ), - severity: Severity::Error, - }], - remove_original_item: false, - }; - } - } - - let contract_tag = naming::get_tag(&contract_namespace, &name); - let contract_name_hash = naming::compute_bytearray_hash(&name); - let contract_namespace_hash = naming::compute_bytearray_hash(&contract_namespace); - let contract_selector = - naming::compute_selector_from_hashes(contract_namespace_hash, contract_name_hash); - - if let MaybeModuleBody::Some(body) = module_ast.body(db) { - let mut body_nodes: Vec<_> = body - .iter_items_in_cfg(db, metadata.cfg_set) - .flat_map(|el| { - if let ast::ModuleItem::Enum(ref enum_ast) = el { - if enum_ast.name(db).text(db).to_string() == "Event" { - has_event = true; - return contract.merge_event(db, enum_ast.clone()); - } - } else if let ast::ModuleItem::Struct(ref struct_ast) = el { - if struct_ast.name(db).text(db).to_string() == "Storage" { - has_storage = true; - return contract.merge_storage(db, struct_ast.clone()); - } - } else if let ast::ModuleItem::Impl(ref impl_ast) = el { - // If an implementation is not targetting the ContractState, - // the auto injection of self and world is not applied. - let trait_path = impl_ast.trait_path(db).node.get_text(db); - if trait_path.contains("") { - return contract.rewrite_impl(db, impl_ast.clone(), metadata); - } - } else if let ast::ModuleItem::FreeFunction(ref fn_ast) = el { - let fn_decl = fn_ast.declaration(db); - let fn_name = fn_decl.name(db).text(db); - - if fn_name == DOJO_INIT_FN { - has_init = true; - return contract.handle_init_fn(db, fn_ast); - } - } - - vec![RewriteNode::Copied(el.as_syntax_node())] - }) - .collect(); - - if !has_init { - let node = RewriteNode::interpolate_patched( - " - #[starknet::interface] - pub trait IDojoInit { - fn $init_name$(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn $init_name$(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!(\"Only the world can init contract `{}`, but caller \ - is `{:?}`\", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - ", - &UnorderedHashMap::from([( - "init_name".to_string(), - RewriteNode::Text(DOJO_INIT_FN.to_string()), - )]), - ); - body_nodes.append(&mut vec![node]); - } - - if !has_event { - body_nodes.append(&mut contract.create_event()) - } - - if !has_storage { - body_nodes.append(&mut contract.create_storage()) - } - - let mut builder = PatchBuilder::new(db, module_ast); - builder.add_modified(RewriteNode::Mapped { - node: Box::new(RewriteNode::interpolate_patched( - " - #[starknet::contract] - pub mod $name$ { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, \ - StoragePointerWriteAccess - }; - - component!(path: dojo::contract::upgradeable::upgradeable, storage: \ - upgradeable, event: UpgradeableEvent); - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - \"$name$\" - } - - fn namespace(self: @ContractState) -> ByteArray { - \"$contract_namespace$\" - } - - fn tag(self: @ContractState) -> ByteArray { - \"$contract_tag$\" - } - - fn name_hash(self: @ContractState) -> felt252 { - $contract_name_hash$ - } - - fn namespace_hash(self: @ContractState) -> felt252 { - $contract_namespace_hash$ - } - - fn selector(self: @ContractState) -> felt252 { - $contract_selector$ - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = \ - dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - $body$ - } - ", - &UnorderedHashMap::from([ - ("name".to_string(), RewriteNode::Text(name.to_string())), - ("body".to_string(), RewriteNode::new_modified(body_nodes)), - ( - "contract_namespace".to_string(), - RewriteNode::Text(contract_namespace.clone()), - ), - ( - "contract_name_hash".to_string(), - RewriteNode::Text(contract_name_hash.to_string()), - ), - ( - "contract_namespace_hash".to_string(), - RewriteNode::Text(contract_namespace_hash.to_string()), - ), - ( - "contract_selector".to_string(), - RewriteNode::Text(contract_selector.to_string()), - ), - ("contract_tag".to_string(), RewriteNode::Text(contract_tag)), - ]), - )), - origin: module_ast.as_syntax_node().span_without_trivia(db), - }); - - let (code, code_mappings) = builder.build(); - - return PluginResult { - code: Some(PluginGeneratedFile { - name: name.clone(), - content: code, - aux_data: Some(DynGeneratedFileAuxData::new(DojoAuxData { - models: vec![], - contracts: vec![ContractAuxData { - name, - namespace: contract_namespace.clone(), - dependencies: contract.dependencies.values().cloned().collect(), - systems: contract.systems.clone(), - }], - events: vec![], - })), - code_mappings, - }), - diagnostics: contract.diagnostics, - remove_original_item: true, - }; - } - - PluginResult::default() - } - - fn handle_init_fn( - &mut self, - db: &dyn SyntaxGroup, - fn_ast: &ast::FunctionWithBody, - ) -> Vec { - let fn_decl = fn_ast.declaration(db); - - if let OptionReturnTypeClause::ReturnTypeClause(_) = fn_decl.signature(db).ret_ty(db) { - self.diagnostics.push(PluginDiagnostic { - stable_ptr: fn_ast.stable_ptr().untyped(), - message: "The dojo_init function cannot have a return type.".to_string(), - severity: Severity::Error, - }); - } - - let (params_str, was_world_injected) = self.rewrite_parameters( - db, - fn_decl.signature(db).parameters(db), - fn_ast.stable_ptr().untyped(), - ); - - let trait_node = RewriteNode::interpolate_patched( - "#[starknet::interface] - pub trait IDojoInit { - fn $init_name$($params_str$); - } - ", - &UnorderedHashMap::from([ - ("init_name".to_string(), RewriteNode::Text(DOJO_INIT_FN.to_string())), - ("params_str".to_string(), RewriteNode::Text(params_str.clone())), - ]), - ); - - let impl_node = RewriteNode::Text( - " - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - " - .to_string(), - ); - - let declaration_node = RewriteNode::Mapped { - node: Box::new(RewriteNode::Text(format!("fn {}({}) {{", DOJO_INIT_FN, params_str))), - origin: fn_ast.declaration(db).as_syntax_node().span_without_trivia(db), - }; - - let world_line_node = if was_world_injected { - RewriteNode::Text("let world = self.world_dispatcher.read();".to_string()) - } else { - RewriteNode::empty() - }; - - let assert_world_caller_node = RewriteNode::Text( - "if starknet::get_caller_address() != self.world().contract_address { \ - core::panics::panic_with_byte_array(@format!(\"Only the world can init contract \ - `{}`, but caller is `{:?}`\", self.tag(), starknet::get_caller_address())); }" - .to_string(), - ); - - let func_nodes = fn_ast - .body(db) - .statements(db) - .elements(db) - .iter() - .map(|e| RewriteNode::Mapped { - node: Box::new(RewriteNode::from(e.as_syntax_node())), - origin: e.as_syntax_node().span_without_trivia(db), - }) - .collect::>(); - - let mut nodes = vec![ - trait_node, - impl_node, - declaration_node, - world_line_node, - assert_world_caller_node, - ]; - nodes.extend(func_nodes); - // Close the init function + close the impl block. - nodes.push(RewriteNode::Text("}\n}".to_string())); - - nodes - } - - pub fn merge_event( - &mut self, - db: &dyn SyntaxGroup, - enum_ast: ast::ItemEnum, - ) -> Vec { - let mut rewrite_nodes = vec![]; - - let elements = enum_ast.variants(db).elements(db); - - let variants = elements.iter().map(|e| e.as_syntax_node().get_text(db)).collect::>(); - let variants = variants.join(",\n"); - - rewrite_nodes.push(RewriteNode::interpolate_patched( - " - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - $variants$ - } - ", - &UnorderedHashMap::from([("variants".to_string(), RewriteNode::Text(variants))]), - )); - rewrite_nodes - } - - pub fn create_event(&mut self) -> Vec { - vec![RewriteNode::Text( - " - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - " - .to_string(), - )] - } - - pub fn merge_storage( - &mut self, - db: &dyn SyntaxGroup, - struct_ast: ast::ItemStruct, - ) -> Vec { - let mut rewrite_nodes = vec![]; - - let elements = struct_ast.members(db).elements(db); - - let members = elements.iter().map(|e| e.as_syntax_node().get_text(db)).collect::>(); - let members = members.join(",\n"); - - rewrite_nodes.push(RewriteNode::interpolate_patched( - " - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::contract::upgradeable::upgradeable::Storage, - $members$ - } - ", - &UnorderedHashMap::from([("members".to_string(), RewriteNode::Text(members))]), - )); - rewrite_nodes - } - - pub fn create_storage(&mut self) -> Vec { - vec![RewriteNode::Text( - " - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::contract::upgradeable::upgradeable::Storage, - } - " - .to_string(), - )] - } - - /// Rewrites parameter list by: - /// * adding `self` parameter based on the `world` parameter mutability. If `world` is not - /// provided, a `View` is assumed. - /// * removing `world` if present as first parameter, as it will be read from the first - /// function statement. - /// - /// Reports an error in case of: - /// * `self` used explicitly, - /// * multiple world parameters, - /// * the `world` parameter is not the first parameter and named 'world'. - /// - /// Returns - /// * the list of parameters in a String. - /// * true if the world has to be injected (found as the first param). - pub fn rewrite_parameters( - &mut self, - db: &dyn SyntaxGroup, - param_list: ast::ParamList, - fn_diagnostic_item: ids::SyntaxStablePtrId, - ) -> (String, bool) { - let is_self_used = self_param::check_parameter(db, ¶m_list); - - let world_injection = world_param::parse_world_injection( - db, - param_list.clone(), - fn_diagnostic_item, - &mut self.diagnostics, - ); - - if is_self_used && world_injection != WorldParamInjectionKind::None { - self.diagnostics.push(PluginDiagnostic { - stable_ptr: fn_diagnostic_item, - message: "You cannot use `self` and `world` parameters together.".to_string(), - severity: Severity::Error, - }); - } - - let mut params = param_list - .elements(db) - .iter() - .filter_map(|param| { - let (name, _, param_type) = syntax_utils::get_parameter_info(db, param.clone()); - - // If the param is `IWorldDispatcher`, we don't need to keep it in the param list - // as it is flatten in the first statement. - if world_param::is_world_param(&name, ¶m_type) { - None - } else { - Some(param.as_syntax_node().get_text(db)) - } - }) - .collect::>(); - - match world_injection { - WorldParamInjectionKind::None => { - if !is_self_used { - params.insert(0, "self: @ContractState".to_string()); - } - } - WorldParamInjectionKind::View => { - params.insert(0, "self: @ContractState".to_string()); - } - WorldParamInjectionKind::External => { - params.insert(0, "ref self: ContractState".to_string()); - } - } - - (params.join(", "), world_injection != WorldParamInjectionKind::None) - } - - /// Rewrites function declaration by: - /// * adding `self` parameter if missing, - /// * removing `world` if present as first parameter (self excluded), - /// * adding `let world = self.world_dispatcher.read();` statement at the beginning of the - /// function to restore the removed `world` parameter. - /// * if `has_generate_trait` is true, the implementation containing the function has the - /// #[generate_trait] attribute. - pub fn rewrite_function( - &mut self, - db: &dyn SyntaxGroup, - fn_ast: ast::FunctionWithBody, - has_generate_trait: bool, - ) -> Vec { - let fn_name = fn_ast.declaration(db).name(db).text(db); - let return_type = - fn_ast.declaration(db).signature(db).ret_ty(db).as_syntax_node().get_text(db); - - // Consider the function as a system if no return type is specified. - if return_type.is_empty() { - self.systems.push(fn_name.to_string()); - } - - let (params_str, was_world_injected) = self.rewrite_parameters( - db, - fn_ast.declaration(db).signature(db).parameters(db), - fn_ast.stable_ptr().untyped(), - ); - - let declaration_node = RewriteNode::Mapped { - node: Box::new(RewriteNode::Text(format!( - "fn {}({}) {} {{", - fn_name, params_str, return_type - ))), - origin: fn_ast.declaration(db).as_syntax_node().span_without_trivia(db), - }; - - let world_line_node = if was_world_injected { - RewriteNode::Text("let world = self.world_dispatcher.read();".to_string()) - } else { - RewriteNode::empty() - }; - - let func_nodes = fn_ast - .body(db) - .statements(db) - .elements(db) - .iter() - .map(|e| RewriteNode::Mapped { - node: Box::new(RewriteNode::from(e.as_syntax_node())), - origin: e.as_syntax_node().span_without_trivia(db), - }) - .collect::>(); - - if has_generate_trait && was_world_injected { - self.diagnostics.push(PluginDiagnostic { - stable_ptr: fn_ast.stable_ptr().untyped(), - message: "You cannot use `world` and `#[generate_trait]` together. Use `self` \ - instead." - .to_string(), - severity: Severity::Error, - }); - } - - let mut nodes = vec![declaration_node, world_line_node]; - nodes.extend(func_nodes); - nodes.push(RewriteNode::Text("}".to_string())); - - nodes - } - - /// Rewrites all the functions of a Impl block. - fn rewrite_impl( - &mut self, - db: &dyn SyntaxGroup, - impl_ast: ast::ItemImpl, - metadata: &MacroPluginMetadata<'_>, - ) -> Vec { - let generate_attrs = impl_ast.attributes(db).query_attr(db, "generate_trait"); - let has_generate_trait = !generate_attrs.is_empty(); - - if let ast::MaybeImplBody::Some(body) = impl_ast.body(db) { - // We shouldn't have generic param in the case of contract's endpoints. - let impl_node = RewriteNode::Mapped { - node: Box::new(RewriteNode::Text(format!( - "{} impl {} of {} {{", - impl_ast.attributes(db).as_syntax_node().get_text(db), - impl_ast.name(db).as_syntax_node().get_text(db), - impl_ast.trait_path(db).as_syntax_node().get_text(db), - ))), - origin: impl_ast.as_syntax_node().span_without_trivia(db), - }; - - let body_nodes: Vec<_> = body - .iter_items_in_cfg(db, metadata.cfg_set) - .flat_map(|el| { - if let ast::ImplItem::Function(ref fn_ast) = el { - return self.rewrite_function(db, fn_ast.clone(), has_generate_trait); - } - vec![RewriteNode::Copied(el.as_syntax_node())] - }) - .collect(); - - let body_node = RewriteNode::Mapped { - node: Box::new(RewriteNode::interpolate_patched( - "$body$", - &UnorderedHashMap::from([( - "body".to_string(), - RewriteNode::new_modified(body_nodes), - )]), - )), - origin: impl_ast.as_syntax_node().span_without_trivia(db), - }; - - return vec![impl_node, body_node, RewriteNode::Text("}".to_string())]; - } - - vec![RewriteNode::Copied(impl_ast.as_syntax_node())] - } -} - -/// Get the contract namespace from the `Expr` parameter. -fn get_contract_namespace( - db: &dyn SyntaxGroup, - arg_value: Expr, - diagnostics: &mut Vec, -) -> Option { - match arg_value { - Expr::ShortString(ss) => Some(ss.string_value(db).unwrap()), - Expr::String(s) => Some(s.string_value(db).unwrap()), - _ => { - diagnostics.push(PluginDiagnostic { - message: format!( - "The argument '{}' of dojo::contract must be a string", - CONTRACT_NAMESPACE - ), - stable_ptr: arg_value.stable_ptr().untyped(), - severity: Severity::Error, - }); - Option::None - } - } -} - -/// Get parameters of the dojo::contract attribute. -/// -/// Parameters: -/// * db: The semantic database. -/// * module_ast: The AST of the contract module. -/// * diagnostics: vector of compiler diagnostics. -/// -/// Returns: -/// * A [`ContractParameters`] object containing all the dojo::contract parameters with their -/// default values if not set in the code. -fn get_parameters( - db: &dyn SyntaxGroup, - module_ast: &ast::ItemModule, - diagnostics: &mut Vec, -) -> ContractParameters { - let mut parameters = ContractParameters::default(); - let mut processed_args: HashMap = HashMap::new(); - - if let OptionArgListParenthesized::ArgListParenthesized(arguments) = - module_ast.attributes(db).query_attr(db, DOJO_CONTRACT_ATTR).first().unwrap().arguments(db) - { - arguments.arguments(db).elements(db).iter().for_each(|a| match a.arg_clause(db) { - ArgClause::Named(x) => { - let arg_name = x.name(db).text(db).to_string(); - let arg_value = x.value(db); - - if processed_args.contains_key(&arg_name) { - diagnostics.push(PluginDiagnostic { - message: format!("Too many '{}' attributes for dojo::contract", arg_name), - stable_ptr: module_ast.stable_ptr().untyped(), - severity: Severity::Error, - }); - } else { - processed_args.insert(arg_name.clone(), true); - - match arg_name.as_str() { - CONTRACT_NAMESPACE => { - parameters.namespace = - get_contract_namespace(db, arg_value, diagnostics); - } - CONTRACT_NOMAPPING => { - parameters.nomapping = true; - } - _ => { - diagnostics.push(PluginDiagnostic { - message: format!( - "Unexpected argument '{}' for dojo::contract", - arg_name - ), - stable_ptr: x.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - } - } - } - ArgClause::Unnamed(arg) => { - let arg_name = arg.value(db).as_syntax_node().get_text(db); - - diagnostics.push(PluginDiagnostic { - message: format!("Unexpected argument '{}' for dojo::contract", arg_name), - stable_ptr: arg.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - ArgClause::FieldInitShorthand(x) => { - diagnostics.push(PluginDiagnostic { - message: format!( - "Unexpected argument '{}' for dojo::contract", - x.name(db).name(db).text(db).to_string() - ), - stable_ptr: x.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - }) - } - - parameters -} diff --git a/crates/dojo-lang/src/event.rs b/crates/dojo-lang/src/event.rs deleted file mode 100644 index 4058d93759..0000000000 --- a/crates/dojo-lang/src/event.rs +++ /dev/null @@ -1,192 +0,0 @@ -use cairo_lang_defs::patcher::{ModifiedNode, RewriteNode}; -use cairo_lang_defs::plugin::PluginDiagnostic; -use cairo_lang_starknet::plugin::aux_data::StarkNetEventAuxData; -use cairo_lang_starknet::plugin::consts::{ - EVENT_TRAIT, EVENT_TYPE_NAME, KEY_ATTR, NESTED_ATTR, SERDE_ATTR, -}; -use cairo_lang_starknet::plugin::events::EventData; -use cairo_lang_starknet_classes::abi::EventFieldKind; -use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::helpers::QueryAttrs; -use cairo_lang_syntax::node::{ast, Terminal, TypedStablePtr, TypedSyntaxNode}; -use indoc::formatdoc; - -use crate::plugin::DojoAuxData; - -// A custom implementation of the starknet::Event derivation path. -// We append the event selector directly within the append_keys_and_data function. -// Without the need of the enum for all event variants. - -// https://github.com/starkware-libs/cairo/blob/main/crates/cairo-lang-starknet/src/plugin/derive/event.rs - -pub fn handle_event_struct( - db: &dyn SyntaxGroup, - aux_data: &mut DojoAuxData, - struct_ast: ast::ItemStruct, -) -> (RewriteNode, Vec) { - let mut diagnostics = vec![]; - - // TODO(spapini): Support generics. - let generic_params = struct_ast.generic_params(db); - match generic_params { - ast::OptionWrappedGenericParamList::Empty(_) => {} - _ => { - diagnostics.push(PluginDiagnostic::error( - generic_params.stable_ptr().untyped(), - format!("{EVENT_TYPE_NAME} structs with generic arguments are unsupported"), - )); - } - } - - // Generate append_keys_and_data() code. - let mut append_members = vec![]; - let mut deserialize_members = vec![]; - let mut ctor = vec![]; - let mut members = vec![]; - for member in struct_ast.members(db).elements(db) { - let member_name = RewriteNode::new_trimmed(member.name(db).as_syntax_node()); - let member_kind = - get_field_kind_for_member(db, &mut diagnostics, &member, EventFieldKind::DataSerde); - members.push((member.name(db).text(db), member_kind)); - - let member_for_append = RewriteNode::interpolate_patched( - "self.$member_name$", - &[("member_name".to_string(), member_name.clone())].into(), - ); - let append_member = append_field(member_kind, member_for_append); - let deserialize_member = deserialize_field(member_kind, member_name.clone()); - append_members.push(append_member); - deserialize_members.push(deserialize_member); - ctor.push(RewriteNode::interpolate_patched( - "$member_name$, ", - &[("member_name".to_string(), member_name)].into(), - )); - } - let event_data = EventData::Struct { members }; - aux_data.events.push(StarkNetEventAuxData { event_data }); - - let append_members = RewriteNode::Modified(ModifiedNode { children: Some(append_members) }); - let deserialize_members = - RewriteNode::Modified(ModifiedNode { children: Some(deserialize_members) }); - let ctor = RewriteNode::Modified(ModifiedNode { children: Some(ctor) }); - - // Add an implementation for `Event`. - let struct_name = RewriteNode::new_trimmed(struct_ast.name(db).as_syntax_node()); - ( - // Append the event selector using the struct_name for the selector - // and then append the members. - RewriteNode::interpolate_patched( - &formatdoc!( - " - impl $struct_name$IsEvent of {EVENT_TRAIT}<$struct_name$> {{ - fn append_keys_and_data( - self: @$struct_name$, ref keys: Array, ref data: Array - ) {{ - core::array::ArrayTrait::append(ref keys, \ - dojo::model::Model::<$struct_name$>::selector()); - $append_members$ - }} - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option<$struct_name$> {{$deserialize_members$ - Option::Some($struct_name$ {{$ctor$}}) - }} - }} - " - ), - &[ - ("struct_name".to_string(), struct_name), - ("append_members".to_string(), append_members), - ("deserialize_members".to_string(), deserialize_members), - ("ctor".to_string(), ctor), - ] - .into(), - ), - diagnostics, - ) -} - -/// Generates code to emit an event for a field -fn append_field(member_kind: EventFieldKind, field: RewriteNode) -> RewriteNode { - match member_kind { - EventFieldKind::Nested | EventFieldKind::Flat => RewriteNode::interpolate_patched( - &format!( - " - {EVENT_TRAIT}::append_keys_and_data( - $field$, ref keys, ref data - );" - ), - &[("field".to_string(), field)].into(), - ), - EventFieldKind::KeySerde => RewriteNode::interpolate_patched( - " - core::serde::Serde::serialize($field$, ref keys);", - &[("field".to_string(), field)].into(), - ), - EventFieldKind::DataSerde => RewriteNode::interpolate_patched( - " - core::serde::Serde::serialize($field$, ref data);", - &[("field".to_string(), field)].into(), - ), - } -} - -fn deserialize_field(member_kind: EventFieldKind, member_name: RewriteNode) -> RewriteNode { - RewriteNode::interpolate_patched( - match member_kind { - EventFieldKind::Nested | EventFieldKind::Flat => { - " - let $member_name$ = starknet::Event::deserialize( - ref keys, ref data - )?;" - } - EventFieldKind::KeySerde => { - " - let $member_name$ = core::serde::Serde::deserialize( - ref keys - )?;" - } - EventFieldKind::DataSerde => { - " - let $member_name$ = core::serde::Serde::deserialize( - ref data - )?;" - } - }, - &[("member_name".to_string(), member_name)].into(), - ) -} - -/// Retrieves the field kind for a given enum variant, -/// indicating how the field should be serialized. -/// See [EventFieldKind]. -fn get_field_kind_for_member( - db: &dyn SyntaxGroup, - diagnostics: &mut Vec, - member: &ast::Member, - default: EventFieldKind, -) -> EventFieldKind { - let is_nested = member.has_attr(db, NESTED_ATTR); - let is_key = member.has_attr(db, KEY_ATTR); - let is_serde = member.has_attr(db, SERDE_ATTR); - - // Currently, nested fields are unsupported. - if is_nested { - diagnostics.push(PluginDiagnostic::error( - member.stable_ptr().untyped(), - "Nested event fields are currently unsupported".to_string(), - )); - } - // Currently, serde fields are unsupported. - if is_serde { - diagnostics.push(PluginDiagnostic::error( - member.stable_ptr().untyped(), - "Serde event fields are currently unsupported".to_string(), - )); - } - - if is_key { - return EventFieldKind::KeySerde; - } - default -} diff --git a/crates/dojo-lang/src/lib.rs b/crates/dojo-lang/src/lib.rs deleted file mode 100644 index 234fe5eb3a..0000000000 --- a/crates/dojo-lang/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![warn(unused_crate_dependencies)] - -//! Dojo capabilities and utilities on top of Starknet. -//! -//! Dojo is a full stack toolchain for developing onchain games in Cairo. -//! -//! Learn more at [dojoengine.gg](http://dojoengine.gg). -pub mod compiler; -pub mod contract; -pub mod event; -pub mod inline_macros; -pub mod interface; -pub mod introspect; -pub mod model; -pub mod plugin; -pub mod print; -pub mod semantics; -pub mod syntax; -pub mod utils; -pub(crate) mod version; - -// Copy of non pub functions from scarb + extension. -// Also used by `sozo`. -pub mod scarb_internal; diff --git a/crates/dojo-lang/src/manifest_test_data/cairo_v240 b/crates/dojo-lang/src/manifest_test_data/cairo_v240 deleted file mode 100644 index acedda39ab..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/cairo_v240 +++ /dev/null @@ -1,993 +0,0 @@ -//! > Test for cairo v2.4.0 compatibility - -//! > test_runner_name -test_compiler_cairo_v240 - -//! > expected_manifest_file -{ - "world": { - "name": "dojo::world::world", - "address": null, - "class_hash": "0x2206663eed57fb406a3557c3dbe650451af6f271af4acdcb5cb2e2279249f66", - "abi": [ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::IWorld" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_id", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "model", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "model", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world::OwnerUpdated", - "kind": "nested" - } - ] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "base": { - "name": "dojo::base::base", - "class_hash": "0x794d5ed2f7eb970f92e0ed9be8f73bbbdf18f7db2a9a296fa12c2d9c33e6ab3", - "abi": [ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::base::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } - ] - }, - "resource_metadata": { - "name": "dojo::model::resource_metadata::resource_metadata", - "address": null, - "class_hash": "0x6a2f06cde4aad60e0b6dd595edebe8dca1fbefe5b36cfc2f46a1d1159757df9", - "abi": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, core::array::Span::)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::>" - }, - { - "name": "Array", - "type": "core::integer::u32" - } - ] - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "dojo::model::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "event", - "name": "dojo::model::resource_metadata::resource_metadata::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "contracts": [ - { - "name": "cairo_v240::cairo_v240", - "address": null, - "class_hash": "0x6517f8b97f269ae354fabcafe7428eda4ce60efbecc55dad8ac662144b8f469", - "abi": [ - { - "type": "event", - "name": "cairo_v240::cairo_v240::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - } - ], - "models": [] -} diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/.gitignore b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/.gitignore deleted file mode 100644 index eb5a316cbd..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml deleted file mode 100644 index 5f63e29985..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "compiler_cairo" -version = "0.1.0" -edition = "2024_07" -cairo-version = "2.7.0" - -# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html - -[cairo] -sierra-replace-ids = true - -[dependencies] -dojo = { path = "../../../../dojo-core" } - -[[target.dojo]] -build-external-contracts = [ ] diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/dojo_dev.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/dojo_dev.toml deleted file mode 100644 index e3776ae7a4..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/dojo_dev.toml +++ /dev/null @@ -1,10 +0,0 @@ -[world] -description = "Cairo compiler features" -name = "compiler_cairo_features" -seed = "compiler_cairo_features" - -[namespace] -default = "ccf" - -[env] -rpc_url = "http://localhost:5050/" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json deleted file mode 100644 index 4800464226..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::base_contract::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "flat" - } - ] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json deleted file mode 100644 index 8553809311..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json +++ /dev/null @@ -1,1231 +0,0 @@ -[ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::world_contract::IWorld" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::model::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "enum", - "name": "dojo::world::world_contract::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Contract", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Namespace", - "type": "()" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::world_contract::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::world_contract::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::world::update::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::world::update::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::world::update::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::update::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::world::update::ProgramOutput" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "ConfigImpl", - "interface_name": "dojo::world::config::IConfig" - }, - { - "type": "interface", - "name": "dojo::world::config::IConfig", - "items": [ - { - "type": "function", - "name": "set_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_facts_registry", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_facts_registry", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::Event", - "kind": "enum", - "variants": [ - { - "name": "DifferProgramHashUpdate", - "type": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "nested" - }, - { - "name": "FactsRegistryUpdate", - "type": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StateUpdated", - "kind": "struct", - "members": [ - { - "name": "da_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world_contract::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::world::config::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world_contract::world::StateUpdated", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml deleted file mode 100644 index 44b3746b00..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -original_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -abi = "manifests/dev/base/abis/dojo-base.json" -tag = "dojo-base" -manifest_name = "dojo-base" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml deleted file mode 100644 index 4dfc391ebd..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -original_class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -abi = "manifests/dev/base/abis/dojo-world.json" -tag = "dojo-world" -manifest_name = "dojo-world" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo deleted file mode 100644 index 0235b496fa..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo +++ /dev/null @@ -1,57 +0,0 @@ -//! Cairo 2.4.0 feature testing. -#[starknet::contract] -mod cairo_v240 { - use core::fmt::Formatter; - - #[storage] - struct Storage {} - - fn byte_array(self: @ContractState) -> ByteArray { - let mut ba: ByteArray = ""; - ba.append_word('ABCDEFGHIJKLMNOPQRSTUVWXYZ12345', 31); - ba.append_byte(0x65); - - let mut bc: ByteArray = ""; - bc.append(@ba); - - bc - } - - fn formatter(self: @ContractState) { - let var = 5; - let mut formatter: Formatter = Default::default(); - write!(formatter, "test").unwrap(); - write!(formatter, "{var:?}").unwrap(); - println!("{}", formatter.buffer); //prints test5 - } - - fn format(self: @ContractState) { - let var1 = 5; - let var2: ByteArray = "hello"; - let var3 = 5_u32; - let _ba = format!("{},{},{}", var1, var2, var3); - let _ba = format!("{var1}{var2}{var3}"); - let _ba = format!("{var1:?}{var2:?}{var3:?}"); - } - - fn long_panic(self: @ContractState) { - panic!("this should not be reached, but at least I'm not limited to 31 characters anymore") - } - - #[derive(Drop, Debug, PartialEq)] - struct MyStruct { - a: u8, - b: u8 - } - - fn asserts(self: @ContractState) { - let var1 = 5; - let var2 = 6; - assert!(var1 != var2, "should not be equal"); - assert!(var1 != var2, "{},{} should not be equal", var1, var2); - - let first = MyStruct { a: 1, b: 2 }; - let second = MyStruct { a: 1, b: 2 }; - assert!(first == second, "should be equal"); - } -} diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo deleted file mode 100644 index 3eb6ba807d..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo +++ /dev/null @@ -1,53 +0,0 @@ -//! Cairo 2.6.0 feature testing. -#[starknet::contract] -mod cairo_v260 { - // Constants. - enum ThreeOptions { - A: felt252, - B: (u256, u256), - C, - } - - struct ThreeOptionsPair { - a: ThreeOptions, - b: ThreeOptions, - } - - const V: ThreeOptionsPair = ThreeOptionsPair { - a: ThreeOptions::A(1337), - b: ThreeOptions::C, - }; - - #[storage] - struct Storage {} - - #[derive(Drop)] - enum MyEnum { - Foo, - Bar - } - - fn if_let() { - let number = Option::Some(5); - let foo_or_bar = MyEnum::Foo; - - if let Option::Some(i) = number { - println!("{}", i); - } - - if let MyEnum::Bar = foo_or_bar { - println!("bar"); - } - } - - fn while_let(mut arr: Array) -> felt252 { - let mut sum = 0; - while let Option::Some(x) = arr.pop_front() { - sum += x; - }; - sum - } - - fn const_reference() -> ThreeOptionsPair { V } - fn const_box() -> Box { BoxTrait::new(V) } -} diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo deleted file mode 100644 index bf8bc5f9aa..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod cairo_24; -mod cairo_26; diff --git a/crates/dojo-lang/src/manifest_test_data/manifest b/crates/dojo-lang/src/manifest_test_data/manifest deleted file mode 100644 index d1a8d40f9f..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/manifest +++ /dev/null @@ -1,1735 +0,0 @@ -//! > Test generated manifest file - -//! > test_runner_name -test_manifest_file - -//! > expected_manifest_file -{ - "world": { - "name": "dojo::world::world", - "address": null, - "class_hash": "0x2206663eed57fb406a3557c3dbe650451af6f271af4acdcb5cb2e2279249f66", - "abi": [ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::IWorld" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_id", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "model", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "model", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world::OwnerUpdated", - "kind": "nested" - } - ] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "base": { - "name": "dojo::base::base", - "class_hash": "0x794d5ed2f7eb970f92e0ed9be8f73bbbdf18f7db2a9a296fa12c2d9c33e6ab3", - "abi": [ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::base::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } - ] - }, - "resource_metadata": { - "name": "dojo::model::resource_metadata::resource_metadata", - "address": null, - "class_hash": "0x6a2f06cde4aad60e0b6dd595edebe8dca1fbefe5b36cfc2f46a1d1159757df9", - "abi": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, core::array::Span::)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::>" - }, - { - "name": "Array", - "type": "core::integer::u32" - } - ] - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "dojo::model::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo::model::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "event", - "name": "dojo::model::resource_metadata::resource_metadata::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "contracts": [ - { - "name": "dojo_examples::actions::actions", - "address": null, - "class_hash": "0x14179d8db6fe166dff1a9746a39efb789a15643bc0c0afddce40d12caf4ecd6", - "abi": [ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsComputedImpl", - "interface_name": "dojo_examples::actions::IActionsComputed" - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::IActionsComputed", - "items": [ - { - "type": "function", - "name": "tile_terrain", - "inputs": [ - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "quadrant", - "inputs": [ - { - "name": "pos", - "type": "dojo_examples::models::Position" - } - ], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsImpl", - "interface_name": "dojo_examples::actions::IActions" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::IActions", - "items": [ - { - "type": "function", - "name": "spawn", - "inputs": [], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::Moved", - "kind": "struct", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "direction", - "type": "dojo_examples::models::Direction", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - }, - { - "name": "Moved", - "type": "dojo_examples::actions::actions::Moved", - "kind": "nested" - } - ] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - { - "name": "dojo_examples::models::moves", - "address": null, - "class_hash": "0x5465e8310088418ac0d42bd49aba2b63b0857fbdec198a365a5e370358bc2d2", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IDojoModel" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, core::array::Span::)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::>" - }, - { - "name": "Array", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IDojoModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Moves", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "remaining", - "type": "core::integer::u8" - }, - { - "name": "last_direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imoves", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Moves" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::moves::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - { - "name": "dojo_examples::models::position", - "address": null, - "class_hash": "0x1cec286fb861c6e928c62ed270ddedd4d79691fdead0ed4faa74064d804f7ae", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IDojoModel" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, core::array::Span::)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::>" - }, - { - "name": "Array", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IDojoModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iposition", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Position" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::position::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - } - ], - "models": [] -} diff --git a/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml b/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml deleted file mode 100644 index 64a96a42c6..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -cairo-version = "2.4.0" -name = "test_crate" -version = "0.4.1" - -[cairo] -sierra-replace-ids = true - -[dependencies] -dojo = { path = "../../../../dojo-core" } diff --git a/crates/dojo-lang/src/manifest_test_data/spawn-and-move b/crates/dojo-lang/src/manifest_test_data/spawn-and-move deleted file mode 120000 index 0b85d0755f..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/spawn-and-move +++ /dev/null @@ -1 +0,0 @@ -../../../../examples/spawn-and-move \ No newline at end of file diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs deleted file mode 100644 index fc6ec37960..0000000000 --- a/crates/dojo-lang/src/model.rs +++ /dev/null @@ -1,964 +0,0 @@ -use std::collections::HashMap; - -use cairo_lang_defs::patcher::RewriteNode; -use cairo_lang_defs::plugin::PluginDiagnostic; -use cairo_lang_diagnostics::Severity; -use cairo_lang_syntax::node::ast::{ - ArgClause, Expr, ItemStruct, Member as MemberAst, OptionArgListParenthesized, -}; -use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::helpers::QueryAttrs; -use cairo_lang_syntax::node::{Terminal, TypedStablePtr, TypedSyntaxNode}; -use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; -use convert_case::{Case, Casing}; -use dojo_world::config::NamespaceConfig; -use dojo_world::contracts::naming; -use dojo_world::manifest::Member; -use starknet::core::utils::get_selector_from_name; - -use crate::plugin::{DojoAuxData, Model, DOJO_MODEL_ATTR}; - -const DEFAULT_MODEL_VERSION: u8 = 1; - -const MODEL_VERSION_NAME: &str = "version"; -const MODEL_NAMESPACE: &str = "namespace"; -const MODEL_NOMAPPING: &str = "nomapping"; - -struct ModelParameters { - version: u8, - namespace: Option, - nomapping: bool, -} - -impl Default for ModelParameters { - fn default() -> ModelParameters { - ModelParameters { - version: DEFAULT_MODEL_VERSION, - namespace: Option::None, - nomapping: false, - } - } -} - -/// Get the model version from the `Expr` parameter. -fn get_model_version( - db: &dyn SyntaxGroup, - arg_value: Expr, - diagnostics: &mut Vec, -) -> u8 { - match arg_value { - Expr::Literal(ref value) => { - if let Ok(value) = value.text(db).parse::() { - if value <= DEFAULT_MODEL_VERSION { - value - } else { - diagnostics.push(PluginDiagnostic { - message: format!("dojo::model version {} not supported", value), - stable_ptr: arg_value.stable_ptr().untyped(), - severity: Severity::Error, - }); - DEFAULT_MODEL_VERSION - } - } else { - diagnostics.push(PluginDiagnostic { - message: format!( - "The argument '{}' of dojo::model must be an integer", - MODEL_VERSION_NAME - ), - stable_ptr: arg_value.stable_ptr().untyped(), - severity: Severity::Error, - }); - DEFAULT_MODEL_VERSION - } - } - _ => { - diagnostics.push(PluginDiagnostic { - message: format!( - "The argument '{}' of dojo::model must be an integer", - MODEL_VERSION_NAME - ), - stable_ptr: arg_value.stable_ptr().untyped(), - severity: Severity::Error, - }); - DEFAULT_MODEL_VERSION - } - } -} - -/// Get the model namespace from the `Expr` parameter. -fn get_model_namespace( - db: &dyn SyntaxGroup, - arg_value: Expr, - diagnostics: &mut Vec, -) -> Option { - match arg_value { - Expr::ShortString(ss) => Some(ss.string_value(db).unwrap()), - Expr::String(s) => Some(s.string_value(db).unwrap()), - _ => { - diagnostics.push(PluginDiagnostic { - message: format!( - "The argument '{}' of dojo::model must be a string", - MODEL_NAMESPACE - ), - stable_ptr: arg_value.stable_ptr().untyped(), - severity: Severity::Error, - }); - Option::None - } - } -} - -/// Get parameters of the dojo::model attribute. -/// -/// Note: dojo::model attribute has already been checked so there is one and only one attribute. -/// -/// Parameters: -/// * db: The semantic database. -/// * struct_ast: The AST of the model struct. -/// * diagnostics: vector of compiler diagnostics. -/// -/// Returns: -/// * A [`ModelParameters`] object containing all the dojo::model parameters with their default -/// values if not set in the code. -fn get_model_parameters( - db: &dyn SyntaxGroup, - struct_ast: ItemStruct, - diagnostics: &mut Vec, -) -> ModelParameters { - let mut parameters = ModelParameters::default(); - let mut processed_args: HashMap = HashMap::new(); - - if let OptionArgListParenthesized::ArgListParenthesized(arguments) = - struct_ast.attributes(db).query_attr(db, DOJO_MODEL_ATTR).first().unwrap().arguments(db) - { - arguments.arguments(db).elements(db).iter().for_each(|a| match a.arg_clause(db) { - ArgClause::Named(x) => { - let arg_name = x.name(db).text(db).to_string(); - let arg_value = x.value(db); - - if processed_args.contains_key(&arg_name) { - diagnostics.push(PluginDiagnostic { - message: format!("Too many '{}' attributes for dojo::model", arg_name), - stable_ptr: struct_ast.stable_ptr().untyped(), - severity: Severity::Error, - }); - } else { - processed_args.insert(arg_name.clone(), true); - - match arg_name.as_str() { - MODEL_VERSION_NAME => { - parameters.version = get_model_version(db, arg_value, diagnostics); - } - MODEL_NAMESPACE => { - parameters.namespace = get_model_namespace(db, arg_value, diagnostics); - } - MODEL_NOMAPPING => { - parameters.nomapping = true; - } - _ => { - diagnostics.push(PluginDiagnostic { - message: format!( - "Unexpected argument '{}' for dojo::model", - arg_name - ), - stable_ptr: x.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - } - } - } - ArgClause::Unnamed(x) => { - diagnostics.push(PluginDiagnostic { - message: format!( - "Unexpected argument '{}' for dojo::model", - x.as_syntax_node().get_text(db) - ), - stable_ptr: x.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - ArgClause::FieldInitShorthand(x) => { - diagnostics.push(PluginDiagnostic { - message: format!( - "Unexpected argument '{}' for dojo::model", - x.name(db).name(db).text(db).to_string() - ), - stable_ptr: x.stable_ptr().untyped(), - severity: Severity::Warning, - }); - } - }) - } - - parameters -} - -/// A handler for Dojo code that modifies a model struct. -/// Parameters: -/// * db: The semantic database. -/// * struct_ast: The AST of the model struct. -/// -/// Returns: -/// * A RewriteNode containing the generated code. -pub fn handle_model_struct( - db: &dyn SyntaxGroup, - aux_data: &mut DojoAuxData, - struct_ast: ItemStruct, - namespace_config: &NamespaceConfig, -) -> (RewriteNode, Vec) { - let mut diagnostics = vec![]; - - let parameters = get_model_parameters(db, struct_ast.clone(), &mut diagnostics); - - let model_name = struct_ast.name(db).as_syntax_node().get_text(db).trim().to_string(); - let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); - - let model_namespace = if parameters.nomapping { - unmapped_namespace - } else { - // Maps namespace from the tag to ensure higher precision on matching namespace mappings. - namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &model_name)) - }; - - for (id, value) in [("name", &model_name), ("namespace", &model_namespace)] { - if !NamespaceConfig::is_name_valid(value) { - return ( - RewriteNode::empty(), - vec![PluginDiagnostic { - stable_ptr: struct_ast.name(db).stable_ptr().0, - message: format!( - "The {id} '{value}' can only contain characters (a-z/A-Z), digits (0-9) \ - and underscore (_)." - ) - .to_string(), - severity: Severity::Error, - }], - ); - } - } - - let model_tag = naming::get_tag(&model_namespace, &model_name); - let model_name_hash = naming::compute_bytearray_hash(&model_name); - let model_namespace_hash = naming::compute_bytearray_hash(&model_namespace); - - let (model_version, model_selector) = match parameters.version { - 0 => (RewriteNode::Text("0".to_string()), RewriteNode::Text(format!("\"{model_name}\""))), - _ => ( - RewriteNode::Text(DEFAULT_MODEL_VERSION.to_string()), - RewriteNode::Text( - naming::compute_selector_from_hashes(model_namespace_hash, model_name_hash) - .to_string(), - ), - ), - }; - - let mut members: Vec = vec![]; - let mut members_values: Vec = vec![]; - let mut param_keys: Vec = vec![]; - let mut serialized_keys: Vec = vec![]; - let mut serialized_param_keys: Vec = vec![]; - let mut serialized_values: Vec = vec![]; - let mut field_accessors: Vec = vec![]; - let mut entity_field_accessors: Vec = vec![]; - let elements = struct_ast.members(db).elements(db); - - elements.iter().for_each(|member_ast| { - let member = Member { - name: member_ast.name(db).text(db).to_string(), - ty: member_ast.type_clause(db).ty(db).as_syntax_node().get_text(db).trim().to_string(), - key: member_ast.has_attr(db, "key"), - }; - - if member.key { - validate_key_member(&member, db, member_ast, &mut diagnostics); - serialized_keys.push(serialize_member_ty(&member, true)); - serialized_param_keys.push(serialize_member_ty(&member, false)); - param_keys.push(format!("{}: {}", member.name, member.ty)); - } else { - serialized_values.push(serialize_member_ty(&member, true)); - members_values - .push(RewriteNode::Text(format!("pub {}: {},\n", member.name, member.ty))); - } - - members.push(member); - }); - let param_keys = param_keys.join(", "); - - members.iter().filter(|m| !m.key).for_each(|member| { - field_accessors.push(generate_field_accessors( - model_name.clone(), - param_keys.clone(), - serialized_param_keys.clone(), - member, - )); - entity_field_accessors.push(generate_entity_field_accessors(model_name.clone(), member)); - }); - - if serialized_keys.is_empty() { - diagnostics.push(PluginDiagnostic { - message: "Model must define at least one #[key] attribute".into(), - stable_ptr: struct_ast.name(db).stable_ptr().untyped(), - severity: Severity::Error, - }); - } - - if serialized_values.is_empty() { - diagnostics.push(PluginDiagnostic { - message: "Model must define at least one member that is not a key".into(), - stable_ptr: struct_ast.name(db).stable_ptr().untyped(), - severity: Severity::Error, - }); - } - - aux_data.models.push(Model { - name: model_name.clone(), - namespace: model_namespace.clone(), - members, - }); - - ( - RewriteNode::interpolate_patched( - " -#[derive(Drop, Serde)] -pub struct $type_name$Entity { - __id: felt252, // private field - $members_values$ -} - -#[generate_trait] -pub impl $type_name$EntityStoreImpl of $type_name$EntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> $type_name$Entity { - $type_name$ModelEntityImpl::get(world, entity_id) - } - - fn update(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::<$type_name$Entity>::update_entity(self, world); - } - - fn delete(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::<$type_name$Entity>::delete_entity(self, world); - } - - $entity_field_accessors$ -} - -#[generate_trait] -pub impl $type_name$StoreImpl of $type_name$Store { - fn entity_id_from_keys($param_keys$) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_param_keys$ - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> $type_name$ { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::<$type_name$>::deserialize(ref serialized); - - if core::option::OptionTrait::<$type_name$>::is_none(@entity) { - panic!( - \"Model `$type_name$`: deserialization failed. Ensure the length of the keys tuple \ - is matching the number of #[key] fields in the model struct.\" - ); - } - - core::option::OptionTrait::<$type_name$>::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, $param_keys$) -> $type_name$ { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_param_keys$ - - dojo::model::Model::<$type_name$>::get(world, serialized.span()) - } - - fn set(self: @$type_name$, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::<$type_name$>::set_model(self, world); - } - - fn delete(self: @$type_name$, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::<$type_name$>::delete_model(self, world); - } - - $field_accessors$ -} - -pub impl $type_name$ModelEntityImpl of dojo::model::ModelEntity<$type_name$Entity> { - fn id(self: @$type_name$Entity) -> felt252 { - *self.__id - } - - fn values(self: @$type_name$Entity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_values$ - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> $type_name$Entity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::<$type_name$Entity>::deserialize(ref serialized); - if core::option::OptionTrait::<$type_name$Entity>::is_none(@entity_values) { - panic!( - \"ModelEntity `$type_name$Entity`: deserialization failed.\" - ); - } - core::option::OptionTrait::<$type_name$Entity>::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> $type_name$Entity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::<$type_name$>::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::<$type_name$>::layout() - ); - } - - fn delete_entity(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::<$type_name$>::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::<$type_name$>::layout(), \ - member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @$type_name$Entity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::<$type_name$>::layout(), \ - member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -#[cfg(target: \"test\")] -pub impl $type_name$ModelEntityTestImpl of dojo::model::ModelEntityTest<$type_name$Entity> { - fn update_test(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - let world_test = dojo::world::IWorldTestDispatcher { contract_address: \ - world.contract_address }; - - dojo::world::IWorldTestDispatcherTrait::set_entity_test( - world_test, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::<$type_name$>::layout() - ); - } - - fn delete_test(self: @$type_name$Entity, world: dojo::world::IWorldDispatcher) { - let world_test = dojo::world::IWorldTestDispatcher { contract_address: \ - world.contract_address }; - - dojo::world::IWorldTestDispatcherTrait::delete_entity_test( - world_test, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::<$type_name$>::layout() - ); - } -} - -pub impl $type_name$ModelImpl of dojo::model::Model<$type_name$> { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> $type_name$ { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - $type_name$Store::from_values(ref _keys, ref values) - } - - fn set_model( - self: @$type_name$, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @$type_name$, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @$type_name$, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - \"$type_name$\" - } - - #[inline(always)] - fn namespace() -> ByteArray { - \"$model_namespace$\" - } - - #[inline(always)] - fn tag() -> ByteArray { - \"$model_tag$\" - } - - #[inline(always)] - fn version() -> u8 { - $model_version$ - } - - #[inline(always)] - fn selector() -> felt252 { - $model_selector$ - } - - #[inline(always)] - fn instance_selector(self: @$type_name$) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - $model_name_hash$ - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - $model_namespace_hash$ - } - - #[inline(always)] - fn entity_id(self: @$type_name$) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @$type_name$) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_keys$ - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @$type_name$) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_values$ - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::<$type_name$>::layout() - } - - #[inline(always)] - fn instance_layout(self: @$type_name$) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[cfg(target: \"test\")] -pub impl $type_name$ModelTestImpl of dojo::model::ModelTest<$type_name$> { - fn set_test( - self: @$type_name$, - world: dojo::world::IWorldDispatcher - ) { - let world_test = dojo::world::IWorldTestDispatcher { contract_address: \ - world.contract_address }; - - dojo::world::IWorldTestDispatcherTrait::set_entity_test( - world_test, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Keys(dojo::model::Model::<$type_name$>::keys(self)), - dojo::model::Model::<$type_name$>::values(self), - dojo::model::Model::<$type_name$>::layout() - ); - } - - fn delete_test( - self: @$type_name$, - world: dojo::world::IWorldDispatcher - ) { - let world_test = dojo::world::IWorldTestDispatcher { contract_address: \ - world.contract_address }; - - dojo::world::IWorldTestDispatcherTrait::delete_entity_test( - world_test, - dojo::model::Model::<$type_name$>::selector(), - dojo::model::ModelIndex::Keys(dojo::model::Model::<$type_name$>::keys(self)), - dojo::model::Model::<$type_name$>::layout() - ); - } -} - -#[starknet::interface] -pub trait I$contract_name$ { - fn ensure_abi(self: @T, model: $type_name$); -} - -#[starknet::contract] -pub mod $contract_name$ { - use super::$type_name$; - use super::I$contract_name$; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - \"$type_name$\" - } - - fn namespace(self: @ContractState) -> ByteArray { - \"$model_namespace$\" - } - - fn tag(self: @ContractState) -> ByteArray { - \"$model_tag$\" - } - - fn version(self: @ContractState) -> u8 { - $model_version$ - } - - fn selector(self: @ContractState) -> felt252 { - $model_selector$ - } - - fn name_hash(self: @ContractState) -> felt252 { - $model_name_hash$ - } - - fn namespace_hash(self: @ContractState) -> felt252 { - $model_namespace_hash$ - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::<$type_name$>::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::<$type_name$>::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::<$type_name$>::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::<$type_name$>::ty() - } - } - - #[abi(embed_v0)] - impl $contract_name$Impl of I$contract_name${ - fn ensure_abi(self: @ContractState, model: $type_name$) { - } - } -} -", - &UnorderedHashMap::from([ - ("contract_name".to_string(), RewriteNode::Text(model_name.to_case(Case::Snake))), - ("type_name".to_string(), RewriteNode::Text(model_name)), - ("namespace".to_string(), RewriteNode::Text("namespace".to_string())), - ("serialized_keys".to_string(), RewriteNode::new_modified(serialized_keys)), - ("serialized_values".to_string(), RewriteNode::new_modified(serialized_values)), - ("model_version".to_string(), model_version), - ("model_selector".to_string(), model_selector), - ("model_namespace".to_string(), RewriteNode::Text(model_namespace.clone())), - ("model_name_hash".to_string(), RewriteNode::Text(model_name_hash.to_string())), - ( - "model_namespace_hash".to_string(), - RewriteNode::Text(model_namespace_hash.to_string()), - ), - ("model_tag".to_string(), RewriteNode::Text(model_tag.clone())), - ("members_values".to_string(), RewriteNode::new_modified(members_values)), - ("param_keys".to_string(), RewriteNode::Text(param_keys)), - ( - "serialized_param_keys".to_string(), - RewriteNode::new_modified(serialized_param_keys), - ), - ("field_accessors".to_string(), RewriteNode::new_modified(field_accessors)), - ( - "entity_field_accessors".to_string(), - RewriteNode::new_modified(entity_field_accessors), - ), - ]), - ), - diagnostics, - ) -} - -/// Validates that the key member is valid. -/// # Arguments -/// -/// * member: The member to validate. -/// * diagnostics: The diagnostics to push to, if the member is an invalid key. -fn validate_key_member( - member: &Member, - db: &dyn SyntaxGroup, - member_ast: &MemberAst, - diagnostics: &mut Vec, -) { - if member.ty == "u256" { - diagnostics.push(PluginDiagnostic { - message: "Key is only supported for core types that are 1 felt long once serialized. \ - `u256` is a struct of 2 u128, hence not supported." - .into(), - stable_ptr: member_ast.name(db).stable_ptr().untyped(), - severity: Severity::Error, - }); - } -} - -/// Creates a [`RewriteNode`] for the member type serialization. -/// -/// # Arguments -/// -/// * member: The member to serialize. -fn serialize_member_ty(member: &Member, with_self: bool) -> RewriteNode { - match member.ty.as_str() { - "felt252" => RewriteNode::Text(format!( - "core::array::ArrayTrait::append(ref serialized, {}{});\n", - if with_self { "*self." } else { "" }, - member.name - )), - _ => RewriteNode::Text(format!( - "core::serde::Serde::serialize({}{}, ref serialized);\n", - if with_self { "self." } else { "@" }, - member.name - )), - } -} - -/// Generates field accessors (`get_[field_name]` and `set_[field_name]`) for every -/// fields of a model. -/// -/// # Arguments -/// -/// * `model_name` - the model name. -/// * `param_keys` - coma separated model keys with the format `KEY_NAME: KEY_TYPE`. -/// * `serialized_param_keys` - code to serialize model keys in a `serialized` felt252 array. -/// * `member` - information about the field for which to generate accessors. -/// -/// # Returns -/// A [`RewriteNode`] containing accessors code. -fn generate_field_accessors( - model_name: String, - param_keys: String, - serialized_param_keys: Vec, - member: &Member, -) -> RewriteNode { - RewriteNode::interpolate_patched( - " - fn get_$field_name$(world: dojo::world::IWorldDispatcher, $param_keys$) -> $field_type$ { - let mut serialized = core::array::ArrayTrait::new(); - $serialized_param_keys$ - - let mut values = dojo::model::Model::<$model_name$>::get_member( - world, - serialized.span(), - $field_selector$ - ); - - let field_value = core::serde::Serde::<$field_type$>::deserialize(ref values); - - if core::option::OptionTrait::<$field_type$>::is_none(@field_value) { - panic!( - \"Field `$model_name$::$field_name$`: deserialization failed.\" - ); - } - - core::option::OptionTrait::<$field_type$>::unwrap(field_value) - } - - fn set_$field_name$(self: @$model_name$, world: dojo::world::IWorldDispatcher, value: \ - $field_type$) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - $field_selector$, - serialized.span() - ); - } - ", - &UnorderedHashMap::from([ - ("model_name".to_string(), RewriteNode::Text(model_name)), - ( - "field_selector".to_string(), - RewriteNode::Text( - get_selector_from_name(&member.name).expect("invalid member name").to_string(), - ), - ), - ("field_name".to_string(), RewriteNode::Text(member.name.clone())), - ("field_type".to_string(), RewriteNode::Text(member.ty.clone())), - ("param_keys".to_string(), RewriteNode::Text(param_keys)), - ("serialized_param_keys".to_string(), RewriteNode::new_modified(serialized_param_keys)), - ]), - ) -} - -/// Generates field accessors (`get_[field_name]` and `set_[field_name]`) for every -/// fields of a model entity. -/// -/// # Arguments -/// -/// * `model_name` - the model name. -/// * `member` - information about the field for which to generate accessors. -/// -/// # Returns -/// A [`RewriteNode`] containing accessors code. -fn generate_entity_field_accessors(model_name: String, member: &Member) -> RewriteNode { - RewriteNode::interpolate_patched( - " - fn get_$field_name$(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> $field_type$ \ - { - let mut values = dojo::model::ModelEntity::<$model_name$Entity>::get_member( - world, - entity_id, - $field_selector$ - ); - let field_value = core::serde::Serde::<$field_type$>::deserialize(ref values); - - if core::option::OptionTrait::<$field_type$>::is_none(@field_value) { - panic!( - \"Field `$model_name$::$field_name$`: deserialization failed.\" - ); - } - - core::option::OptionTrait::<$field_type$>::unwrap(field_value) - } - - fn set_$field_name$(self: @$model_name$Entity, world: dojo::world::IWorldDispatcher, value: \ - $field_type$) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - $field_selector$, - serialized.span() - ); - } -", - &UnorderedHashMap::from([ - ("model_name".to_string(), RewriteNode::Text(model_name)), - ( - "field_selector".to_string(), - RewriteNode::Text( - get_selector_from_name(&member.name).expect("invalid member name").to_string(), - ), - ), - ("field_name".to_string(), RewriteNode::Text(member.name.clone())), - ("field_type".to_string(), RewriteNode::Text(member.ty.clone())), - ]), - ) -} diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs deleted file mode 100644 index 317bf2cb87..0000000000 --- a/crates/dojo-lang/src/plugin.rs +++ /dev/null @@ -1,470 +0,0 @@ -use std::cmp::Ordering; - -use anyhow::Result; -use cairo_lang_defs::patcher::PatchBuilder; -use cairo_lang_defs::plugin::{ - DynGeneratedFileAuxData, GeneratedFileAuxData, MacroPlugin, MacroPluginMetadata, - PluginDiagnostic, PluginGeneratedFile, PluginResult, -}; -use cairo_lang_diagnostics::Severity; -use cairo_lang_semantic::plugin::PluginSuite; -use cairo_lang_starknet::plugin::aux_data::StarkNetEventAuxData; -use cairo_lang_syntax::attribute::structured::{AttributeArgVariant, AttributeStructurize}; -use cairo_lang_syntax::node::ast::Attribute; -use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::helpers::QueryAttrs; -use cairo_lang_syntax::node::ids::SyntaxStablePtrId; -use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; -use dojo_types::system::Dependency; -use dojo_world::config::NamespaceConfig; -use dojo_world::manifest::Member; -use scarb::compiler::plugin::builtin::BuiltinStarkNetPlugin; -use scarb::compiler::plugin::{CairoPlugin, CairoPluginInstance}; -use scarb::core::{PackageId, PackageName, SourceId}; -use semver::Version; -use smol_str::SmolStr; -use url::Url; - -use crate::contract::DojoContract; -use crate::event::handle_event_struct; -use crate::inline_macros::delete::DeleteMacro; -use crate::inline_macros::emit::EmitMacro; -use crate::inline_macros::get::GetMacro; -use crate::inline_macros::get_models_test_class_hashes::GetModelsTestClassHashes; -use crate::inline_macros::selector_from_tag::SelectorFromTagMacro; -use crate::inline_macros::set::SetMacro; -use crate::inline_macros::spawn_test_world::SpawnTestWorld; -use crate::interface::DojoInterface; -use crate::introspect::{handle_introspect_enum, handle_introspect_struct}; -use crate::model::handle_model_struct; -use crate::print::{handle_print_enum, handle_print_struct}; - -pub const DOJO_CONTRACT_ATTR: &str = "dojo::contract"; -pub const DOJO_INTERFACE_ATTR: &str = "dojo::interface"; -pub const DOJO_MODEL_ATTR: &str = "dojo::model"; -pub const DOJO_EVENT_ATTR: &str = "dojo::event"; - -pub const DOJO_INTROSPECT_ATTR: &str = "Introspect"; -pub const DOJO_PACKED_ATTR: &str = "IntrospectPacked"; - -#[derive(Clone, Debug, PartialEq)] -pub struct Model { - pub name: String, - pub namespace: String, - pub members: Vec, -} - -#[derive(Debug, PartialEq, Eq)] -pub struct ContractAuxData { - pub name: SmolStr, - pub namespace: String, - pub dependencies: Vec, - pub systems: Vec, -} - -/// Dojo related auxiliary data of the Dojo plugin. -#[derive(Debug, Default, PartialEq)] -pub struct DojoAuxData { - /// A list of models that were processed by the plugin. - pub models: Vec, - /// A list of contracts that were processed by the plugin and their model dependencies. - pub contracts: Vec, - /// A list of events that were processed by the plugin. - pub events: Vec, -} - -impl GeneratedFileAuxData for DojoAuxData { - fn as_any(&self) -> &dyn std::any::Any { - self - } - fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { - if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } - } -} - -#[cfg(test)] -#[path = "plugin_test.rs"] -mod test; - -pub const PACKAGE_NAME: &str = "dojo_plugin"; - -#[derive(Debug, Default)] -pub struct BuiltinDojoPlugin; - -impl BuiltinDojoPlugin { - fn handle_mod( - &self, - db: &dyn SyntaxGroup, - module_ast: ast::ItemModule, - namespace_config: &NamespaceConfig, - metadata: &MacroPluginMetadata<'_>, - ) -> PluginResult { - if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { - return DojoContract::from_module(db, &module_ast, namespace_config, metadata); - } - - PluginResult::default() - } - - fn handle_trait( - &self, - db: &dyn SyntaxGroup, - trait_ast: ast::ItemTrait, - metadata: &MacroPluginMetadata<'_>, - ) -> PluginResult { - if trait_ast.has_attr(db, DOJO_INTERFACE_ATTR) { - return DojoInterface::from_trait(db, trait_ast, metadata); - } - - PluginResult::default() - } -} - -impl CairoPlugin for BuiltinDojoPlugin { - fn id(&self) -> PackageId { - let url = Url::parse("https://github.com/dojoengine/dojo").unwrap(); - let version = "0.4.0"; - // TODO: update this once pushed. - let rev = "1e651b5d4d3b79b14a7d8aa29a92062fcb9e6659"; - - let source_id = - SourceId::for_git(&url, &scarb::core::GitReference::Tag(format!("v{version}").into())) - .unwrap() - .with_precise(rev.to_string()) - .unwrap(); - - PackageId::new(PackageName::new(PACKAGE_NAME), Version::parse(version).unwrap(), source_id) - } - - fn instantiate(&self) -> Result> { - Ok(Box::new(BuiltinDojoPluginInstance)) - } -} - -struct BuiltinDojoPluginInstance; -impl CairoPluginInstance for BuiltinDojoPluginInstance { - fn plugin_suite(&self) -> PluginSuite { - dojo_plugin_suite() - } -} - -pub fn dojo_plugin_suite() -> PluginSuite { - let mut suite = PluginSuite::default(); - - suite - .add_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::() - .add_inline_macro_plugin::(); - - suite -} - -fn get_derive_attr_names( - db: &dyn SyntaxGroup, - diagnostics: &mut Vec, - attrs: Vec, -) -> Vec { - attrs - .iter() - .filter_map(|attr| { - let args = attr.clone().structurize(db).args; - if args.is_empty() { - diagnostics.push(PluginDiagnostic { - stable_ptr: attr.stable_ptr().0, - message: "Expected args.".into(), - severity: Severity::Error, - }); - None - } else { - Some(args.into_iter().filter_map(|a| { - if let AttributeArgVariant::Unnamed(ast::Expr::Path(path)) = a.variant { - if let [ast::PathSegment::Simple(segment)] = &path.elements(db)[..] { - Some(segment.ident(db).text(db).to_string()) - } else { - None - } - } else { - None - } - })) - } - }) - .flatten() - .collect::>() -} - -fn check_for_derive_attr_conflicts( - diagnostics: &mut Vec, - diagnostic_item: SyntaxStablePtrId, - attr_names: &[String], -) { - if attr_names.contains(&DOJO_INTROSPECT_ATTR.to_string()) - && attr_names.contains(&DOJO_PACKED_ATTR.to_string()) - { - diagnostics.push(PluginDiagnostic { - stable_ptr: diagnostic_item, - message: format!( - "{} and {} attributes cannot be used at a same time.", - DOJO_INTROSPECT_ATTR, DOJO_PACKED_ATTR - ), - severity: Severity::Error, - }); - } -} - -fn get_additional_derive_attrs_for_model(derive_attr_names: &[String]) -> Vec { - let mut additional_attrs = vec![]; - - // if not already present, add Introspect to derive attributes because it - // is mandatory for a model - if !derive_attr_names.contains(&DOJO_INTROSPECT_ATTR.to_string()) - && !derive_attr_names.contains(&DOJO_PACKED_ATTR.to_string()) - { - additional_attrs.push(DOJO_INTROSPECT_ATTR.to_string()); - } - - additional_attrs -} - -impl MacroPlugin for BuiltinDojoPlugin { - // This function is called for every item in whole db. Hence, - // the sooner we can return, the better. - // As an example, compiling spawn-and-move project, it's almost 14K calls to this - // function. - fn generate_code( - &self, - db: &dyn SyntaxGroup, - item_ast: ast::ModuleItem, - metadata: &MacroPluginMetadata<'_>, - ) -> PluginResult { - // Metadata gives information from the crates from where `item_ast` was parsed. - // During the compilation phase, we inject namespace information into the `CfgSet` - // so that it can be used here. - let namespace_config = metadata.cfg_set.into(); - - match item_ast { - ast::ModuleItem::Module(module_ast) => { - self.handle_mod(db, module_ast, &namespace_config, metadata) - } - ast::ModuleItem::Trait(trait_ast) => self.handle_trait(db, trait_ast, metadata), - ast::ModuleItem::Enum(enum_ast) => { - let aux_data = DojoAuxData::default(); - let mut rewrite_nodes = vec![]; - let mut diagnostics = vec![]; - - let derive_attr_names = get_derive_attr_names( - db, - &mut diagnostics, - enum_ast.attributes(db).query_attr(db, "derive"), - ); - - check_for_derive_attr_conflicts( - &mut diagnostics, - enum_ast.name(db).stable_ptr().0, - &derive_attr_names, - ); - - // Iterate over all the derive attributes of the struct - for attr in derive_attr_names { - match attr.as_str() { - DOJO_INTROSPECT_ATTR => { - rewrite_nodes.push(handle_introspect_enum( - db, - &mut diagnostics, - enum_ast.clone(), - false, - )); - } - DOJO_PACKED_ATTR => { - rewrite_nodes.push(handle_introspect_enum( - db, - &mut diagnostics, - enum_ast.clone(), - true, - )); - } - "Print" => rewrite_nodes.push(handle_print_enum(db, enum_ast.clone())), - _ => continue, - } - } - - if rewrite_nodes.is_empty() { - return PluginResult { diagnostics, ..PluginResult::default() }; - } - - let name = enum_ast.name(db).text(db); - let mut builder = PatchBuilder::new(db, &enum_ast); - for node in rewrite_nodes { - builder.add_modified(node); - } - - let (code, code_mappings) = builder.build(); - - PluginResult { - code: Some(PluginGeneratedFile { - name, - content: code, - aux_data: Some(DynGeneratedFileAuxData::new(aux_data)), - code_mappings, - }), - diagnostics, - remove_original_item: false, - } - } - ast::ModuleItem::Struct(struct_ast) => { - let mut aux_data = DojoAuxData::default(); - let mut rewrite_nodes = vec![]; - let mut diagnostics = vec![]; - - let mut addtional_derive_attr_names = vec![]; - let derive_attr_names = get_derive_attr_names( - db, - &mut diagnostics, - struct_ast.attributes(db).query_attr(db, "derive"), - ); - - let model_attrs = struct_ast.attributes(db).query_attr(db, DOJO_MODEL_ATTR); - - check_for_derive_attr_conflicts( - &mut diagnostics, - struct_ast.name(db).stable_ptr().0, - &derive_attr_names, - ); - - if !model_attrs.is_empty() { - addtional_derive_attr_names = - get_additional_derive_attrs_for_model(&derive_attr_names); - } - - // Iterate over all the derive attributes of the struct - for attr in derive_attr_names.iter().chain(addtional_derive_attr_names.iter()) { - match attr.as_str() { - "Print" => { - rewrite_nodes.push(handle_print_struct(db, struct_ast.clone())); - } - DOJO_INTROSPECT_ATTR => { - rewrite_nodes.push(handle_introspect_struct( - db, - &mut diagnostics, - struct_ast.clone(), - false, - )); - } - DOJO_PACKED_ATTR => { - rewrite_nodes.push(handle_introspect_struct( - db, - &mut diagnostics, - struct_ast.clone(), - true, - )); - } - _ => continue, - } - } - - let event_attrs = struct_ast.attributes(db).query_attr(db, DOJO_EVENT_ATTR); - - match event_attrs.len().cmp(&1) { - Ordering::Equal => { - let (event_rewrite_nodes, event_diagnostics) = - handle_event_struct(db, &mut aux_data, struct_ast.clone()); - rewrite_nodes.push(event_rewrite_nodes); - diagnostics.extend(event_diagnostics); - } - Ordering::Greater => { - diagnostics.push(PluginDiagnostic { - message: "A Dojo event must have zero or one dojo::event attribute." - .into(), - stable_ptr: struct_ast.stable_ptr().0, - severity: Severity::Error, - }); - } - _ => {} - } - - match model_attrs.len().cmp(&1) { - Ordering::Equal => { - let (model_rewrite_nodes, model_diagnostics) = handle_model_struct( - db, - &mut aux_data, - struct_ast.clone(), - &namespace_config, - ); - rewrite_nodes.push(model_rewrite_nodes); - diagnostics.extend(model_diagnostics); - } - Ordering::Greater => { - diagnostics.push(PluginDiagnostic { - message: "A Dojo model must have zero or one dojo::model attribute." - .into(), - stable_ptr: struct_ast.stable_ptr().0, - severity: Severity::Error, - }); - } - _ => {} - } - - if rewrite_nodes.is_empty() { - return PluginResult { diagnostics, ..PluginResult::default() }; - } - - let name = struct_ast.name(db).text(db); - let mut builder = PatchBuilder::new(db, &struct_ast); - for node in rewrite_nodes { - builder.add_modified(node); - } - - let (code, code_mappings) = builder.build(); - - PluginResult { - code: Some(PluginGeneratedFile { - name, - content: code, - aux_data: Some(DynGeneratedFileAuxData::new(aux_data)), - code_mappings, - }), - diagnostics, - remove_original_item: false, - } - } - _ => PluginResult::default(), - } - } - - fn declared_attributes(&self) -> Vec { - vec![ - DOJO_INTERFACE_ATTR.to_string(), - DOJO_CONTRACT_ATTR.to_string(), - DOJO_EVENT_ATTR.to_string(), - DOJO_MODEL_ATTR.to_string(), - "key".to_string(), - ] - } - - fn declared_derives(&self) -> Vec { - vec!["Introspect".to_string(), "IntrospectPacked".to_string()] - } -} - -#[derive(Debug)] -pub struct CairoPluginRepository(scarb::compiler::plugin::CairoPluginRepository); - -impl Default for CairoPluginRepository { - fn default() -> Self { - let mut repo = scarb::compiler::plugin::CairoPluginRepository::empty(); - repo.add(Box::new(BuiltinDojoPlugin)).unwrap(); - repo.add(Box::new(BuiltinStarkNetPlugin)).unwrap(); - Self(repo) - } -} - -impl From for scarb::compiler::plugin::CairoPluginRepository { - fn from(val: CairoPluginRepository) -> Self { - val.0 - } -} diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model deleted file mode 100644 index 9a704e2a9c..0000000000 --- a/crates/dojo-lang/src/plugin_test_data/model +++ /dev/null @@ -1,26713 +0,0 @@ -//! > Test expansion of the dojo::model. - -//! > test_runner_name -test_expand_plugin - -//! > test_id -model - -//! > cairo_code -#[dojo::model(version: 0)] -#[dojo::model(version: 0)] -struct BadModelMultipleAttr { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 0, version: 0)] -struct BadModelMultipleVersions { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: hello)] -struct BadModelBadVersionType { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version)] -struct BadModelNoVersionValue { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(my_arg: 1)] -struct BadModelUnexpectedArgWithValue { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(my_arg)] -struct BadModelUnexpectedArg { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 2)] -struct BadModelNotSupportedVersion { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 0)] -struct Modelv0 { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: 'MyNamespace')] -struct ModelWithBadNamespaceFormat { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: 'my_namespace')] -struct ModelWithShortStringNamespace { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: "my_namespace")] -struct ModelWithStringNamespace { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model] -struct Position { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model] -struct Roles { - role_ids: Array -} - -#[dojo::model] -struct OnlyKeyModel { - #[key] - id: felt252 -} - -#[dojo::model] -struct U256KeyModel { - #[key] - id: u256 -} - -#[dojo::model] -struct Player { - #[key] - game: felt252, - #[key] - player: ContractAddress, - name: felt252, -} - -#[dojo::model] -type OtherPlayer = Player; - -#[dojo::model] -struct ModelWithSimpleArray { - #[key] - player: ContractAddress, - x: u16, - y: Array -} - -#[dojo::model] -struct ModelWithByteArray { - #[key] - player: ContractAddress, - x: u16, - y: ByteArray -} - -#[dojo::model] -struct ModelWithComplexArray { - #[key] - player: ContractAddress, - x: u16, - y: Array -} - -#[dojo::model] -struct ModelWithTuple { - #[key] - player: ContractAddress, - x: u16, - y: (u8, u16, u32) -} - -#[dojo::model] -struct ModelWithTupleNoPrimitives { - #[key] - player: ContractAddress, - x: u16, - y: (u8, Vec3, u32) -} - -//! > expanded_cairo_code -#[dojo::model(version: 0)] -#[dojo::model(version: 0)] -struct BadModelMultipleAttr { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 0, version: 0)] -struct BadModelMultipleVersions { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: hello)] -struct BadModelBadVersionType { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version)] -struct BadModelNoVersionValue { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(my_arg: 1)] -struct BadModelUnexpectedArgWithValue { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(my_arg)] -struct BadModelUnexpectedArg { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 2)] -struct BadModelNotSupportedVersion { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(version: 0)] -struct Modelv0 { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: 'MyNamespace')] -struct ModelWithBadNamespaceFormat { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: 'my_namespace')] -struct ModelWithShortStringNamespace { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model(namespace: "my_namespace")] -struct ModelWithStringNamespace { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model] -struct Position { - #[key] - id: felt252, - v: Vec3, -} - -#[dojo::model] -struct Roles { - role_ids: Array -} - -#[dojo::model] -struct OnlyKeyModel { - #[key] - id: felt252 -} - -#[dojo::model] -struct U256KeyModel { - #[key] - id: u256 -} - -#[dojo::model] -struct Player { - #[key] - game: felt252, - #[key] - player: ContractAddress, - name: felt252, -} - -#[dojo::model] -type OtherPlayer = Player; - -#[dojo::model] -struct ModelWithSimpleArray { - #[key] - player: ContractAddress, - x: u16, - y: Array -} - -#[dojo::model] -struct ModelWithByteArray { - #[key] - player: ContractAddress, - x: u16, - y: ByteArray -} - -#[dojo::model] -struct ModelWithComplexArray { - #[key] - player: ContractAddress, - x: u16, - y: Array -} - -#[dojo::model] -struct ModelWithTuple { - #[key] - player: ContractAddress, - x: u16, - y: (u8, u16, u32) -} - -#[dojo::model] -struct ModelWithTupleNoPrimitives { - #[key] - player: ContractAddress, - x: u16, - y: (u8, Vec3, u32) -} -impl BadModelMultipleAttrIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelMultipleAttr', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -impl BadModelMultipleVersionsIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelMultipleVersions', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelMultipleVersionsEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelMultipleVersionsEntityStoreImpl of BadModelMultipleVersionsEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelMultipleVersionsEntity { - BadModelMultipleVersionsModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelMultipleVersions::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelMultipleVersionsStoreImpl of BadModelMultipleVersionsStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelMultipleVersions { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelMultipleVersions`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelMultipleVersions { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelMultipleVersions::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelMultipleVersionsModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelMultipleVersionsEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelMultipleVersionsEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelMultipleVersionsEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelMultipleVersionsEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelMultipleVersionsEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelMultipleVersionsEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelMultipleVersionsModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelMultipleVersions { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelMultipleVersionsStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelMultipleVersions, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelMultipleVersions, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelMultipleVersions, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelMultipleVersions" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelMultipleVersions" - } - - #[inline(always)] - fn version() -> u8 { - 0 - } - - #[inline(always)] - fn selector() -> felt252 { - "BadModelMultipleVersions" - } - - #[inline(always)] - fn instance_selector(self: @BadModelMultipleVersions) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3538888628466873673221842373412072042558277047191927145880480325050722136660 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelMultipleVersions) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelMultipleVersions) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelMultipleVersions) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelMultipleVersions) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_multiple_versions { - fn ensure_abi(self: @T, model: BadModelMultipleVersions); -} - -#[starknet::contract] -pub mod bad_model_multiple_versions { - use super::BadModelMultipleVersions; - use super::Ibad_model_multiple_versions; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelMultipleVersions" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelMultipleVersions" - } - - fn version(self: @ContractState) -> u8 { - 0 - } - - fn selector(self: @ContractState) -> felt252 { - "BadModelMultipleVersions" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3538888628466873673221842373412072042558277047191927145880480325050722136660 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_multiple_versionsImpl of Ibad_model_multiple_versions{ - fn ensure_abi(self: @ContractState, model: BadModelMultipleVersions) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_multiple_versionsImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_multiple_versionsImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_multiple_versionsImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl BadModelBadVersionTypeIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelBadVersionType', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelBadVersionTypeEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelBadVersionTypeEntityStoreImpl of BadModelBadVersionTypeEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelBadVersionTypeEntity { - BadModelBadVersionTypeModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelBadVersionType::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelBadVersionTypeStoreImpl of BadModelBadVersionTypeStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelBadVersionType { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelBadVersionType`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelBadVersionType { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelBadVersionType::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelBadVersionTypeModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelBadVersionTypeEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelBadVersionTypeEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelBadVersionTypeEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelBadVersionTypeEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelBadVersionTypeEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelBadVersionTypeEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelBadVersionTypeModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelBadVersionType { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelBadVersionTypeStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelBadVersionType, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelBadVersionType, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelBadVersionType, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelBadVersionType" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelBadVersionType" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1905541678078795270787966976324692071183638743428320623241420232497892529006 - } - - #[inline(always)] - fn instance_selector(self: @BadModelBadVersionType) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 760683829940564015458541272487101565210915690045377810379189532484191344547 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelBadVersionType) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelBadVersionType) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelBadVersionType) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelBadVersionType) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_bad_version_type { - fn ensure_abi(self: @T, model: BadModelBadVersionType); -} - -#[starknet::contract] -pub mod bad_model_bad_version_type { - use super::BadModelBadVersionType; - use super::Ibad_model_bad_version_type; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelBadVersionType" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelBadVersionType" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 1905541678078795270787966976324692071183638743428320623241420232497892529006 - } - - fn name_hash(self: @ContractState) -> felt252 { - 760683829940564015458541272487101565210915690045377810379189532484191344547 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_bad_version_typeImpl of Ibad_model_bad_version_type{ - fn ensure_abi(self: @ContractState, model: BadModelBadVersionType) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_bad_version_typeImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_bad_version_typeImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_bad_version_typeImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl BadModelNoVersionValueIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelNoVersionValue', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelNoVersionValueEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelNoVersionValueEntityStoreImpl of BadModelNoVersionValueEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNoVersionValueEntity { - BadModelNoVersionValueModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelNoVersionValue::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelNoVersionValueStoreImpl of BadModelNoVersionValueStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelNoVersionValue { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelNoVersionValue`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelNoVersionValue { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelNoVersionValue::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelNoVersionValueModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelNoVersionValueEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelNoVersionValueEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelNoVersionValueEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelNoVersionValueEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNoVersionValueEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelNoVersionValueEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelNoVersionValueModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelNoVersionValue { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelNoVersionValueStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelNoVersionValue, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelNoVersionValue, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelNoVersionValue, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelNoVersionValue" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelNoVersionValue" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2174173236757861924887576251338889271361403293870377278593064770381730742730 - } - - #[inline(always)] - fn instance_selector(self: @BadModelNoVersionValue) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2459365230136118590954025890011480023818926626380754992635699340900694864996 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelNoVersionValue) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelNoVersionValue) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelNoVersionValue) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelNoVersionValue) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_no_version_value { - fn ensure_abi(self: @T, model: BadModelNoVersionValue); -} - -#[starknet::contract] -pub mod bad_model_no_version_value { - use super::BadModelNoVersionValue; - use super::Ibad_model_no_version_value; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelNoVersionValue" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelNoVersionValue" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2174173236757861924887576251338889271361403293870377278593064770381730742730 - } - - fn name_hash(self: @ContractState) -> felt252 { - 2459365230136118590954025890011480023818926626380754992635699340900694864996 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_no_version_valueImpl of Ibad_model_no_version_value{ - fn ensure_abi(self: @ContractState, model: BadModelNoVersionValue) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_no_version_valueImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_no_version_valueImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_no_version_valueImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl BadModelUnexpectedArgWithValueIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelUnexpectedArgWithValue', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelUnexpectedArgWithValueEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelUnexpectedArgWithValueEntityStoreImpl of BadModelUnexpectedArgWithValueEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgWithValueEntity { - BadModelUnexpectedArgWithValueModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelUnexpectedArgWithValue::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelUnexpectedArgWithValueStoreImpl of BadModelUnexpectedArgWithValueStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelUnexpectedArgWithValue { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelUnexpectedArgWithValue`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelUnexpectedArgWithValue { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelUnexpectedArgWithValue::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelUnexpectedArgWithValueModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelUnexpectedArgWithValueEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelUnexpectedArgWithValueEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelUnexpectedArgWithValueEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelUnexpectedArgWithValueEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgWithValueEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelUnexpectedArgWithValueEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelUnexpectedArgWithValueModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelUnexpectedArgWithValue { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelUnexpectedArgWithValueStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelUnexpectedArgWithValue, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelUnexpectedArgWithValue, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelUnexpectedArgWithValue, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelUnexpectedArgWithValue" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelUnexpectedArgWithValue" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1774601905279008934284028706234273692471613779453192873246657851412081197776 - } - - #[inline(always)] - fn instance_selector(self: @BadModelUnexpectedArgWithValue) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3586339245084542986020591057627093254376225984628310828088084183494435682971 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelUnexpectedArgWithValue) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelUnexpectedArgWithValue) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelUnexpectedArgWithValue) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelUnexpectedArgWithValue) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_unexpected_arg_with_value { - fn ensure_abi(self: @T, model: BadModelUnexpectedArgWithValue); -} - -#[starknet::contract] -pub mod bad_model_unexpected_arg_with_value { - use super::BadModelUnexpectedArgWithValue; - use super::Ibad_model_unexpected_arg_with_value; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelUnexpectedArgWithValue" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelUnexpectedArgWithValue" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 1774601905279008934284028706234273692471613779453192873246657851412081197776 - } - - fn name_hash(self: @ContractState) -> felt252 { - 3586339245084542986020591057627093254376225984628310828088084183494435682971 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_unexpected_arg_with_valueImpl of Ibad_model_unexpected_arg_with_value{ - fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArgWithValue) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_unexpected_arg_with_valueImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_unexpected_arg_with_valueImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_unexpected_arg_with_valueImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl BadModelUnexpectedArgIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelUnexpectedArg', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelUnexpectedArgEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelUnexpectedArgEntityStoreImpl of BadModelUnexpectedArgEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgEntity { - BadModelUnexpectedArgModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelUnexpectedArg::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelUnexpectedArgStoreImpl of BadModelUnexpectedArgStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelUnexpectedArg { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelUnexpectedArg`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelUnexpectedArg { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelUnexpectedArg::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelUnexpectedArgModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelUnexpectedArgEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelUnexpectedArgEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelUnexpectedArgEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelUnexpectedArgEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelUnexpectedArgEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelUnexpectedArgModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelUnexpectedArg { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelUnexpectedArgStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelUnexpectedArg, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelUnexpectedArg, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelUnexpectedArg, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelUnexpectedArg" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelUnexpectedArg" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 285468224541147509570785281966044474829506125602814945625270991330973673529 - } - - #[inline(always)] - fn instance_selector(self: @BadModelUnexpectedArg) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 246403407829267991441535935236143476032296881039254363860883767387993960270 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelUnexpectedArg) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelUnexpectedArg) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelUnexpectedArg) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelUnexpectedArg) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_unexpected_arg { - fn ensure_abi(self: @T, model: BadModelUnexpectedArg); -} - -#[starknet::contract] -pub mod bad_model_unexpected_arg { - use super::BadModelUnexpectedArg; - use super::Ibad_model_unexpected_arg; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelUnexpectedArg" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelUnexpectedArg" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 285468224541147509570785281966044474829506125602814945625270991330973673529 - } - - fn name_hash(self: @ContractState) -> felt252 { - 246403407829267991441535935236143476032296881039254363860883767387993960270 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_unexpected_argImpl of Ibad_model_unexpected_arg{ - fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArg) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_unexpected_argImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_unexpected_argImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_unexpected_argImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl BadModelNotSupportedVersionIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'BadModelNotSupportedVersion', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct BadModelNotSupportedVersionEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl BadModelNotSupportedVersionEntityStoreImpl of BadModelNotSupportedVersionEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNotSupportedVersionEntity { - BadModelNotSupportedVersionModelEntityImpl::get(world, entity_id) - } - - fn update(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelNotSupportedVersion::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl BadModelNotSupportedVersionStoreImpl of BadModelNotSupportedVersionStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> BadModelNotSupportedVersion { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `BadModelNotSupportedVersion`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelNotSupportedVersion { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `BadModelNotSupportedVersion::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl BadModelNotSupportedVersionModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @BadModelNotSupportedVersionEntity) -> felt252 { - *self.__id - } - - fn values(self: @BadModelNotSupportedVersionEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> BadModelNotSupportedVersionEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `BadModelNotSupportedVersionEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNotSupportedVersionEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelNotSupportedVersionEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl BadModelNotSupportedVersionModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> BadModelNotSupportedVersion { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - BadModelNotSupportedVersionStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @BadModelNotSupportedVersion, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @BadModelNotSupportedVersion, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @BadModelNotSupportedVersion, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "BadModelNotSupportedVersion" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-BadModelNotSupportedVersion" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3364830312705791335907422218790599751780160858399843169712719310945970157661 - } - - #[inline(always)] - fn instance_selector(self: @BadModelNotSupportedVersion) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1812257929012908024237871796629728977392496349235879470060252299886369485820 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @BadModelNotSupportedVersion) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @BadModelNotSupportedVersion) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @BadModelNotSupportedVersion) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @BadModelNotSupportedVersion) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ibad_model_not_supported_version { - fn ensure_abi(self: @T, model: BadModelNotSupportedVersion); -} - -#[starknet::contract] -pub mod bad_model_not_supported_version { - use super::BadModelNotSupportedVersion; - use super::Ibad_model_not_supported_version; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "BadModelNotSupportedVersion" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-BadModelNotSupportedVersion" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 3364830312705791335907422218790599751780160858399843169712719310945970157661 - } - - fn name_hash(self: @ContractState) -> felt252 { - 1812257929012908024237871796629728977392496349235879470060252299886369485820 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl bad_model_not_supported_versionImpl of Ibad_model_not_supported_version{ - fn ensure_abi(self: @ContractState, model: BadModelNotSupportedVersion) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__bad_model_not_supported_versionImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - bad_model_not_supported_versionImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__bad_model_not_supported_versionImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl Modelv0Introspect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'Modelv0', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct Modelv0Entity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl Modelv0EntityStoreImpl of Modelv0EntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Modelv0Entity { - Modelv0ModelEntityImpl::get(world, entity_id) - } - - fn update(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Modelv0::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl Modelv0StoreImpl of Modelv0Store { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> Modelv0 { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `Modelv0`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> Modelv0 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @Modelv0, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @Modelv0, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Modelv0::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @Modelv0, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl Modelv0ModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @Modelv0Entity) -> felt252 { - *self.__id - } - - fn values(self: @Modelv0Entity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> Modelv0Entity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `Modelv0Entity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Modelv0Entity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @Modelv0Entity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl Modelv0ModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> Modelv0 { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - Modelv0Store::from_values(ref _keys, ref values) - } - - fn set_model( - self: @Modelv0, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @Modelv0, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @Modelv0, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "Modelv0" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-Modelv0" - } - - #[inline(always)] - fn version() -> u8 { - 0 - } - - #[inline(always)] - fn selector() -> felt252 { - "Modelv0" - } - - #[inline(always)] - fn instance_selector(self: @Modelv0) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2212879130471315306779111820244908968466545702031328551192231795237740448313 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @Modelv0) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @Modelv0) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Modelv0) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @Modelv0) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodelv_0 { - fn ensure_abi(self: @T, model: Modelv0); -} - -#[starknet::contract] -pub mod modelv_0 { - use super::Modelv0; - use super::Imodelv_0; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "Modelv0" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-Modelv0" - } - - fn version(self: @ContractState) -> u8 { - 0 - } - - fn selector(self: @ContractState) -> felt252 { - "Modelv0" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2212879130471315306779111820244908968466545702031328551192231795237740448313 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl modelv_0Impl of Imodelv_0{ - fn ensure_abi(self: @ContractState, model: Modelv0) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__modelv_0Impl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - modelv_0Impl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__modelv_0Impl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithBadNamespaceFormatIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithBadNamespaceFormat', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithBadNamespaceFormatEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl ModelWithBadNamespaceFormatEntityStoreImpl of ModelWithBadNamespaceFormatEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithBadNamespaceFormatEntity { - ModelWithBadNamespaceFormatModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithBadNamespaceFormat::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithBadNamespaceFormatStoreImpl of ModelWithBadNamespaceFormatStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithBadNamespaceFormat { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithBadNamespaceFormat`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithBadNamespaceFormat { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithBadNamespaceFormat::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl ModelWithBadNamespaceFormatModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithBadNamespaceFormatEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithBadNamespaceFormatEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithBadNamespaceFormatEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithBadNamespaceFormatEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithBadNamespaceFormatEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithBadNamespaceFormatEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithBadNamespaceFormatModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithBadNamespaceFormat { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithBadNamespaceFormatStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithBadNamespaceFormat, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithBadNamespaceFormat, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithBadNamespaceFormat, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithBadNamespaceFormat" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithBadNamespaceFormat" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3339335350336894195883884955409923858499485801033572582237787132047489035817 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithBadNamespaceFormat) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 513559242384681567568052881519197161166285694153303371154270254637843894159 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithBadNamespaceFormat) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithBadNamespaceFormat) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithBadNamespaceFormat) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithBadNamespaceFormat) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_bad_namespace_format { - fn ensure_abi(self: @T, model: ModelWithBadNamespaceFormat); -} - -#[starknet::contract] -pub mod model_with_bad_namespace_format { - use super::ModelWithBadNamespaceFormat; - use super::Imodel_with_bad_namespace_format; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithBadNamespaceFormat" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithBadNamespaceFormat" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 3339335350336894195883884955409923858499485801033572582237787132047489035817 - } - - fn name_hash(self: @ContractState) -> felt252 { - 513559242384681567568052881519197161166285694153303371154270254637843894159 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_bad_namespace_formatImpl of Imodel_with_bad_namespace_format{ - fn ensure_abi(self: @ContractState, model: ModelWithBadNamespaceFormat) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_bad_namespace_formatImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_bad_namespace_formatImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_bad_namespace_formatImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithShortStringNamespaceIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithShortStringNamespace', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithShortStringNamespaceEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl ModelWithShortStringNamespaceEntityStoreImpl of ModelWithShortStringNamespaceEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithShortStringNamespaceEntity { - ModelWithShortStringNamespaceModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithShortStringNamespace::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithShortStringNamespaceStoreImpl of ModelWithShortStringNamespaceStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithShortStringNamespace { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithShortStringNamespace`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithShortStringNamespace { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithShortStringNamespace::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl ModelWithShortStringNamespaceModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithShortStringNamespaceEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithShortStringNamespaceEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithShortStringNamespaceEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithShortStringNamespaceEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithShortStringNamespaceEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithShortStringNamespaceEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithShortStringNamespaceModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithShortStringNamespace { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithShortStringNamespaceStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithShortStringNamespace, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithShortStringNamespace, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithShortStringNamespace, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithShortStringNamespace" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithShortStringNamespace" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3563011140946869267852628778244415212055246902495528859686589254859279333005 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithShortStringNamespace) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 4646597166239297873853881466258165424425132957303541470648153031188639878 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithShortStringNamespace) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithShortStringNamespace) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithShortStringNamespace) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithShortStringNamespace) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_short_string_namespace { - fn ensure_abi(self: @T, model: ModelWithShortStringNamespace); -} - -#[starknet::contract] -pub mod model_with_short_string_namespace { - use super::ModelWithShortStringNamespace; - use super::Imodel_with_short_string_namespace; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithShortStringNamespace" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithShortStringNamespace" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 3563011140946869267852628778244415212055246902495528859686589254859279333005 - } - - fn name_hash(self: @ContractState) -> felt252 { - 4646597166239297873853881466258165424425132957303541470648153031188639878 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_short_string_namespaceImpl of Imodel_with_short_string_namespace{ - fn ensure_abi(self: @ContractState, model: ModelWithShortStringNamespace) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_short_string_namespaceImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_short_string_namespaceImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_short_string_namespaceImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithStringNamespaceIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithStringNamespace', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithStringNamespaceEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl ModelWithStringNamespaceEntityStoreImpl of ModelWithStringNamespaceEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithStringNamespaceEntity { - ModelWithStringNamespaceModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithStringNamespace::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithStringNamespaceStoreImpl of ModelWithStringNamespaceStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithStringNamespace { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithStringNamespace`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithStringNamespace { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithStringNamespace::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl ModelWithStringNamespaceModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithStringNamespaceEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithStringNamespaceEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithStringNamespaceEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithStringNamespaceEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithStringNamespaceEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithStringNamespaceEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithStringNamespaceModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithStringNamespace { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithStringNamespaceStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithStringNamespace, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithStringNamespace, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithStringNamespace, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithStringNamespace" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithStringNamespace" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3428238780389029245974129676124052799610748885939447299287640410044966811336 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithStringNamespace) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 36187013840655350498900857372670392628596870210415176261336407419317644423 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithStringNamespace) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithStringNamespace) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithStringNamespace) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithStringNamespace) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_string_namespace { - fn ensure_abi(self: @T, model: ModelWithStringNamespace); -} - -#[starknet::contract] -pub mod model_with_string_namespace { - use super::ModelWithStringNamespace; - use super::Imodel_with_string_namespace; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithStringNamespace" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithStringNamespace" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 3428238780389029245974129676124052799610748885939447299287640410044966811336 - } - - fn name_hash(self: @ContractState) -> felt252 { - 36187013840655350498900857372670392628596870210415176261336407419317644423 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_string_namespaceImpl of Imodel_with_string_namespace{ - fn ensure_abi(self: @ContractState, model: ModelWithStringNamespace) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_string_namespaceImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_string_namespaceImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_string_namespaceImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl PositionIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'Position', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'v', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct PositionEntity { - __id: felt252, // private field - pub v: Vec3, - -} - -#[generate_trait] -pub impl PositionEntityStoreImpl of PositionEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PositionEntity { - PositionModelEntityImpl::get(world, entity_id) - } - - fn update(self: @PositionEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @PositionEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Position::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @PositionEntity, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl PositionStoreImpl of PositionStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> Position { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `Position`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> Position { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @Position, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @Position, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 578691550836206188651404750433984985630363913126316857592149308417275000080 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Position::v`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_v(self: @Position, world: dojo::world::IWorldDispatcher, value: Vec3) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 578691550836206188651404750433984985630363913126316857592149308417275000080, - serialized.span() - ); - } - -} - -pub impl PositionModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @PositionEntity) -> felt252 { - *self.__id - } - - fn values(self: @PositionEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> PositionEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `PositionEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PositionEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @PositionEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @PositionEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @PositionEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl PositionModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> Position { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - PositionStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @Position, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @Position, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @Position, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "Position" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-Position" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1782729361185285637005619480739442196364037716000358448825261820703351159758 - } - - #[inline(always)] - fn instance_selector(self: @Position) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2899920299641094436341712346886623904698864491830316325765258522168980161362 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @Position) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @Position) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Position) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.v, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @Position) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Iposition { - fn ensure_abi(self: @T, model: Position); -} - -#[starknet::contract] -pub mod position { - use super::Position; - use super::Iposition; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "Position" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-Position" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 1782729361185285637005619480739442196364037716000358448825261820703351159758 - } - - fn name_hash(self: @ContractState) -> felt252 { - 2899920299641094436341712346886623904698864491830316325765258522168980161362 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl positionImpl of Iposition{ - fn ensure_abi(self: @ContractState, model: Position) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__positionImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - positionImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__positionImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl RolesIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 387776731289756409274549987067854286905927440612427426920343953432870065647, - layout: dojo::model::introspect::Introspect:: ->::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'Roles', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'role_ids', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( - array![ - dojo::model::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct RolesEntity { - __id: felt252, // private field - pub role_ids: Array, - -} - -#[generate_trait] -pub impl RolesEntityStoreImpl of RolesEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> RolesEntity { - RolesModelEntityImpl::get(world, entity_id) - } - - fn update(self: @RolesEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @RolesEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_role_ids(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 387776731289756409274549987067854286905927440612427426920343953432870065647 - ); - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `Roles::role_ids`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_role_ids(self: @RolesEntity, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 387776731289756409274549987067854286905927440612427426920343953432870065647, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl RolesStoreImpl of RolesStore { - fn entity_id_from_keys() -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> Roles { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `Roles`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, ) -> Roles { - let mut serialized = core::array::ArrayTrait::new(); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @Roles, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @Roles, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_role_ids(world: dojo::world::IWorldDispatcher, ) -> Array { - let mut serialized = core::array::ArrayTrait::new(); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 387776731289756409274549987067854286905927440612427426920343953432870065647 - ); - - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `Roles::role_ids`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_role_ids(self: @Roles, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 387776731289756409274549987067854286905927440612427426920343953432870065647, - serialized.span() - ); - } - -} - -pub impl RolesModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @RolesEntity) -> felt252 { - *self.__id - } - - fn values(self: @RolesEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.role_ids, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> RolesEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `RolesEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> RolesEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @RolesEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @RolesEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @RolesEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl RolesModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> Roles { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - RolesStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @Roles, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @Roles, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @Roles, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "Roles" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-Roles" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3584099896964965841643389141246184155284218827427504603233100831001054183182 - } - - #[inline(always)] - fn instance_selector(self: @Roles) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2030971736961612564423689930729061756599290850089001157163423482274886199516 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @Roles) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @Roles) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Roles) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.role_ids, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @Roles) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Iroles { - fn ensure_abi(self: @T, model: Roles); -} - -#[starknet::contract] -pub mod roles { - use super::Roles; - use super::Iroles; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "Roles" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-Roles" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 3584099896964965841643389141246184155284218827427504603233100831001054183182 - } - - fn name_hash(self: @ContractState) -> felt252 { - 2030971736961612564423689930729061756599290850089001157163423482274886199516 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl rolesImpl of Iroles{ - fn ensure_abi(self: @ContractState, model: Roles) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__rolesImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - rolesImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__rolesImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl OnlyKeyModelIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'OnlyKeyModel', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct OnlyKeyModelEntity { - __id: felt252, // private field - -} - -#[generate_trait] -pub impl OnlyKeyModelEntityStoreImpl of OnlyKeyModelEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> OnlyKeyModelEntity { - OnlyKeyModelModelEntityImpl::get(world, entity_id) - } - - fn update(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - -} - -#[generate_trait] -pub impl OnlyKeyModelStoreImpl of OnlyKeyModelStore { - fn entity_id_from_keys(id: felt252) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> OnlyKeyModel { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `OnlyKeyModel`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> OnlyKeyModel { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, id); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @OnlyKeyModel, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @OnlyKeyModel, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - -} - -pub impl OnlyKeyModelModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @OnlyKeyModelEntity) -> felt252 { - *self.__id - } - - fn values(self: @OnlyKeyModelEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> OnlyKeyModelEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `OnlyKeyModelEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> OnlyKeyModelEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @OnlyKeyModelEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl OnlyKeyModelModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> OnlyKeyModel { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - OnlyKeyModelStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @OnlyKeyModel, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @OnlyKeyModel, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @OnlyKeyModel, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "OnlyKeyModel" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-OnlyKeyModel" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2309092000941816896446401231215693966290521919639503466118437426986900396853 - } - - #[inline(always)] - fn instance_selector(self: @OnlyKeyModel) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1001826121797570811408809643478760373535949956555931325019299477987282578617 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @OnlyKeyModel) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @OnlyKeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.id); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @OnlyKeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @OnlyKeyModel) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Ionly_key_model { - fn ensure_abi(self: @T, model: OnlyKeyModel); -} - -#[starknet::contract] -pub mod only_key_model { - use super::OnlyKeyModel; - use super::Ionly_key_model; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "OnlyKeyModel" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-OnlyKeyModel" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2309092000941816896446401231215693966290521919639503466118437426986900396853 - } - - fn name_hash(self: @ContractState) -> felt252 { - 1001826121797570811408809643478760373535949956555931325019299477987282578617 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl only_key_modelImpl of Ionly_key_model{ - fn ensure_abi(self: @ContractState, model: OnlyKeyModel) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__only_key_modelImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - only_key_modelImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__only_key_modelImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl U256KeyModelIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'U256KeyModel', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct U256KeyModelEntity { - __id: felt252, // private field - -} - -#[generate_trait] -pub impl U256KeyModelEntityStoreImpl of U256KeyModelEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> U256KeyModelEntity { - U256KeyModelModelEntityImpl::get(world, entity_id) - } - - fn update(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - -} - -#[generate_trait] -pub impl U256KeyModelStoreImpl of U256KeyModelStore { - fn entity_id_from_keys(id: u256) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@id, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> U256KeyModel { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `U256KeyModel`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, id: u256) -> U256KeyModel { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@id, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @U256KeyModel, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @U256KeyModel, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - -} - -pub impl U256KeyModelModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @U256KeyModelEntity) -> felt252 { - *self.__id - } - - fn values(self: @U256KeyModelEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> U256KeyModelEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `U256KeyModelEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> U256KeyModelEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @U256KeyModelEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl U256KeyModelModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> U256KeyModel { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - U256KeyModelStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @U256KeyModel, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @U256KeyModel, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @U256KeyModel, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "U256KeyModel" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-U256KeyModel" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2221887666320363067192826725795502610968343119143207326025439486865385474790 - } - - #[inline(always)] - fn instance_selector(self: @U256KeyModel) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1848733002266458148515852001373055968326209639346734967305014900020806934517 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @U256KeyModel) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @U256KeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.id, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @U256KeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @U256KeyModel) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Iu_256_key_model { - fn ensure_abi(self: @T, model: U256KeyModel); -} - -#[starknet::contract] -pub mod u_256_key_model { - use super::U256KeyModel; - use super::Iu_256_key_model; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "U256KeyModel" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-U256KeyModel" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2221887666320363067192826725795502610968343119143207326025439486865385474790 - } - - fn name_hash(self: @ContractState) -> felt252 { - 1848733002266458148515852001373055968326209639346734967305014900020806934517 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl u_256_key_modelImpl of Iu_256_key_model{ - fn ensure_abi(self: @ContractState, model: U256KeyModel) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__u_256_key_modelImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - u_256_key_modelImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__u_256_key_modelImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl PlayerIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(1) - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'Player', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'game', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'name', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct PlayerEntity { - __id: felt252, // private field - pub name: felt252, - -} - -#[generate_trait] -pub impl PlayerEntityStoreImpl of PlayerEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PlayerEntity { - PlayerModelEntityImpl::get(world, entity_id) - } - - fn update(self: @PlayerEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @PlayerEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_name(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> felt252 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1528802474226268325865027367859591458315299653151958663884057507666229546336 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Player::name`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_name(self: @PlayerEntity, world: dojo::world::IWorldDispatcher, value: felt252) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1528802474226268325865027367859591458315299653151958663884057507666229546336, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl PlayerStoreImpl of PlayerStore { - fn entity_id_from_keys(game: felt252, player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, game); -core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> Player { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `Player`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, game: felt252, player: ContractAddress) -> Player { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, game); -core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @Player, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @Player, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_name(world: dojo::world::IWorldDispatcher, game: felt252, player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, game); -core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1528802474226268325865027367859591458315299653151958663884057507666229546336 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `Player::name`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_name(self: @Player, world: dojo::world::IWorldDispatcher, value: felt252) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1528802474226268325865027367859591458315299653151958663884057507666229546336, - serialized.span() - ); - } - -} - -pub impl PlayerModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @PlayerEntity) -> felt252 { - *self.__id - } - - fn values(self: @PlayerEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.name); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> PlayerEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `PlayerEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PlayerEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @PlayerEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @PlayerEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @PlayerEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl PlayerModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> Player { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - PlayerStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @Player, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @Player, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @Player, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "Player" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-Player" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 32472305970791489884889070587064570056671760620943135506258424375410423946 - } - - #[inline(always)] - fn instance_selector(self: @Player) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1073075359926275415180704315933677548333097210683379121732618306925003101845 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @Player) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @Player) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.game); -core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Player) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.name); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @Player) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Iplayer { - fn ensure_abi(self: @T, model: Player); -} - -#[starknet::contract] -pub mod player { - use super::Player; - use super::Iplayer; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "Player" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-Player" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 32472305970791489884889070587064570056671760620943135506258424375410423946 - } - - fn name_hash(self: @ContractState) -> felt252 { - 1073075359926275415180704315933677548333097210683379121732618306925003101845 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl playerImpl of Iplayer{ - fn ensure_abi(self: @ContractState, model: Player) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__playerImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - playerImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__playerImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithSimpleArrayIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() - }, -dojo::model::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::introspect::Introspect:: ->::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithSimpleArray', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( - array![ - dojo::model::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithSimpleArrayEntity { - __id: felt252, // private field - pub x: u16, -pub y: Array, - -} - -#[generate_trait] -pub impl ModelWithSimpleArrayEntityStoreImpl of ModelWithSimpleArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithSimpleArrayEntity { - ModelWithSimpleArrayModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithSimpleArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `ModelWithSimpleArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_y(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithSimpleArrayStoreImpl of ModelWithSimpleArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithSimpleArray { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithSimpleArray`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithSimpleArray { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithSimpleArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> Array { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `ModelWithSimpleArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_y(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -pub impl ModelWithSimpleArrayModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithSimpleArrayEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithSimpleArrayEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithSimpleArrayEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithSimpleArrayEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithSimpleArrayEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithSimpleArrayEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithSimpleArrayModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithSimpleArray { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithSimpleArrayStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithSimpleArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithSimpleArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithSimpleArray, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithSimpleArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithSimpleArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2155888289741706273257207428305937938996511115291276975807216945184181752777 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithSimpleArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 173141902001925402715103859951360389436088950156916962046507357841237663931 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithSimpleArray) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithSimpleArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithSimpleArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithSimpleArray) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_simple_array { - fn ensure_abi(self: @T, model: ModelWithSimpleArray); -} - -#[starknet::contract] -pub mod model_with_simple_array { - use super::ModelWithSimpleArray; - use super::Imodel_with_simple_array; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithSimpleArray" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithSimpleArray" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2155888289741706273257207428305937938996511115291276975807216945184181752777 - } - - fn name_hash(self: @ContractState) -> felt252 { - 173141902001925402715103859951360389436088950156916962046507357841237663931 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_simple_arrayImpl of Imodel_with_simple_array{ - fn ensure_abi(self: @ContractState, model: ModelWithSimpleArray) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_simple_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_simple_arrayImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_simple_arrayImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithByteArrayIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() - }, -dojo::model::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithByteArray', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::ByteArray - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithByteArrayEntity { - __id: felt252, // private field - pub x: u16, -pub y: ByteArray, - -} - -#[generate_trait] -pub impl ModelWithByteArrayEntityStoreImpl of ModelWithByteArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithByteArrayEntity { - ModelWithByteArrayModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithByteArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ByteArray { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithByteArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_y(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher, value: ByteArray) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithByteArrayStoreImpl of ModelWithByteArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithByteArray { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithByteArray`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithByteArray { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithByteArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ByteArray { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithByteArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_y(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher, value: ByteArray) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -pub impl ModelWithByteArrayModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithByteArrayEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithByteArrayEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithByteArrayEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithByteArrayEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithByteArrayEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithByteArrayEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithByteArrayModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithByteArray { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithByteArrayStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithByteArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithByteArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithByteArray, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithByteArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithByteArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2309493726682581230048608406375650493303358263694405202817326852234706548038 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithByteArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2176409715042145900636260236501596599545103472111273072320531220776338338674 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithByteArray) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithByteArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithByteArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithByteArray) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_byte_array { - fn ensure_abi(self: @T, model: ModelWithByteArray); -} - -#[starknet::contract] -pub mod model_with_byte_array { - use super::ModelWithByteArray; - use super::Imodel_with_byte_array; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithByteArray" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithByteArray" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2309493726682581230048608406375650493303358263694405202817326852234706548038 - } - - fn name_hash(self: @ContractState) -> felt252 { - 2176409715042145900636260236501596599545103472111273072320531220776338338674 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_byte_arrayImpl of Imodel_with_byte_array{ - fn ensure_abi(self: @ContractState, model: ModelWithByteArray) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_byte_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_byte_arrayImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_byte_arrayImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithComplexArrayIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() - }, -dojo::model::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::introspect::Introspect:: ->::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithComplexArray', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( - array![ - dojo::model::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithComplexArrayEntity { - __id: felt252, // private field - pub x: u16, -pub y: Array, - -} - -#[generate_trait] -pub impl ModelWithComplexArrayEntityStoreImpl of ModelWithComplexArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithComplexArrayEntity { - ModelWithComplexArrayModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithComplexArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `ModelWithComplexArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_y(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithComplexArrayStoreImpl of ModelWithComplexArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithComplexArray { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithComplexArray`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithComplexArray { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithComplexArray::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> Array { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - - let field_value = core::serde::Serde::>::deserialize(ref values); - - if core::option::OptionTrait::>::is_none(@field_value) { - panic!( - "Field `ModelWithComplexArray::y`: deserialization failed." - ); - } - - core::option::OptionTrait::>::unwrap(field_value) - } - - fn set_y(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher, value: Array) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -pub impl ModelWithComplexArrayModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithComplexArrayEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithComplexArrayEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithComplexArrayEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithComplexArrayEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithComplexArrayEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithComplexArrayEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithComplexArrayModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithComplexArray { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithComplexArrayStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithComplexArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithComplexArray, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithComplexArray, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithComplexArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithComplexArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1293570145807126672811046976011709110822800800255162893130594439459909679461 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithComplexArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2866472224509756243720005045848892642397514372569303051745174230372637769655 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithComplexArray) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithComplexArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithComplexArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithComplexArray) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_complex_array { - fn ensure_abi(self: @T, model: ModelWithComplexArray); -} - -#[starknet::contract] -pub mod model_with_complex_array { - use super::ModelWithComplexArray; - use super::Imodel_with_complex_array; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithComplexArray" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithComplexArray" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 1293570145807126672811046976011709110822800800255162893130594439459909679461 - } - - fn name_hash(self: @ContractState) -> felt252 { - 2866472224509756243720005045848892642397514372569303051745174230372637769655 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_complex_arrayImpl of Imodel_with_complex_array{ - fn ensure_abi(self: @ContractState, model: ModelWithComplexArray) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_complex_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_complex_arrayImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_complex_arrayImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithTupleIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(4) - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() - }, -dojo::model::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::Layout::Tuple( - array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithTuple', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( - array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithTupleEntity { - __id: felt252, // private field - pub x: u16, -pub y: (u8, u16, u32), - -} - -#[generate_trait] -pub impl ModelWithTupleEntityStoreImpl of ModelWithTupleEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleEntity { - ModelWithTupleModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithTuple::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, u16, u32) { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - let field_value = core::serde::Serde::<(u8, u16, u32)>::deserialize(ref values); - - if core::option::OptionTrait::<(u8, u16, u32)>::is_none(@field_value) { - panic!( - "Field `ModelWithTuple::y`: deserialization failed." - ); - } - - core::option::OptionTrait::<(u8, u16, u32)>::unwrap(field_value) - } - - fn set_y(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher, value: (u8, u16, u32)) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithTupleStoreImpl of ModelWithTupleStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithTuple { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithTuple`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithTuple { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithTuple::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> (u8, u16, u32) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - - let field_value = core::serde::Serde::<(u8, u16, u32)>::deserialize(ref values); - - if core::option::OptionTrait::<(u8, u16, u32)>::is_none(@field_value) { - panic!( - "Field `ModelWithTuple::y`: deserialization failed." - ); - } - - core::option::OptionTrait::<(u8, u16, u32)>::unwrap(field_value) - } - - fn set_y(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher, value: (u8, u16, u32)) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -pub impl ModelWithTupleModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithTupleEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithTupleEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithTupleEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithTupleEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithTupleEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithTupleModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithTuple { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithTupleStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithTuple, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithTuple, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithTuple, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithTuple" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithTuple" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2556860780543194947392385177981405629628409496147617432088261544126553394590 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithTuple) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3222351670132870101782632958288197874250493316621507272653773018669253981260 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithTuple) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithTuple) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithTuple) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithTuple) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_tuple { - fn ensure_abi(self: @T, model: ModelWithTuple); -} - -#[starknet::contract] -pub mod model_with_tuple { - use super::ModelWithTuple; - use super::Imodel_with_tuple; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithTuple" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithTuple" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 2556860780543194947392385177981405629628409496147617432088261544126553394590 - } - - fn name_hash(self: @ContractState) -> felt252 { - 3222351670132870101782632958288197874250493316621507272653773018669253981260 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_tupleImpl of Imodel_with_tuple{ - fn ensure_abi(self: @ContractState, model: ModelWithTuple) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_tupleImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_tupleImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_tupleImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -impl ModelWithTupleNoPrimitivesIntrospect<> of dojo::model::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), -Option::Some(3) - ]; - - if dojo::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::utils::sum(sizes)) - - } - - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( - array![ - dojo::model::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() - }, -dojo::model::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::Layout::Tuple( - array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { - name: 'ModelWithTupleNoPrimitives', - attrs: array![].span(), - children: array![ - dojo::model::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() - }, -dojo::model::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( - array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -#[derive(Drop, Serde)] -pub struct ModelWithTupleNoPrimitivesEntity { - __id: felt252, // private field - pub x: u16, -pub y: (u8, Vec3, u32), - -} - -#[generate_trait] -pub impl ModelWithTupleNoPrimitivesEntityStoreImpl of ModelWithTupleNoPrimitivesEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleNoPrimitivesEntity { - ModelWithTupleNoPrimitivesModelEntityImpl::get(world, entity_id) - } - - fn update(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::update_entity(self, world); - } - - fn delete(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher) { - dojo::model::ModelEntity::::delete_entity(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithTupleNoPrimitives::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, Vec3, u32) { - let mut values = dojo::model::ModelEntity::::get_member( - world, - entity_id, - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - let field_value = core::serde::Serde::<(u8, Vec3, u32)>::deserialize(ref values); - - if core::option::OptionTrait::<(u8, Vec3, u32)>::is_none(@field_value) { - panic!( - "Field `ModelWithTupleNoPrimitives::y`: deserialization failed." - ); - } - - core::option::OptionTrait::<(u8, Vec3, u32)>::unwrap(field_value) - } - - fn set_y(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher, value: (u8, Vec3, u32)) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -#[generate_trait] -pub impl ModelWithTupleNoPrimitivesStoreImpl of ModelWithTupleNoPrimitivesStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - core::poseidon::poseidon_hash_span(serialized.span()) - } - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithTupleNoPrimitives { - let mut serialized = core::array::ArrayTrait::new(); - serialized.append_span(keys); - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity = core::serde::Serde::::deserialize(ref serialized); - - if core::option::OptionTrait::::is_none(@entity) { - panic!( - "Model `ModelWithTupleNoPrimitives`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." - ); - } - - core::option::OptionTrait::::unwrap(entity) - } - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithTupleNoPrimitives { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - dojo::model::Model::::get(world, serialized.span()) - } - - fn set(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::set_model(self, world); - } - - fn delete(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher) { - dojo::model::Model::::delete_model(self, world); - } - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16 { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 512066735765477566404754172672287371265995314501343422459174036873487219331 - ); - - let field_value = core::serde::Serde::::deserialize(ref values); - - if core::option::OptionTrait::::is_none(@field_value) { - panic!( - "Field `ModelWithTupleNoPrimitives::x`: deserialization failed." - ); - } - - core::option::OptionTrait::::unwrap(field_value) - } - - fn set_x(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher, value: u16) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 512066735765477566404754172672287371265995314501343422459174036873487219331, - serialized.span() - ); - } - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> (u8, Vec3, u32) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@player, ref serialized); - - - let mut values = dojo::model::Model::::get_member( - world, - serialized.span(), - 1591024729085637502504777720563487898377940395575083379770417352976841400819 - ); - - let field_value = core::serde::Serde::<(u8, Vec3, u32)>::deserialize(ref values); - - if core::option::OptionTrait::<(u8, Vec3, u32)>::is_none(@field_value) { - panic!( - "Field `ModelWithTupleNoPrimitives::y`: deserialization failed." - ); - } - - core::option::OptionTrait::<(u8, Vec3, u32)>::unwrap(field_value) - } - - fn set_y(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher, value: (u8, Vec3, u32)) { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(@value, ref serialized); - - self.set_member( - world, - 1591024729085637502504777720563487898377940395575083379770417352976841400819, - serialized.span() - ); - } - -} - -pub impl ModelWithTupleNoPrimitivesModelEntityImpl of dojo::model::ModelEntity { - fn id(self: @ModelWithTupleNoPrimitivesEntity) -> felt252 { - *self.__id - } - - fn values(self: @ModelWithTupleNoPrimitivesEntity) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - fn from_values(entity_id: felt252, ref values: Span) -> ModelWithTupleNoPrimitivesEntity { - let mut serialized = array![entity_id]; - serialized.append_span(values); - let mut serialized = core::array::ArrayTrait::span(@serialized); - - let entity_values = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity_values) { - panic!( - "ModelEntity `ModelWithTupleNoPrimitivesEntity`: deserialization failed." - ); - } - core::option::OptionTrait::::unwrap(entity_values) - } - - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleNoPrimitivesEntity { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(entity_id), - dojo::model::Model::::layout() - ); - Self::from_values(entity_id, ref values) - } - - fn update_entity(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - self.values(), - dojo::model::Model::::layout() - ); - } - - fn delete_entity(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::Id(self.id()), - dojo::model::Model::::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - entity_id: felt252, - member_id: felt252, - ) -> Span { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithTupleNoPrimitivesEntity, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span, - ) { - match dojo::utils::find_model_field_layout(dojo::model::Model::::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - dojo::model::Model::::selector(), - dojo::model::ModelIndex::MemberId((self.id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } -} - -pub impl ModelWithTupleNoPrimitivesModelImpl of dojo::model::Model { - fn get(world: dojo::world::IWorldDispatcher, keys: Span) -> ModelWithTupleNoPrimitives { - let mut values = dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(keys), - Self::layout() - ); - let mut _keys = keys; - - ModelWithTupleNoPrimitivesStore::from_values(ref _keys, ref values) - } - - fn set_model( - self: @ModelWithTupleNoPrimitives, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::values(self), - Self::layout() - ); - } - - fn delete_model( - self: @ModelWithTupleNoPrimitives, - world: dojo::world::IWorldDispatcher - ) { - dojo::world::IWorldDispatcherTrait::delete_entity( - world, - Self::selector(), - dojo::model::ModelIndex::Keys(Self::keys(self)), - Self::layout() - ); - } - - fn get_member( - world: dojo::world::IWorldDispatcher, - keys: Span, - member_id: felt252 - ) -> Span { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - let entity_id = dojo::utils::entity_id_from_keys(keys); - dojo::world::IWorldDispatcherTrait::entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((entity_id, member_id)), - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - fn set_member( - self: @ModelWithTupleNoPrimitives, - world: dojo::world::IWorldDispatcher, - member_id: felt252, - values: Span - ) { - match dojo::utils::find_model_field_layout(Self::layout(), member_id) { - Option::Some(field_layout) => { - dojo::world::IWorldDispatcherTrait::set_entity( - world, - Self::selector(), - dojo::model::ModelIndex::MemberId((self.entity_id(), member_id)), - values, - field_layout - ) - }, - Option::None => core::panic_with_felt252('bad member id') - } - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithTupleNoPrimitives" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_test" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_test-ModelWithTupleNoPrimitives" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 59168777730614245274545541976317431416582911855710103554159293691166950405 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithTupleNoPrimitives) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 157059227407493660591195028728750607977045261142495925435047270200565107096 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - #[inline(always)] - fn entity_id(self: @ModelWithTupleNoPrimitives) -> felt252 { - core::poseidon::poseidon_hash_span(self.keys()) - } - - #[inline(always)] - fn keys(self: @ModelWithTupleNoPrimitives) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithTupleNoPrimitives) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized); -core::serde::Serde::serialize(self.y, ref serialized); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::model::Layout { - dojo::model::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @ModelWithTupleNoPrimitives) -> dojo::model::Layout { - Self::layout() - } - - #[inline(always)] - fn packed_size() -> Option { - dojo::model::layout::compute_packed_size(Self::layout()) - } -} - -#[starknet::interface] -pub trait Imodel_with_tuple_no_primitives { - fn ensure_abi(self: @T, model: ModelWithTupleNoPrimitives); -} - -#[starknet::contract] -pub mod model_with_tuple_no_primitives { - use super::ModelWithTupleNoPrimitives; - use super::Imodel_with_tuple_no_primitives; - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - "ModelWithTupleNoPrimitives" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ModelWithTupleNoPrimitives" - } - - fn version(self: @ContractState) -> u8 { - 1 - } - - fn selector(self: @ContractState) -> felt252 { - 59168777730614245274545541976317431416582911855710103554159293691166950405 - } - - fn name_hash(self: @ContractState) -> felt252 { - 157059227407493660591195028728750607977045261142495925435047270200565107096 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn unpacked_size(self: @ContractState) -> Option { - dojo::model::introspect::Introspect::::size() - } - - fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() - } - - fn layout(self: @ContractState) -> dojo::model::Layout { - dojo::model::Model::::layout() - } - - fn schema(self: @ContractState) -> dojo::model::introspect::Ty { - dojo::model::introspect::Introspect::::ty() - } - } - - #[abi(embed_v0)] - impl model_with_tuple_no_primitivesImpl of Imodel_with_tuple_no_primitives{ - fn ensure_abi(self: @ContractState, model: ModelWithTupleNoPrimitives) { - } - } -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ContractState { -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::version(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::unpacked_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::packed_size(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::>::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::layout(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = DojoModelImpl::schema(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__model_with_tuple_no_primitivesImpl__ensure_abi(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_model = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - model_with_tuple_no_primitivesImpl::ensure_abi(@contract_state, __arg_model); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__DojoModelImpl__name as name; - pub use super::__wrapper__DojoModelImpl__namespace as namespace; - pub use super::__wrapper__DojoModelImpl__tag as tag; - pub use super::__wrapper__DojoModelImpl__version as version; - pub use super::__wrapper__DojoModelImpl__selector as selector; - pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; - pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; - pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; - pub use super::__wrapper__DojoModelImpl__layout as layout; - pub use super::__wrapper__DojoModelImpl__schema as schema; - pub use super::__wrapper__model_with_tuple_no_primitivesImpl__ensure_abi as ensure_abi; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} -impl BadModelMultipleVersionsEntityDrop of core::traits::Drop::; -impl BadModelMultipleVersionsEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelMultipleVersionsEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelMultipleVersionsEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelMultipleVersionsEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelMultipleVersionsEntity; - - fn update(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelMultipleVersionsEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelMultipleVersionsStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelMultipleVersions; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelMultipleVersions; - - fn set(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelMultipleVersions, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_multiple_versionsDispatcherTrait { - fn ensure_abi(self: T, model: BadModelMultipleVersions); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_multiple_versionsDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_multiple_versionsDispatcherImpl of Ibad_model_multiple_versionsDispatcherTrait { - fn ensure_abi(self: Ibad_model_multiple_versionsDispatcher, model: BadModelMultipleVersions) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_multiple_versionsLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_multiple_versionsLibraryDispatcherImpl of Ibad_model_multiple_versionsDispatcherTrait { - fn ensure_abi(self: Ibad_model_multiple_versionsLibraryDispatcher, model: BadModelMultipleVersions) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_multiple_versionsSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelMultipleVersions) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_multiple_versionsSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_multiple_versionsSafeLibraryDispatcherImpl of Ibad_model_multiple_versionsSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_multiple_versionsSafeLibraryDispatcher, model: BadModelMultipleVersions) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_multiple_versionsSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_multiple_versionsSafeDispatcherImpl of Ibad_model_multiple_versionsSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_multiple_versionsSafeDispatcher, model: BadModelMultipleVersions) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl BadModelBadVersionTypeEntityDrop of core::traits::Drop::; -impl BadModelBadVersionTypeEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelBadVersionTypeEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelBadVersionTypeEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelBadVersionTypeEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelBadVersionTypeEntity; - - fn update(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelBadVersionTypeEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelBadVersionTypeStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelBadVersionType; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelBadVersionType; - - fn set(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelBadVersionType, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_bad_version_typeDispatcherTrait { - fn ensure_abi(self: T, model: BadModelBadVersionType); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_bad_version_typeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_bad_version_typeDispatcherImpl of Ibad_model_bad_version_typeDispatcherTrait { - fn ensure_abi(self: Ibad_model_bad_version_typeDispatcher, model: BadModelBadVersionType) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_bad_version_typeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_bad_version_typeLibraryDispatcherImpl of Ibad_model_bad_version_typeDispatcherTrait { - fn ensure_abi(self: Ibad_model_bad_version_typeLibraryDispatcher, model: BadModelBadVersionType) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_bad_version_typeSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelBadVersionType) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_bad_version_typeSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_bad_version_typeSafeLibraryDispatcherImpl of Ibad_model_bad_version_typeSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_bad_version_typeSafeLibraryDispatcher, model: BadModelBadVersionType) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_bad_version_typeSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_bad_version_typeSafeDispatcherImpl of Ibad_model_bad_version_typeSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_bad_version_typeSafeDispatcher, model: BadModelBadVersionType) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl BadModelNoVersionValueEntityDrop of core::traits::Drop::; -impl BadModelNoVersionValueEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelNoVersionValueEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelNoVersionValueEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelNoVersionValueEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNoVersionValueEntity; - - fn update(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelNoVersionValueEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelNoVersionValueStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelNoVersionValue; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelNoVersionValue; - - fn set(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelNoVersionValue, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_no_version_valueDispatcherTrait { - fn ensure_abi(self: T, model: BadModelNoVersionValue); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_no_version_valueDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_no_version_valueDispatcherImpl of Ibad_model_no_version_valueDispatcherTrait { - fn ensure_abi(self: Ibad_model_no_version_valueDispatcher, model: BadModelNoVersionValue) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_no_version_valueLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_no_version_valueLibraryDispatcherImpl of Ibad_model_no_version_valueDispatcherTrait { - fn ensure_abi(self: Ibad_model_no_version_valueLibraryDispatcher, model: BadModelNoVersionValue) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_no_version_valueSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelNoVersionValue) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_no_version_valueSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_no_version_valueSafeLibraryDispatcherImpl of Ibad_model_no_version_valueSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_no_version_valueSafeLibraryDispatcher, model: BadModelNoVersionValue) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_no_version_valueSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_no_version_valueSafeDispatcherImpl of Ibad_model_no_version_valueSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_no_version_valueSafeDispatcher, model: BadModelNoVersionValue) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl BadModelUnexpectedArgWithValueEntityDrop of core::traits::Drop::; -impl BadModelUnexpectedArgWithValueEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelUnexpectedArgWithValueEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelUnexpectedArgWithValueEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelUnexpectedArgWithValueEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgWithValueEntity; - - fn update(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelUnexpectedArgWithValueEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelUnexpectedArgWithValueStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelUnexpectedArgWithValue; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelUnexpectedArgWithValue; - - fn set(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelUnexpectedArgWithValue, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_unexpected_arg_with_valueDispatcherTrait { - fn ensure_abi(self: T, model: BadModelUnexpectedArgWithValue); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_arg_with_valueDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_unexpected_arg_with_valueDispatcherImpl of Ibad_model_unexpected_arg_with_valueDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueDispatcher, model: BadModelUnexpectedArgWithValue) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_arg_with_valueLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherImpl of Ibad_model_unexpected_arg_with_valueDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueLibraryDispatcher, model: BadModelUnexpectedArgWithValue) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherImpl of Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_arg_with_valueSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherImpl of Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueSafeDispatcher, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl BadModelUnexpectedArgEntityDrop of core::traits::Drop::; -impl BadModelUnexpectedArgEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelUnexpectedArgEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelUnexpectedArgEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelUnexpectedArgEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelUnexpectedArgEntity; - - fn update(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelUnexpectedArgEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelUnexpectedArgStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelUnexpectedArg; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelUnexpectedArg; - - fn set(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelUnexpectedArg, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_unexpected_argDispatcherTrait { - fn ensure_abi(self: T, model: BadModelUnexpectedArg); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_argDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_unexpected_argDispatcherImpl of Ibad_model_unexpected_argDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_argDispatcher, model: BadModelUnexpectedArg) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_argLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_unexpected_argLibraryDispatcherImpl of Ibad_model_unexpected_argDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_argLibraryDispatcher, model: BadModelUnexpectedArg) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_unexpected_argSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_argSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_unexpected_argSafeLibraryDispatcherImpl of Ibad_model_unexpected_argSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_argSafeLibraryDispatcher, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_unexpected_argSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_unexpected_argSafeDispatcherImpl of Ibad_model_unexpected_argSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_unexpected_argSafeDispatcher, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl BadModelNotSupportedVersionEntityDrop of core::traits::Drop::; -impl BadModelNotSupportedVersionEntitySerde of core::serde::Serde:: { - fn serialize(self: @BadModelNotSupportedVersionEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(BadModelNotSupportedVersionEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait BadModelNotSupportedVersionEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> BadModelNotSupportedVersionEntity; - - fn update(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @BadModelNotSupportedVersionEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait BadModelNotSupportedVersionStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> BadModelNotSupportedVersion; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> BadModelNotSupportedVersion; - - fn set(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher); - - fn delete(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @BadModelNotSupportedVersion, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Ibad_model_not_supported_versionDispatcherTrait { - fn ensure_abi(self: T, model: BadModelNotSupportedVersion); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_not_supported_versionDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_not_supported_versionDispatcherImpl of Ibad_model_not_supported_versionDispatcherTrait { - fn ensure_abi(self: Ibad_model_not_supported_versionDispatcher, model: BadModelNotSupportedVersion) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_not_supported_versionLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_not_supported_versionLibraryDispatcherImpl of Ibad_model_not_supported_versionDispatcherTrait { - fn ensure_abi(self: Ibad_model_not_supported_versionLibraryDispatcher, model: BadModelNotSupportedVersion) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ibad_model_not_supported_versionSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_not_supported_versionSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ibad_model_not_supported_versionSafeLibraryDispatcherImpl of Ibad_model_not_supported_versionSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_not_supported_versionSafeLibraryDispatcher, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ibad_model_not_supported_versionSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ibad_model_not_supported_versionSafeDispatcherImpl of Ibad_model_not_supported_versionSafeDispatcherTrait { - fn ensure_abi(self: Ibad_model_not_supported_versionSafeDispatcher, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl Modelv0EntityDrop of core::traits::Drop::; -impl Modelv0EntitySerde of core::serde::Serde:: { - fn serialize(self: @Modelv0Entity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Modelv0Entity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait Modelv0EntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Modelv0Entity; - - fn update(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @Modelv0Entity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Modelv0Store { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> Modelv0; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> Modelv0; - - fn set(self: @Modelv0, world: dojo::world::IWorldDispatcher); - - fn delete(self: @Modelv0, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @Modelv0, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Imodelv_0DispatcherTrait { - fn ensure_abi(self: T, model: Modelv0); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodelv_0Dispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodelv_0DispatcherImpl of Imodelv_0DispatcherTrait { - fn ensure_abi(self: Imodelv_0Dispatcher, model: Modelv0) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodelv_0LibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodelv_0LibraryDispatcherImpl of Imodelv_0DispatcherTrait { - fn ensure_abi(self: Imodelv_0LibraryDispatcher, model: Modelv0) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodelv_0SafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: Modelv0) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodelv_0SafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodelv_0SafeLibraryDispatcherImpl of Imodelv_0SafeDispatcherTrait { - fn ensure_abi(self: Imodelv_0SafeLibraryDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodelv_0SafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodelv_0SafeDispatcherImpl of Imodelv_0SafeDispatcherTrait { - fn ensure_abi(self: Imodelv_0SafeDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithBadNamespaceFormatEntityDrop of core::traits::Drop::; -impl ModelWithBadNamespaceFormatEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithBadNamespaceFormatEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithBadNamespaceFormatEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithBadNamespaceFormatEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithBadNamespaceFormatEntity; - - fn update(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @ModelWithBadNamespaceFormatEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait ModelWithBadNamespaceFormatStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithBadNamespaceFormat; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithBadNamespaceFormat; - - fn set(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @ModelWithBadNamespaceFormat, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Imodel_with_bad_namespace_formatDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_bad_namespace_formatDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_bad_namespace_formatDispatcherImpl of Imodel_with_bad_namespace_formatDispatcherTrait { - fn ensure_abi(self: Imodel_with_bad_namespace_formatDispatcher, model: ModelWithBadNamespaceFormat) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_bad_namespace_formatLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_bad_namespace_formatLibraryDispatcherImpl of Imodel_with_bad_namespace_formatDispatcherTrait { - fn ensure_abi(self: Imodel_with_bad_namespace_formatLibraryDispatcher, model: ModelWithBadNamespaceFormat) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_bad_namespace_formatSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_bad_namespace_formatSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherImpl of Imodel_with_bad_namespace_formatSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_bad_namespace_formatSafeLibraryDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_bad_namespace_formatSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_bad_namespace_formatSafeDispatcherImpl of Imodel_with_bad_namespace_formatSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_bad_namespace_formatSafeDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithShortStringNamespaceEntityDrop of core::traits::Drop::; -impl ModelWithShortStringNamespaceEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithShortStringNamespaceEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithShortStringNamespaceEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithShortStringNamespaceEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithShortStringNamespaceEntity; - - fn update(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @ModelWithShortStringNamespaceEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait ModelWithShortStringNamespaceStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithShortStringNamespace; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithShortStringNamespace; - - fn set(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @ModelWithShortStringNamespace, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Imodel_with_short_string_namespaceDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithShortStringNamespace); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_short_string_namespaceDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_short_string_namespaceDispatcherImpl of Imodel_with_short_string_namespaceDispatcherTrait { - fn ensure_abi(self: Imodel_with_short_string_namespaceDispatcher, model: ModelWithShortStringNamespace) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_short_string_namespaceLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_short_string_namespaceLibraryDispatcherImpl of Imodel_with_short_string_namespaceDispatcherTrait { - fn ensure_abi(self: Imodel_with_short_string_namespaceLibraryDispatcher, model: ModelWithShortStringNamespace) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_short_string_namespaceSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_short_string_namespaceSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherImpl of Imodel_with_short_string_namespaceSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_short_string_namespaceSafeLibraryDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_short_string_namespaceSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_short_string_namespaceSafeDispatcherImpl of Imodel_with_short_string_namespaceSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_short_string_namespaceSafeDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithStringNamespaceEntityDrop of core::traits::Drop::; -impl ModelWithStringNamespaceEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithStringNamespaceEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithStringNamespaceEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithStringNamespaceEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithStringNamespaceEntity; - - fn update(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @ModelWithStringNamespaceEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait ModelWithStringNamespaceStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithStringNamespace; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> ModelWithStringNamespace; - - fn set(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @ModelWithStringNamespace, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait Imodel_with_string_namespaceDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithStringNamespace); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_string_namespaceDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_string_namespaceDispatcherImpl of Imodel_with_string_namespaceDispatcherTrait { - fn ensure_abi(self: Imodel_with_string_namespaceDispatcher, model: ModelWithStringNamespace) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_string_namespaceLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_string_namespaceLibraryDispatcherImpl of Imodel_with_string_namespaceDispatcherTrait { - fn ensure_abi(self: Imodel_with_string_namespaceLibraryDispatcher, model: ModelWithStringNamespace) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_string_namespaceSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithStringNamespace) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_string_namespaceSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_string_namespaceSafeLibraryDispatcherImpl of Imodel_with_string_namespaceSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_string_namespaceSafeLibraryDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_string_namespaceSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_string_namespaceSafeDispatcherImpl of Imodel_with_string_namespaceSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_string_namespaceSafeDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl PositionEntityDrop of core::traits::Drop::; -impl PositionEntitySerde of core::serde::Serde:: { - fn serialize(self: @PositionEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.v, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(PositionEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - v: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait PositionEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PositionEntity; - - fn update(self: @PositionEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @PositionEntity, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; - - fn set_v(self: @PositionEntity, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait PositionStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> Position; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> Position; - - fn set(self: @Position, world: dojo::world::IWorldDispatcher); - - fn delete(self: @Position, world: dojo::world::IWorldDispatcher); - - - fn get_v(world: dojo::world::IWorldDispatcher, id: felt252) -> Vec3; - - fn set_v(self: @Position, world: dojo::world::IWorldDispatcher, value: Vec3); - -} -pub trait IpositionDispatcherTrait { - fn ensure_abi(self: T, model: Position); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IpositionDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IpositionDispatcherImpl of IpositionDispatcherTrait { - fn ensure_abi(self: IpositionDispatcher, model: Position) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IpositionLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IpositionLibraryDispatcherImpl of IpositionDispatcherTrait { - fn ensure_abi(self: IpositionLibraryDispatcher, model: Position) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait IpositionSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: Position) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IpositionSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IpositionSafeLibraryDispatcherImpl of IpositionSafeDispatcherTrait { - fn ensure_abi(self: IpositionSafeLibraryDispatcher, model: Position) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IpositionSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IpositionSafeDispatcherImpl of IpositionSafeDispatcherTrait { - fn ensure_abi(self: IpositionSafeDispatcher, model: Position) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl RolesEntityDrop of core::traits::Drop::; -impl RolesEntitySerde of core::serde::Serde:: { - fn serialize(self: @RolesEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.role_ids, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(RolesEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - role_ids: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait RolesEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> RolesEntity; - - fn update(self: @RolesEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @RolesEntity, world: dojo::world::IWorldDispatcher); - - - fn get_role_ids(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array; - - fn set_role_ids(self: @RolesEntity, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait RolesStore { - fn entity_id_from_keys() -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> Roles; - - fn get(world: dojo::world::IWorldDispatcher, ) -> Roles; - - fn set(self: @Roles, world: dojo::world::IWorldDispatcher); - - fn delete(self: @Roles, world: dojo::world::IWorldDispatcher); - - - fn get_role_ids(world: dojo::world::IWorldDispatcher, ) -> Array; - - fn set_role_ids(self: @Roles, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait IrolesDispatcherTrait { - fn ensure_abi(self: T, model: Roles); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IrolesDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IrolesDispatcherImpl of IrolesDispatcherTrait { - fn ensure_abi(self: IrolesDispatcher, model: Roles) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IrolesLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IrolesLibraryDispatcherImpl of IrolesDispatcherTrait { - fn ensure_abi(self: IrolesLibraryDispatcher, model: Roles) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait IrolesSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: Roles) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IrolesSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IrolesSafeLibraryDispatcherImpl of IrolesSafeDispatcherTrait { - fn ensure_abi(self: IrolesSafeLibraryDispatcher, model: Roles) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IrolesSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IrolesSafeDispatcherImpl of IrolesSafeDispatcherTrait { - fn ensure_abi(self: IrolesSafeDispatcher, model: Roles) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl OnlyKeyModelEntityDrop of core::traits::Drop::; -impl OnlyKeyModelEntitySerde of core::serde::Serde:: { - fn serialize(self: @OnlyKeyModelEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(OnlyKeyModelEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait OnlyKeyModelEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> OnlyKeyModelEntity; - - fn update(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @OnlyKeyModelEntity, world: dojo::world::IWorldDispatcher); - - -} -pub trait OnlyKeyModelStore { - fn entity_id_from_keys(id: felt252) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> OnlyKeyModel; - - fn get(world: dojo::world::IWorldDispatcher, id: felt252) -> OnlyKeyModel; - - fn set(self: @OnlyKeyModel, world: dojo::world::IWorldDispatcher); - - fn delete(self: @OnlyKeyModel, world: dojo::world::IWorldDispatcher); - - -} -pub trait Ionly_key_modelDispatcherTrait { - fn ensure_abi(self: T, model: OnlyKeyModel); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ionly_key_modelDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ionly_key_modelDispatcherImpl of Ionly_key_modelDispatcherTrait { - fn ensure_abi(self: Ionly_key_modelDispatcher, model: OnlyKeyModel) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ionly_key_modelLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ionly_key_modelLibraryDispatcherImpl of Ionly_key_modelDispatcherTrait { - fn ensure_abi(self: Ionly_key_modelLibraryDispatcher, model: OnlyKeyModel) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Ionly_key_modelSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: OnlyKeyModel) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ionly_key_modelSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Ionly_key_modelSafeLibraryDispatcherImpl of Ionly_key_modelSafeDispatcherTrait { - fn ensure_abi(self: Ionly_key_modelSafeLibraryDispatcher, model: OnlyKeyModel) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Ionly_key_modelSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Ionly_key_modelSafeDispatcherImpl of Ionly_key_modelSafeDispatcherTrait { - fn ensure_abi(self: Ionly_key_modelSafeDispatcher, model: OnlyKeyModel) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl U256KeyModelEntityDrop of core::traits::Drop::; -impl U256KeyModelEntitySerde of core::serde::Serde:: { - fn serialize(self: @U256KeyModelEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(U256KeyModelEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait U256KeyModelEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> U256KeyModelEntity; - - fn update(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @U256KeyModelEntity, world: dojo::world::IWorldDispatcher); - - -} -pub trait U256KeyModelStore { - fn entity_id_from_keys(id: u256) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> U256KeyModel; - - fn get(world: dojo::world::IWorldDispatcher, id: u256) -> U256KeyModel; - - fn set(self: @U256KeyModel, world: dojo::world::IWorldDispatcher); - - fn delete(self: @U256KeyModel, world: dojo::world::IWorldDispatcher); - - -} -pub trait Iu_256_key_modelDispatcherTrait { - fn ensure_abi(self: T, model: U256KeyModel); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Iu_256_key_modelDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Iu_256_key_modelDispatcherImpl of Iu_256_key_modelDispatcherTrait { - fn ensure_abi(self: Iu_256_key_modelDispatcher, model: U256KeyModel) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Iu_256_key_modelLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Iu_256_key_modelLibraryDispatcherImpl of Iu_256_key_modelDispatcherTrait { - fn ensure_abi(self: Iu_256_key_modelLibraryDispatcher, model: U256KeyModel) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Iu_256_key_modelSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: U256KeyModel) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Iu_256_key_modelSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Iu_256_key_modelSafeLibraryDispatcherImpl of Iu_256_key_modelSafeDispatcherTrait { - fn ensure_abi(self: Iu_256_key_modelSafeLibraryDispatcher, model: U256KeyModel) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Iu_256_key_modelSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Iu_256_key_modelSafeDispatcherImpl of Iu_256_key_modelSafeDispatcherTrait { - fn ensure_abi(self: Iu_256_key_modelSafeDispatcher, model: U256KeyModel) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl PlayerEntityDrop of core::traits::Drop::; -impl PlayerEntitySerde of core::serde::Serde:: { - fn serialize(self: @PlayerEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.name, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(PlayerEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - name: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait PlayerEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> PlayerEntity; - - fn update(self: @PlayerEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @PlayerEntity, world: dojo::world::IWorldDispatcher); - - - fn get_name(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> felt252; - - fn set_name(self: @PlayerEntity, world: dojo::world::IWorldDispatcher, value: felt252); - -} -pub trait PlayerStore { - fn entity_id_from_keys(game: felt252, player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> Player; - - fn get(world: dojo::world::IWorldDispatcher, game: felt252, player: ContractAddress) -> Player; - - fn set(self: @Player, world: dojo::world::IWorldDispatcher); - - fn delete(self: @Player, world: dojo::world::IWorldDispatcher); - - - fn get_name(world: dojo::world::IWorldDispatcher, game: felt252, player: ContractAddress) -> felt252; - - fn set_name(self: @Player, world: dojo::world::IWorldDispatcher, value: felt252); - -} -pub trait IplayerDispatcherTrait { - fn ensure_abi(self: T, model: Player); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IplayerDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IplayerDispatcherImpl of IplayerDispatcherTrait { - fn ensure_abi(self: IplayerDispatcher, model: Player) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IplayerLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IplayerLibraryDispatcherImpl of IplayerDispatcherTrait { - fn ensure_abi(self: IplayerLibraryDispatcher, model: Player) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait IplayerSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: Player) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IplayerSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IplayerSafeLibraryDispatcherImpl of IplayerSafeDispatcherTrait { - fn ensure_abi(self: IplayerSafeLibraryDispatcher, model: Player) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct IplayerSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IplayerSafeDispatcherImpl of IplayerSafeDispatcherTrait { - fn ensure_abi(self: IplayerSafeDispatcher, model: Player) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithSimpleArrayEntityDrop of core::traits::Drop::; -impl ModelWithSimpleArrayEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithSimpleArrayEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.x, ref output); - core::serde::Serde::serialize(self.y, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithSimpleArrayEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - x: core::serde::Serde::deserialize(ref serialized)?, - y: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithSimpleArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithSimpleArrayEntity; - - fn update(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; - - fn set_x(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array; - - fn set_y(self: @ModelWithSimpleArrayEntity, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait ModelWithSimpleArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithSimpleArray; - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithSimpleArray; - - fn set(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16; - - fn set_x(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> Array; - - fn set_y(self: @ModelWithSimpleArray, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait Imodel_with_simple_arrayDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithSimpleArray); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_simple_arrayDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_simple_arrayDispatcherImpl of Imodel_with_simple_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_simple_arrayDispatcher, model: ModelWithSimpleArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_simple_arrayLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_simple_arrayLibraryDispatcherImpl of Imodel_with_simple_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_simple_arrayLibraryDispatcher, model: ModelWithSimpleArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_simple_arraySafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithSimpleArray) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_simple_arraySafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_simple_arraySafeLibraryDispatcherImpl of Imodel_with_simple_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_simple_arraySafeLibraryDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_simple_arraySafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_simple_arraySafeDispatcherImpl of Imodel_with_simple_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_simple_arraySafeDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithByteArrayEntityDrop of core::traits::Drop::; -impl ModelWithByteArrayEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithByteArrayEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.x, ref output); - core::serde::Serde::serialize(self.y, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithByteArrayEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - x: core::serde::Serde::deserialize(ref serialized)?, - y: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithByteArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithByteArrayEntity; - - fn update(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; - - fn set_x(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ByteArray; - - fn set_y(self: @ModelWithByteArrayEntity, world: dojo::world::IWorldDispatcher, value: ByteArray); - -} -pub trait ModelWithByteArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithByteArray; - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithByteArray; - - fn set(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16; - - fn set_x(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ByteArray; - - fn set_y(self: @ModelWithByteArray, world: dojo::world::IWorldDispatcher, value: ByteArray); - -} -pub trait Imodel_with_byte_arrayDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithByteArray); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_byte_arrayDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_byte_arrayDispatcherImpl of Imodel_with_byte_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_byte_arrayDispatcher, model: ModelWithByteArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_byte_arrayLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_byte_arrayLibraryDispatcherImpl of Imodel_with_byte_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_byte_arrayLibraryDispatcher, model: ModelWithByteArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_byte_arraySafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithByteArray) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_byte_arraySafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_byte_arraySafeLibraryDispatcherImpl of Imodel_with_byte_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_byte_arraySafeLibraryDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_byte_arraySafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_byte_arraySafeDispatcherImpl of Imodel_with_byte_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_byte_arraySafeDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithComplexArrayEntityDrop of core::traits::Drop::; -impl ModelWithComplexArrayEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithComplexArrayEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.x, ref output); - core::serde::Serde::serialize(self.y, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithComplexArrayEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - x: core::serde::Serde::deserialize(ref serialized)?, - y: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithComplexArrayEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithComplexArrayEntity; - - fn update(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; - - fn set_x(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> Array; - - fn set_y(self: @ModelWithComplexArrayEntity, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait ModelWithComplexArrayStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithComplexArray; - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithComplexArray; - - fn set(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16; - - fn set_x(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> Array; - - fn set_y(self: @ModelWithComplexArray, world: dojo::world::IWorldDispatcher, value: Array); - -} -pub trait Imodel_with_complex_arrayDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithComplexArray); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_complex_arrayDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_complex_arrayDispatcherImpl of Imodel_with_complex_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_complex_arrayDispatcher, model: ModelWithComplexArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_complex_arrayLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_complex_arrayLibraryDispatcherImpl of Imodel_with_complex_arrayDispatcherTrait { - fn ensure_abi(self: Imodel_with_complex_arrayLibraryDispatcher, model: ModelWithComplexArray) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_complex_arraySafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithComplexArray) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_complex_arraySafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_complex_arraySafeLibraryDispatcherImpl of Imodel_with_complex_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_complex_arraySafeLibraryDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_complex_arraySafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_complex_arraySafeDispatcherImpl of Imodel_with_complex_arraySafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_complex_arraySafeDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithTupleEntityDrop of core::traits::Drop::; -impl ModelWithTupleEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithTupleEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.x, ref output); - core::serde::Serde::serialize(self.y, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithTupleEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - x: core::serde::Serde::deserialize(ref serialized)?, - y: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithTupleEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleEntity; - - fn update(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; - - fn set_x(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, u16, u32); - - fn set_y(self: @ModelWithTupleEntity, world: dojo::world::IWorldDispatcher, value: (u8, u16, u32)); - -} -pub trait ModelWithTupleStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithTuple; - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithTuple; - - fn set(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16; - - fn set_x(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> (u8, u16, u32); - - fn set_y(self: @ModelWithTuple, world: dojo::world::IWorldDispatcher, value: (u8, u16, u32)); - -} -pub trait Imodel_with_tupleDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithTuple); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tupleDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_tupleDispatcherImpl of Imodel_with_tupleDispatcherTrait { - fn ensure_abi(self: Imodel_with_tupleDispatcher, model: ModelWithTuple) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tupleLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_tupleLibraryDispatcherImpl of Imodel_with_tupleDispatcherTrait { - fn ensure_abi(self: Imodel_with_tupleLibraryDispatcher, model: ModelWithTuple) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_tupleSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithTuple) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tupleSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_tupleSafeLibraryDispatcherImpl of Imodel_with_tupleSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_tupleSafeLibraryDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tupleSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_tupleSafeDispatcherImpl of Imodel_with_tupleSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_tupleSafeDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ModelWithTupleNoPrimitivesEntityDrop of core::traits::Drop::; -impl ModelWithTupleNoPrimitivesEntitySerde of core::serde::Serde:: { - fn serialize(self: @ModelWithTupleNoPrimitivesEntity, ref output: core::array::Array) { - core::serde::Serde::serialize(self.__id, ref output); - core::serde::Serde::serialize(self.x, ref output); - core::serde::Serde::serialize(self.y, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(ModelWithTupleNoPrimitivesEntity { - __id: core::serde::Serde::deserialize(ref serialized)?, - x: core::serde::Serde::deserialize(ref serialized)?, - y: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -pub trait ModelWithTupleNoPrimitivesEntityStore { - fn get(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> ModelWithTupleNoPrimitivesEntity; - - fn update(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; - - fn set_x(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, Vec3, u32); - - fn set_y(self: @ModelWithTupleNoPrimitivesEntity, world: dojo::world::IWorldDispatcher, value: (u8, Vec3, u32)); - -} -pub trait ModelWithTupleNoPrimitivesStore { - fn entity_id_from_keys(player: ContractAddress) -> felt252; - - fn from_values(ref keys: Span, ref values: Span) -> ModelWithTupleNoPrimitives; - - fn get(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> ModelWithTupleNoPrimitives; - - fn set(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher); - - fn delete(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher); - - - fn get_x(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> u16; - - fn set_x(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher, value: u16); - - fn get_y(world: dojo::world::IWorldDispatcher, player: ContractAddress) -> (u8, Vec3, u32); - - fn set_y(self: @ModelWithTupleNoPrimitives, world: dojo::world::IWorldDispatcher, value: (u8, Vec3, u32)); - -} -pub trait Imodel_with_tuple_no_primitivesDispatcherTrait { - fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tuple_no_primitivesDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_tuple_no_primitivesDispatcherImpl of Imodel_with_tuple_no_primitivesDispatcherTrait { - fn ensure_abi(self: Imodel_with_tuple_no_primitivesDispatcher, model: ModelWithTupleNoPrimitives) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tuple_no_primitivesLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_tuple_no_primitivesLibraryDispatcherImpl of Imodel_with_tuple_no_primitivesDispatcherTrait { - fn ensure_abi(self: Imodel_with_tuple_no_primitivesLibraryDispatcher, model: ModelWithTupleNoPrimitives) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -pub trait Imodel_with_tuple_no_primitivesSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherImpl of Imodel_with_tuple_no_primitivesSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -pub struct Imodel_with_tuple_no_primitivesSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl Imodel_with_tuple_no_primitivesSafeDispatcherImpl of Imodel_with_tuple_no_primitivesSafeDispatcherTrait { - fn ensure_abi(self: Imodel_with_tuple_no_primitivesSafeDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@model, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("ensure_abi"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl Ibad_model_multiple_versionsDispatcherCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsDispatcherDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_multiple_versionsDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_multiple_versionsDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_multiple_versionsDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_multiple_versionsDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_multiple_versionsDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_multiple_versionsDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_multiple_versionsDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_multiple_versionsDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_multiple_versionsDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_multiple_versionsLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_multiple_versionsLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_multiple_versionsLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_multiple_versionsLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_multiple_versionsLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_multiple_versionsLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_multiple_versionsLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_multiple_versionsLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_multiple_versionsSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_multiple_versionsSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_multiple_versionsSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_multiple_versionsSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_multiple_versionsSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_multiple_versionsSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_multiple_versionsSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_multiple_versionsSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_multiple_versionsSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_multiple_versionsSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_multiple_versionsSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_multiple_versionsSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_multiple_versionsSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_multiple_versionsSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_multiple_versionsSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_bad_version_typeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_bad_version_typeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_bad_version_typeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_bad_version_typeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_bad_version_typeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_bad_version_typeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_bad_version_typeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_bad_version_typeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_bad_version_typeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_bad_version_typeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_bad_version_typeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_bad_version_typeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_bad_version_typeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_bad_version_typeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_bad_version_typeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_bad_version_typeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_bad_version_typeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_bad_version_typeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_bad_version_typeSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_bad_version_typeSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_bad_version_typeSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_bad_version_typeSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_bad_version_typeSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_bad_version_typeSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_bad_version_typeSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_bad_version_typeSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_bad_version_typeSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_bad_version_typeSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_bad_version_typeSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_bad_version_typeSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_bad_version_typeSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_bad_version_typeSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_bad_version_typeSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_no_version_valueDispatcherCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueDispatcherDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_no_version_valueDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_no_version_valueDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_no_version_valueDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_no_version_valueDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_no_version_valueDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_no_version_valueDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_no_version_valueDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_no_version_valueDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_no_version_valueDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_no_version_valueLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_no_version_valueLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_no_version_valueLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_no_version_valueLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_no_version_valueLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_no_version_valueLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_no_version_valueLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_no_version_valueLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_no_version_valueSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_no_version_valueSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_no_version_valueSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_no_version_valueSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_no_version_valueSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_no_version_valueSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_no_version_valueSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_no_version_valueSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_no_version_valueSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_no_version_valueSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_no_version_valueSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_no_version_valueSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_no_version_valueSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_no_version_valueSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_no_version_valueSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_no_version_valueSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_no_version_valueSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_no_version_valueSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_no_version_valueSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_unexpected_arg_with_valueDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_arg_with_valueDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_arg_with_valueDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_arg_with_valueDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_arg_with_valueDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_arg_with_valueDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_arg_with_valueLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_arg_with_valueLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_arg_with_valueLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_arg_with_valueSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_arg_with_valueSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_arg_with_valueSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_arg_with_valueSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_arg_with_valueSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_unexpected_argDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_argDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_argDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_argDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_argDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_argDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_argDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_argDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_argDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_argDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_unexpected_argLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_argLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_argLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_argLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_argLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_argLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_argLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_argLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_unexpected_argSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_argSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_argSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_argSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_argSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_argSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_unexpected_argSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_unexpected_argSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_unexpected_argSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_unexpected_argSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_unexpected_argSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_unexpected_argSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_unexpected_argSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_unexpected_argSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_unexpected_argSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_unexpected_argSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_unexpected_argSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_unexpected_argSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_unexpected_argSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_not_supported_versionDispatcherCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionDispatcherDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_not_supported_versionDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_not_supported_versionDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_not_supported_versionDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_not_supported_versionDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_not_supported_versionDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_not_supported_versionDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_not_supported_versionDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_not_supported_versionDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_not_supported_versionDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_not_supported_versionLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_not_supported_versionLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_not_supported_versionLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_not_supported_versionLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_not_supported_versionLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_not_supported_versionLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_not_supported_versionLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_not_supported_versionLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_not_supported_versionSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_not_supported_versionSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_not_supported_versionSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_not_supported_versionSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ibad_model_not_supported_versionSafeDispatcherCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeDispatcherDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ibad_model_not_supported_versionSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ibad_model_not_supported_versionSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIbad_model_not_supported_versionSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ibad_model_not_supported_versionSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ibad_model_not_supported_versionSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ibad_model_not_supported_versionSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ibad_model_not_supported_versionSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ibad_model_not_supported_versionSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ibad_model_not_supported_versionSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ibad_model_not_supported_versionSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodelv_0DispatcherCopy of core::traits::Copy::; -impl Imodelv_0DispatcherDrop of core::traits::Drop::; -impl Imodelv_0DispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodelv_0Dispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodelv_0Dispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodelv_0Dispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodelv_0Dispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0Dispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodelv_0Dispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0Dispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodelv_0DispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodelv_0DispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodelv_0DispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodelv_0DispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0DispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodelv_0DispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodelv_0DispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodelv_0DispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodelv_0DispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0DispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodelv_0LibraryDispatcherCopy of core::traits::Copy::; -impl Imodelv_0LibraryDispatcherDrop of core::traits::Drop::; -impl Imodelv_0LibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodelv_0LibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodelv_0LibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodelv_0LibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodelv_0LibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0LibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodelv_0LibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0LibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodelv_0LibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodelv_0LibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodelv_0LibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodelv_0LibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0LibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodelv_0LibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodelv_0LibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodelv_0LibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodelv_0LibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0LibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodelv_0SafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodelv_0SafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodelv_0SafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodelv_0SafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodelv_0SafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodelv_0SafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodelv_0SafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodelv_0SafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodelv_0SafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodelv_0SafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodelv_0SafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodelv_0SafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0SafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodelv_0SafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodelv_0SafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodelv_0SafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodelv_0SafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0SafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodelv_0SafeDispatcherCopy of core::traits::Copy::; -impl Imodelv_0SafeDispatcherDrop of core::traits::Drop::; -impl Imodelv_0SafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodelv_0SafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodelv_0SafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodelv_0SafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodelv_0SafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0SafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodelv_0SafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0SafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodelv_0SafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodelv_0SafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodelv_0SafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodelv_0SafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0SafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodelv_0SafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodelv_0SafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodelv_0SafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodelv_0SafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodelv_0SafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_bad_namespace_formatDispatcherCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatDispatcherDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_bad_namespace_formatDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_bad_namespace_formatDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_bad_namespace_formatDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_bad_namespace_formatDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_bad_namespace_formatDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_bad_namespace_formatDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_bad_namespace_formatDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_bad_namespace_formatDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_bad_namespace_formatDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_bad_namespace_formatLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_bad_namespace_formatLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_bad_namespace_formatLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_bad_namespace_formatLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_bad_namespace_formatLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_bad_namespace_formatLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_bad_namespace_formatSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_bad_namespace_formatSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_bad_namespace_formatSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_bad_namespace_formatSafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_bad_namespace_formatSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_bad_namespace_formatSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_bad_namespace_formatSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_bad_namespace_formatSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_bad_namespace_formatSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_bad_namespace_formatSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_short_string_namespaceDispatcherCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceDispatcherDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_short_string_namespaceDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_short_string_namespaceDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_short_string_namespaceDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_short_string_namespaceDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_short_string_namespaceDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_short_string_namespaceDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_short_string_namespaceDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_short_string_namespaceDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_short_string_namespaceDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_short_string_namespaceLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_short_string_namespaceLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_short_string_namespaceLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_short_string_namespaceLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_short_string_namespaceLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_short_string_namespaceLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_short_string_namespaceSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_short_string_namespaceSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_short_string_namespaceSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_short_string_namespaceSafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_short_string_namespaceSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_short_string_namespaceSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_short_string_namespaceSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_short_string_namespaceSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_short_string_namespaceSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_short_string_namespaceSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_short_string_namespaceSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_short_string_namespaceSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_short_string_namespaceSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_short_string_namespaceSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_string_namespaceDispatcherCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceDispatcherDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_string_namespaceDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_string_namespaceDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_string_namespaceDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_string_namespaceDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_string_namespaceDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_string_namespaceDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_string_namespaceDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_string_namespaceDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_string_namespaceDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_string_namespaceLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_string_namespaceLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_string_namespaceLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_string_namespaceLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_string_namespaceLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_string_namespaceLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_string_namespaceLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_string_namespaceLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_string_namespaceSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_string_namespaceSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_string_namespaceSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_string_namespaceSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_string_namespaceSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_string_namespaceSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_string_namespaceSafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_string_namespaceSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_string_namespaceSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_string_namespaceSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_string_namespaceSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_string_namespaceSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_string_namespaceSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_string_namespaceSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_string_namespaceSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_string_namespaceSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_string_namespaceSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_string_namespaceSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_string_namespaceSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IpositionDispatcherCopy of core::traits::Copy::; -impl IpositionDispatcherDrop of core::traits::Drop::; -impl IpositionDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IpositionDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IpositionDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIpositionDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IpositionDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IpositionDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IpositionDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IpositionDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IpositionDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IpositionDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IpositionDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IpositionDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IpositionDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IpositionDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IpositionLibraryDispatcherCopy of core::traits::Copy::; -impl IpositionLibraryDispatcherDrop of core::traits::Drop::; -impl IpositionLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IpositionLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IpositionLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIpositionLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IpositionLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IpositionLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IpositionLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IpositionLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IpositionLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IpositionLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IpositionLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IpositionLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IpositionLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IpositionLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IpositionSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IpositionSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IpositionSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IpositionSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IpositionSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIpositionSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IpositionSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IpositionSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IpositionSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IpositionSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IpositionSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IpositionSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IpositionSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IpositionSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IpositionSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IpositionSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IpositionSafeDispatcherCopy of core::traits::Copy::; -impl IpositionSafeDispatcherDrop of core::traits::Drop::; -impl IpositionSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IpositionSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IpositionSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIpositionSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IpositionSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IpositionSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IpositionSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IpositionSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IpositionSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IpositionSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IpositionSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IpositionSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IpositionSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IpositionSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IpositionSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IrolesDispatcherCopy of core::traits::Copy::; -impl IrolesDispatcherDrop of core::traits::Drop::; -impl IrolesDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IrolesDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IrolesDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIrolesDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IrolesDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IrolesDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IrolesDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IrolesDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IrolesDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IrolesDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IrolesDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IrolesDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IrolesDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IrolesDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IrolesLibraryDispatcherCopy of core::traits::Copy::; -impl IrolesLibraryDispatcherDrop of core::traits::Drop::; -impl IrolesLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IrolesLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IrolesLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIrolesLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IrolesLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IrolesLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IrolesLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IrolesLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IrolesLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IrolesLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IrolesLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IrolesLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IrolesLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IrolesLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IrolesSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IrolesSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IrolesSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IrolesSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IrolesSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIrolesSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IrolesSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IrolesSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IrolesSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IrolesSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IrolesSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IrolesSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IrolesSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IrolesSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IrolesSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IrolesSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IrolesSafeDispatcherCopy of core::traits::Copy::; -impl IrolesSafeDispatcherDrop of core::traits::Drop::; -impl IrolesSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IrolesSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IrolesSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIrolesSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IrolesSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IrolesSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IrolesSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IrolesSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IrolesSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IrolesSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IrolesSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IrolesSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IrolesSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IrolesSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IrolesSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ionly_key_modelDispatcherCopy of core::traits::Copy::; -impl Ionly_key_modelDispatcherDrop of core::traits::Drop::; -impl Ionly_key_modelDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ionly_key_modelDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ionly_key_modelDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIonly_key_modelDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ionly_key_modelDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ionly_key_modelDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ionly_key_modelDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ionly_key_modelDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ionly_key_modelDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ionly_key_modelDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ionly_key_modelDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ionly_key_modelDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ionly_key_modelDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ionly_key_modelDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ionly_key_modelLibraryDispatcherCopy of core::traits::Copy::; -impl Ionly_key_modelLibraryDispatcherDrop of core::traits::Drop::; -impl Ionly_key_modelLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ionly_key_modelLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ionly_key_modelLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIonly_key_modelLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ionly_key_modelLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ionly_key_modelLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ionly_key_modelLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ionly_key_modelLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ionly_key_modelLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ionly_key_modelLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ionly_key_modelLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ionly_key_modelLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ionly_key_modelLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ionly_key_modelLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ionly_key_modelSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Ionly_key_modelSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Ionly_key_modelSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ionly_key_modelSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ionly_key_modelSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIonly_key_modelSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ionly_key_modelSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ionly_key_modelSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ionly_key_modelSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Ionly_key_modelSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ionly_key_modelSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ionly_key_modelSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ionly_key_modelSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Ionly_key_modelSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ionly_key_modelSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ionly_key_modelSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Ionly_key_modelSafeDispatcherCopy of core::traits::Copy::; -impl Ionly_key_modelSafeDispatcherDrop of core::traits::Drop::; -impl Ionly_key_modelSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Ionly_key_modelSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Ionly_key_modelSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIonly_key_modelSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Ionly_key_modelSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Ionly_key_modelSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Ionly_key_modelSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Ionly_key_modelSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Ionly_key_modelSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Ionly_key_modelSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Ionly_key_modelSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Ionly_key_modelSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Ionly_key_modelSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Ionly_key_modelSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Ionly_key_modelSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Iu_256_key_modelDispatcherCopy of core::traits::Copy::; -impl Iu_256_key_modelDispatcherDrop of core::traits::Drop::; -impl Iu_256_key_modelDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Iu_256_key_modelDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Iu_256_key_modelDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIu_256_key_modelDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Iu_256_key_modelDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Iu_256_key_modelDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Iu_256_key_modelDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Iu_256_key_modelDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Iu_256_key_modelDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Iu_256_key_modelDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Iu_256_key_modelLibraryDispatcherCopy of core::traits::Copy::; -impl Iu_256_key_modelLibraryDispatcherDrop of core::traits::Drop::; -impl Iu_256_key_modelLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Iu_256_key_modelLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Iu_256_key_modelLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIu_256_key_modelLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Iu_256_key_modelLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Iu_256_key_modelLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Iu_256_key_modelLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Iu_256_key_modelLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Iu_256_key_modelLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Iu_256_key_modelLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Iu_256_key_modelSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Iu_256_key_modelSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Iu_256_key_modelSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIu_256_key_modelSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Iu_256_key_modelSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Iu_256_key_modelSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Iu_256_key_modelSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Iu_256_key_modelSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Iu_256_key_modelSafeDispatcherCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeDispatcherDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Iu_256_key_modelSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Iu_256_key_modelSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIu_256_key_modelSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Iu_256_key_modelSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Iu_256_key_modelSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Iu_256_key_modelSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Iu_256_key_modelSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Iu_256_key_modelSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Iu_256_key_modelSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Iu_256_key_modelSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Iu_256_key_modelSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Iu_256_key_modelSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IplayerDispatcherCopy of core::traits::Copy::; -impl IplayerDispatcherDrop of core::traits::Drop::; -impl IplayerDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IplayerDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IplayerDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIplayerDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IplayerDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IplayerDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IplayerDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IplayerDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IplayerDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IplayerDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IplayerDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IplayerDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IplayerDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IplayerDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IplayerLibraryDispatcherCopy of core::traits::Copy::; -impl IplayerLibraryDispatcherDrop of core::traits::Drop::; -impl IplayerLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IplayerLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IplayerLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIplayerLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IplayerLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IplayerLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IplayerLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IplayerLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IplayerLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IplayerLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IplayerLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IplayerLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IplayerLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IplayerLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IplayerSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IplayerSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IplayerSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IplayerSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IplayerSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIplayerSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IplayerSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IplayerSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IplayerSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IplayerSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IplayerSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IplayerSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IplayerSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IplayerSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IplayerSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IplayerSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IplayerSafeDispatcherCopy of core::traits::Copy::; -impl IplayerSafeDispatcherDrop of core::traits::Drop::; -impl IplayerSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IplayerSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IplayerSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIplayerSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IplayerSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IplayerSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IplayerSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IplayerSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IplayerSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IplayerSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IplayerSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IplayerSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IplayerSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IplayerSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IplayerSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_simple_arrayDispatcherCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayDispatcherDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_simple_arrayDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_simple_arrayDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_simple_arrayDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arrayDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arrayDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arrayDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_simple_arrayDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_simple_arrayDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_simple_arrayDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arrayDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arrayDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_simple_arrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_simple_arrayDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_simple_arrayDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arrayDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_simple_arrayLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_simple_arrayLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_simple_arrayLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_simple_arrayLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arrayLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arrayLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arrayLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_simple_arrayLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_simple_arrayLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arrayLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arrayLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_simple_arrayLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_simple_arrayLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arrayLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_simple_arraySafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_simple_arraySafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_simple_arraySafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_simple_arraySafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arraySafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_simple_arraySafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_simple_arraySafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arraySafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_simple_arraySafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_simple_arraySafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_simple_arraySafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_simple_arraySafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arraySafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_simple_arraySafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arraySafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_simple_arraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_simple_arraySafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_simple_arraySafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arraySafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_simple_arraySafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_simple_arraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_simple_arraySafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_simple_arraySafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_simple_arraySafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_byte_arrayDispatcherCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayDispatcherDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_byte_arrayDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_byte_arrayDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_byte_arrayDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arrayDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arrayDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arrayDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_byte_arrayDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_byte_arrayDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_byte_arrayDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arrayDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arrayDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_byte_arrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_byte_arrayDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_byte_arrayDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arrayDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_byte_arrayLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_byte_arrayLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_byte_arrayLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_byte_arrayLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arrayLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arrayLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arrayLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_byte_arrayLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_byte_arrayLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arrayLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arrayLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_byte_arrayLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_byte_arrayLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arrayLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_byte_arraySafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_byte_arraySafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_byte_arraySafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_byte_arraySafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arraySafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_byte_arraySafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_byte_arraySafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arraySafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_byte_arraySafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_byte_arraySafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_byte_arraySafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_byte_arraySafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arraySafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_byte_arraySafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arraySafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_byte_arraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_byte_arraySafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_byte_arraySafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arraySafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_byte_arraySafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_byte_arraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_byte_arraySafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_byte_arraySafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_byte_arraySafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_complex_arrayDispatcherCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayDispatcherDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_complex_arrayDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_complex_arrayDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_complex_arrayDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arrayDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arrayDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arrayDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arrayDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_complex_arrayDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_complex_arrayDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_complex_arrayDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arrayDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arrayDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_complex_arrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_complex_arrayDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_complex_arrayDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arrayDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_complex_arrayLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_complex_arrayLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_complex_arrayLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_complex_arrayLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arrayLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arrayLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arrayLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_complex_arrayLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_complex_arrayLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arrayLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arrayLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_complex_arrayLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_complex_arrayLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arrayLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_complex_arraySafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_complex_arraySafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_complex_arraySafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_complex_arraySafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arraySafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arraySafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_complex_arraySafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_complex_arraySafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arraySafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_complex_arraySafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_complex_arraySafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_complex_arraySafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_complex_arraySafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arraySafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_complex_arraySafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arraySafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arraySafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_complex_arraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_complex_arraySafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_complex_arraySafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arraySafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_complex_arraySafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_complex_arraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_complex_arraySafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_complex_arraySafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_complex_arraySafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_tupleDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tupleDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tupleDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tupleDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tupleDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tupleDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_tupleDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tupleDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tupleDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_tupleDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tupleDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tupleDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_tupleLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tupleLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tupleLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tupleLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tupleLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tupleLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_tupleLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tupleLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tupleLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_tupleLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tupleLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tupleLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_tupleSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tupleSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tupleSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tupleSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tupleSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tupleSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tupleSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tupleSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_tupleSafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tupleSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tupleSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tupleSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tupleSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_tupleSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tupleSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tupleSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tupleSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_tupleSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tupleSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tupleSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tupleSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_tuple_no_primitivesDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tuple_no_primitivesDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tuple_no_primitivesDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tuple_no_primitivesDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tuple_no_primitivesDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tuple_no_primitivesDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tuple_no_primitivesDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tuple_no_primitivesDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Imodel_with_tuple_no_primitivesLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tuple_no_primitivesLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tuple_no_primitivesLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tuple_no_primitivesLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tuple_no_primitivesSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tuple_no_primitivesSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl Imodel_with_tuple_no_primitivesSafeDispatcherCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @Imodel_with_tuple_no_primitivesSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(Imodel_with_tuple_no_primitivesSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreImodel_with_tuple_no_primitivesSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - Imodel_with_tuple_no_primitivesSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = Imodel_with_tuple_no_primitivesSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> Imodel_with_tuple_no_primitivesSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl Ibad_model_multiple_versionsDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_multiple_versionsSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_bad_version_typeSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_no_version_valueSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_no_version_valueSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_unexpected_argSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_unexpected_argSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ibad_model_not_supported_versionSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodelv_0DispatcherSubPointersDrop of core::traits::Drop::; -impl Imodelv_0DispatcherSubPointersCopy of core::traits::Copy::; -impl Imodelv_0DispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodelv_0DispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodelv_0LibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodelv_0LibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodelv_0LibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodelv_0LibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodelv_0SafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodelv_0SafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodelv_0SafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodelv_0SafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodelv_0SafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodelv_0SafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodelv_0SafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodelv_0SafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_bad_namespace_formatSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_short_string_namespaceSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_string_namespaceSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_string_namespaceSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IpositionDispatcherSubPointersDrop of core::traits::Drop::; -impl IpositionDispatcherSubPointersCopy of core::traits::Copy::; -impl IpositionDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IpositionDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IpositionLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IpositionLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IpositionLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IpositionLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IpositionSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IpositionSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IpositionSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IpositionSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IpositionSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IpositionSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IpositionSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IpositionSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IrolesDispatcherSubPointersDrop of core::traits::Drop::; -impl IrolesDispatcherSubPointersCopy of core::traits::Copy::; -impl IrolesDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IrolesDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IrolesLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IrolesLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IrolesLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IrolesLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IrolesSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IrolesSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IrolesSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IrolesSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IrolesSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IrolesSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IrolesSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IrolesSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ionly_key_modelDispatcherSubPointersDrop of core::traits::Drop::; -impl Ionly_key_modelDispatcherSubPointersCopy of core::traits::Copy::; -impl Ionly_key_modelDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ionly_key_modelDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ionly_key_modelLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ionly_key_modelLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ionly_key_modelLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ionly_key_modelLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ionly_key_modelSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Ionly_key_modelSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Ionly_key_modelSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ionly_key_modelSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Ionly_key_modelSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Ionly_key_modelSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Ionly_key_modelSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Ionly_key_modelSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Iu_256_key_modelDispatcherSubPointersDrop of core::traits::Drop::; -impl Iu_256_key_modelDispatcherSubPointersCopy of core::traits::Copy::; -impl Iu_256_key_modelDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Iu_256_key_modelDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Iu_256_key_modelLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Iu_256_key_modelLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Iu_256_key_modelLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Iu_256_key_modelLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Iu_256_key_modelSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Iu_256_key_modelSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IplayerDispatcherSubPointersDrop of core::traits::Drop::; -impl IplayerDispatcherSubPointersCopy of core::traits::Copy::; -impl IplayerDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IplayerDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IplayerLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IplayerLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IplayerLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IplayerLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IplayerSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IplayerSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IplayerSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IplayerSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IplayerSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IplayerSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IplayerSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IplayerSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_simple_arrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_simple_arraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_simple_arraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_byte_arrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_byte_arraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_byte_arraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_complex_arrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_complex_arraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_complex_arraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tupleDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tupleDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tupleDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tupleDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tupleLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tupleLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tupleLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tupleLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tupleSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tupleSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl Imodel_with_tuple_no_primitivesSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - -//! > expected_diagnostics -error: A Dojo model must have zero or one dojo::model attribute. - --> /tmp/plugin_test/model/src/lib.cairo:1:1 -#[dojo::model(version: 0)] -^************************^ - -error: Too many 'version' attributes for dojo::model - --> /tmp/plugin_test/model/src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ - -error: The argument 'version' of dojo::model must be an integer - --> /tmp/plugin_test/model/src/lib.cairo:16:24 -#[dojo::model(version: hello)] - ^***^ - -error: Unexpected argument 'version' for dojo::model - --> /tmp/plugin_test/model/src/lib.cairo:23:15 -#[dojo::model(version)] - ^*****^ - -error: Unexpected argument 'my_arg' for dojo::model - --> /tmp/plugin_test/model/src/lib.cairo:30:15 -#[dojo::model(my_arg: 1)] - ^*******^ - -error: Unexpected argument 'my_arg' for dojo::model - --> /tmp/plugin_test/model/src/lib.cairo:37:15 -#[dojo::model(my_arg)] - ^****^ - -error: dojo::model version 2 not supported - --> /tmp/plugin_test/model/src/lib.cairo:44:24 -#[dojo::model(version: 2)] - ^ - -error: Model must define at least one #[key] attribute - --> /tmp/plugin_test/model/src/lib.cairo:87:8 -struct Roles { - ^***^ - -error: Model must define at least one member that is not a key - --> /tmp/plugin_test/model/src/lib.cairo:92:8 -struct OnlyKeyModel { - ^**********^ - -error: Key is only supported for core types that are 1 felt long once serialized. `u256` is a struct of 2 u128, hence not supported. - --> /tmp/plugin_test/model/src/lib.cairo:100:5 - id: u256 - ^^ - -error: Model must define at least one member that is not a key - --> /tmp/plugin_test/model/src/lib.cairo:98:8 -struct U256KeyModel { - ^**********^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system deleted file mode 100644 index 2d53e0fb5d..0000000000 --- a/crates/dojo-lang/src/plugin_test_data/system +++ /dev/null @@ -1,11529 +0,0 @@ -//! > Test expansion of the #[system]. - -//! > test_runner_name -test_expand_plugin - -//! > test_id -system - -//! > cairo_code -#[dojo::contract(namespace: "My@Namespace")] -mod bad_namespace_format { - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } -} - -#[dojo::contract(namespace: 'my_namespace')] -mod spawn { - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } -} - -#[dojo::contract(namespace: "my_namespace")] -mod proxy { - fn execute(value: felt252) -> felt252 { - value - } -} - -#[dojo::contract] -mod ctxnamed { - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } -} - -#[dojo::contract] -mod withevent { - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - TestEvent: TestEvent, - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } -} - -#[starknet::component] -mod testcomponent1 { - #[storage] - struct Storage {} -} - -#[starknet::component] -mod testcomponent2 { - #[storage] - struct Storage {} -} - -#[dojo::contract] -mod withcomponent { - component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); - component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); - - #[storage] - struct Storage { - #[substorage(v0)] - testcomponent1_storage: testcomponent1::Storage, - #[substorage(v0)] - testcomponent2_storage: testcomponent2::Storage, - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event, - } -} -#[dojo::interface] -trait IEmptyTrait; - -#[dojo::interface] -trait IFaultyTrait { - const ONE: u8; - - #[my_attr] - fn do_with_attrs(p1: u8) -> u16; -} - -#[dojo::interface] -trait INominalTrait { - fn do_no_param() -> felt252; - fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252; - fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252; - fn do_params_no_world(p1: felt252, p2: u8) -> felt252; - fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252; - fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252; - - fn do_with_self(self: @ContractState) -> felt252; - fn do_with_ref_self(ref self: ContractState) -> felt252; -} - -#[dojo::interface] -trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - fn do_with_ref_self_and_world_inv( - ref world: IWorldDispatcher, ref self: ContractState - ) -> felt252; - fn do_with_several_world_dispatchers( - world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher - ) -> felt252; - fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252; - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; -} - -#[dojo::contract] -mod MyFaultyContract { - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - 'land' - } - - fn do_with_ref_self_and_world( - ref self: ContractState, ref world: IWorldDispatcher - ) -> felt252 { - 'land' - } - - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - 'land' - } - - fn do_with_ref_self_and_world_inv( - ref world: IWorldDispatcher, ref self: ContractState - ) -> felt252 { - 'land' - } - - fn do_with_several_world_dispatchers( - world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher - ) -> felt252 { - 'land' - } - - fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252 { - 'land' - } - - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - 'land' - } - } - - #[generate_trait] - impl InternalImplBad of InternalUtils { - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - 'land' - } - } -} - -#[dojo::contract] -mod MyNominalContract { - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait { - fn do_no_param() -> felt252 { - 'land' - } - - fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252 { - 'land' - } - - fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252 { - 'land' - } - - fn do_params_no_world(p1: felt252, p2: u8) -> felt252 { - 'land' - } - - fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252 { - 'land' - } - - fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252 { - 'land' - } - - fn do_with_self(self: @ContractState) -> felt252 { - 'land' - } - - fn do_with_ref_self(ref self: ContractState) -> felt252 { - 'land' - } - } - - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } -} - -#[dojo::contract] -mod init_test { - fn dojo_init( - world: IWorldDispatcher, - actions_address: ContractAddress, - actions_class: ClassHash, - value: u8 - ) { - emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); - } -} - -#[dojo::contract] -mod no_init_test {} - -//! > generated_cairo_code -#[starknet::contract] -mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - } - - #[abi(embed_v0)] - fn name(self: @ContractState) -> felt252 { - 'spawn' - } - - #[abi(embed_v0)] - impl Upgradeable of dojo::upgradable::IUpgradeable { - fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { - let caller = starknet::get_caller_address(); - assert( - self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' - ); - dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); - } - } - - use traits::Into; - use dojo::world::Context; - - #[abi(embed_v0)] - fn execute(self: @ContractState, ctx: Context, name: felt252) { - return (); - } -} - - -#[starknet::contract] -mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - } - - #[abi(embed_v0)] - fn name(self: @ContractState) -> felt252 { - 'proxy' - } - - #[abi(embed_v0)] - impl Upgradeable of dojo::upgradable::IUpgradeable { - fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { - let caller = starknet::get_caller_address(); - assert( - self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' - ); - dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); - } - } - - - #[abi(embed_v0)] - fn execute(self: @ContractState, value: felt252) -> felt252 { - value - } -} - - -#[starknet::contract] -mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - } - - #[abi(embed_v0)] - fn name(self: @ContractState) -> felt252 { - 'ctxnamed' - } - - #[abi(embed_v0)] - impl Upgradeable of dojo::upgradable::IUpgradeable { - fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { - let caller = starknet::get_caller_address(); - assert( - self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' - ); - dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); - } - } - - use traits::Into; - use dojo::world::Context; - - #[abi(embed_v0)] - fn execute(self: @ContractState, ctx2: Context, name: felt252) { - return (); - } -} - -//! > expected_diagnostics -error: Anything other than functions is not supported in a dojo::interface - --> /tmp/plugin_test/system/src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/system/src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/system/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/system/src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/system/src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/system/src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /tmp/plugin_test/system/src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> /tmp/plugin_test/system/src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/system/src/lib.cairo:105:5 - fn do_with_self(self: @ContractState) -> felt252; - ^**********************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/system/src/lib.cairo:106:5 - fn do_with_ref_self(ref self: ContractState) -> felt252; - ^*****************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/system/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^**********************************************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/system/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/system/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/system/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/system/src/lib.cairo:117:5 - fn do_with_several_world_dispatchers( - ^***********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/system/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^***************************************************************************^ - -error: Generated trait must have generic args matching the impl's generic params. - --> /tmp/plugin_test/system/src/lib.cairo:163:5 - #[generate_trait] - ^***************^ - -//! > expanded_cairo_code - -#[starknet::component] -mod testcomponent1 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ComponentState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ComponentState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - -#[starknet::component] -mod testcomponent2 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -#[phantom] -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - StorageStorageBase { - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - StorageStorageBaseMut { - } - } -} - -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ComponentState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ComponentState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -} - - #[starknet::contract] - pub mod bad_namespace_format { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "bad_namespace_format" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-bad_namespace_format" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2014299465256018364248618312205774234949844604916563661777686628154176783488 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 1674441257224597091124008266787844860104091058063661385750024717220711878589 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 68455752117050128185302950891816466897876546944174376812212671562113328733 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 1940415311068338004979133415474511940700681073349244306389458906719593210527 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { - value - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 1088922133313711214547564678240399488767278073212336739350382494993498982824 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 3549898308100844368972151697544420289462059777504886668025232769583717017648 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) - } -} - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 3051237314154062498758064027519150695325862034415997374893619833554034627226 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, - #[substorage(v0)] - pub testcomponent1_storage: testcomponent1::Storage, - #[substorage(v0)] - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, - pub testcomponent1_storage: starknet::storage::FlattenedStorage, - pub testcomponent2_storage: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; - let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - testcomponent1_storage: testcomponent1_storage_value, - testcomponent2_storage: testcomponent2_storage_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, - pub testcomponent1_storage: starknet::storage::FlattenedStorage>, - pub testcomponent2_storage: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; - let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - testcomponent1_storage: testcomponent1_storage_value, - testcomponent2_storage: testcomponent2_storage_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); - } -} -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); - } -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) - } -} -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) - } -} - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::interface] - pub trait IEmptyTrait {} - - #[starknet::interface] - pub trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - pub trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - pub trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - pub mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 3304414327641815709216225681190245445308480446755012097234787467696641395890 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} - #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; -} - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@ContractState>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let mut __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_self, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let mut __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_another_world, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 1466845198188516049094649763342542731381088471625065496527510975945391631525 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p1 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_self(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; - pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; - pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; - pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 3030310726300416277764466172753931798577418912153146471062249714457767216078 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();if starknet::get_caller_address() != self.world().contract_address { core::panics::panic_with_byte_array(@format!("Only the world can init contract `{}`, but caller is `{:?}`", self.tag(), starknet::get_caller_address())); } emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); -} -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_actions_address = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_actions_class = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - let __arg_value = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #3' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 1612380646418854749267717900057829622040529970486094087524750323429009828706 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::contract::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - pub trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - pub impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - if starknet::get_caller_address() != self.world().contract_address { - core::panics::panic_with_byte_array( - @format!("Only the world can init contract `{}`, but caller is `{:?}`", - self.tag(), - starknet::get_caller_address(), - )); - } - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::contract::upgradeable::upgradeable::Event, - } - pub trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - - pub trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::contract::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -#[phantom] -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - pub upgradeable: dojo::contract::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let world_dispatcher_value = starknet::storage::StorageBase {__base_address__: selector!("world_dispatcher")}; - let upgradeable_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - world_dispatcher: world_dispatcher_value, - upgradeable: upgradeable_value, - } - } -} - -pub struct ContractState { - pub upgradeable: dojo::contract::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::contract::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::contract::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::contract::upgradeable::upgradeable::ComponentState { - @dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::contract::upgradeable::upgradeable::ComponentState { - dojo::contract::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::contract::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::contract::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::contract::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::contract::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::contract::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IDojoInitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IDojoInitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IDojoInitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - - } - pub trait IEmptyTraitDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IEmptyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IEmptyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - - pub trait IEmptyTraitSafeDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IEmptyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IEmptyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - pub trait IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: T, p1: u8) -> u16; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - - pub trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - pub trait INominalTraitDispatcherTrait { - fn do_no_param(self: T) -> felt252; -fn do_no_param_but_world(self: T) -> felt252; -fn do_no_param_but_world_ref(self: T) -> felt252; -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; -fn do_params_and_world(self: T, p2: u8) -> felt252; -fn do_params_and_world_ref(self: T, p2: u8) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct INominalTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct INominalTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - - pub trait INominalTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_no_param(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct INominalTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct INominalTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - pub trait IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - - pub trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] - pub struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -impl IEmptyTraitDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IEmptyTraitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IEmptyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IEmptyTraitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IEmptyTraitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IEmptyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IEmptyTraitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IEmptyTraitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IEmptyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IEmptyTraitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IEmptyTraitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IEmptyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IEmptyTraitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IEmptyTraitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IEmptyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IEmptyTraitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IEmptyTraitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IEmptyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IEmptyTraitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IEmptyTraitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IEmptyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IEmptyTraitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IEmptyTraitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IEmptyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IEmptyTraitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IEmptyTraitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IFaultyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IFaultyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IFaultyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IFaultyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IFaultyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IFaultyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IFaultyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl INominalTraitDispatcherCopy of core::traits::Copy::; -impl INominalTraitDispatcherDrop of core::traits::Drop::; -impl INominalTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct INominalTraitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl INominalTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = INominalTraitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct INominalTraitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl INominalTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = INominalTraitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct INominalTraitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl INominalTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = INominalTraitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct INominalTraitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl INominalTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = INominalTraitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct INominalTraitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl INominalTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = INominalTraitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct INominalTraitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl INominalTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = INominalTraitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct INominalTraitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl INominalTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = INominalTraitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct INominalTraitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl INominalTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = INominalTraitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - INominalTraitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IFaultyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IFaultyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IFaultyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IFaultyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeLibraryDispatcherSubPointers { - pub class_hash: starknet::storage::StoragePointer, -} -impl IFaultyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeLibraryDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeLibraryDispatcherSubPointers { - class_hash: class_hash_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeLibraryDispatcherSubPointersMut { - pub class_hash: starknet::storage::StoragePointer>, -} -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeLibraryDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let class_hash_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeLibraryDispatcherSubPointersMut { - class_hash: class_hash_value, - } - } -} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} - -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeDispatcherSubPointers { - pub contract_address: starknet::storage::StoragePointer, -} -impl IFaultyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { - type SubPointersType = IFaultyTraitSafeDispatcherSubPointers; - fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeDispatcherSubPointers { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeDispatcherSubPointers { - contract_address: contract_address_value, - } - } -} -#[derive(Drop, Copy)] -pub struct IFaultyTraitSafeDispatcherSubPointersMut { - pub contract_address: starknet::storage::StoragePointer>, -} -impl IFaultyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { - type SubPointersType = IFaultyTraitSafeDispatcherSubPointersMut; - fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeDispatcherSubPointersMut { - let base_address = self.__storage_pointer_address__; - let mut current_offset = self.__storage_pointer_offset__; - let contract_address_value = starknet::storage::StoragePointer { - __storage_pointer_address__: base_address, - __storage_pointer_offset__: current_offset, - }; - IFaultyTraitSafeDispatcherSubPointersMut { - contract_address: contract_address_value, - } - } -} -impl IEmptyTraitDispatcherSubPointersDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSubPointersCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl INominalTraitDispatcherSubPointersDrop of core::traits::Drop::; -impl INominalTraitDispatcherSubPointersCopy of core::traits::Copy::; -impl INominalTraitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl INominalTraitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; diff --git a/crates/dojo-lang/src/scarb_internal/debug.rs b/crates/dojo-lang/src/scarb_internal/debug.rs deleted file mode 100644 index 50b9ba7e0a..0000000000 --- a/crates/dojo-lang/src/scarb_internal/debug.rs +++ /dev/null @@ -1,155 +0,0 @@ -use std::collections::HashMap; -use std::env; -use std::sync::Arc; - -use anyhow::{Context, Result}; -use cairo_lang_compiler::db::RootDatabase; -use cairo_lang_diagnostics::ToOption; -use cairo_lang_filesystem::db::{get_originating_location, FilesGroup}; -use cairo_lang_filesystem::ids::{FileId, FileLongId}; -use cairo_lang_filesystem::span::TextSpan; -use cairo_lang_sierra_generator::db::SierraGenGroup; -use cairo_lang_sierra_generator::program_generator::{ - SierraProgramDebugInfo, SierraProgramWithDebug, -}; -use cairo_lang_starknet::compile::{extract_semantic_entrypoints, SemanticEntryPoints}; -use cairo_lang_starknet::contract::ContractDeclaration; -use itertools::{chain, Itertools}; -use serde::Serialize; - -pub fn compile_prepared_db_to_debug_info( - db: &RootDatabase, - contracts: &[&ContractDeclaration], - // mut compiler_config: CompilerConfig<'_>, -) -> Result> { - // compiler_config.diagnostics_reporter.ensure(db)?; - - contracts - .iter() - .map(|contract| compile_contract_with_prepared_and_checked_db_to_debug_info(db, contract)) - .try_collect() -} - -/// Compile declared Starknet contract. -/// -/// The `contract` value **must** come from `db`, for example as a result of calling -/// [`find_contracts`]. Does not check diagnostics, it is expected that they are checked by caller -/// of this function. -fn compile_contract_with_prepared_and_checked_db_to_debug_info( - db: &RootDatabase, - contract: &ContractDeclaration, -) -> Result { - let SemanticEntryPoints { external, l1_handler, constructor } = - extract_semantic_entrypoints(db, contract)?; - let SierraProgramWithDebug { program: _sierra_program, debug_info } = Arc::unwrap_or_clone( - db.get_sierra_program_for_functions( - chain!(&external, &l1_handler, &constructor).map(|f| f.value).collect(), - ) - .to_option() - .with_context(|| "Compilation failed without any diagnostics.")?, - ); - - Ok(debug_info) -} - -#[derive(Debug, Clone, Serialize)] -pub struct SierraToCairoDebugInfo { - pub sierra_statements_to_cairo_info: HashMap, -} - -/// Human readable position inside a file, in lines and characters. -#[derive(Debug, Serialize, Clone)] -pub struct TextPosition { - /// Line index, 0 based. - pub line: usize, - /// Character index inside the line, 0 based. - pub col: usize, -} - -#[derive(Debug, Serialize, Clone)] -pub struct Location { - pub start: TextPosition, - pub end: TextPosition, - pub file_path: String, -} - -#[derive(Debug, Clone, Serialize)] -pub struct SierraStatementToCairoDebugInfo { - pub cairo_locations: Vec, -} - -/// Returns a map from Sierra statement indexes to Cairo function names. -pub fn get_sierra_to_cairo_debug_info( - sierra_program_debug_info: &SierraProgramDebugInfo, - compiler_db: &RootDatabase, -) -> SierraToCairoDebugInfo { - let mut sierra_statements_to_cairo_info: HashMap = - HashMap::new(); - - for (statement_idx, locations) in - sierra_program_debug_info.statements_locations.locations.iter_sorted() - { - let mut cairo_locations: Vec = Vec::new(); - for location in locations { - let syntax_node = location.syntax_node(compiler_db); - let file_id = syntax_node.stable_ptr().file_id(compiler_db); - let _file_name = file_id.file_name(compiler_db); - let syntax_node_location_span = syntax_node.span_without_trivia(compiler_db); - - let (originating_file_id, originating_text_span) = - get_originating_location(compiler_db, file_id, syntax_node_location_span); - let cairo_location = get_location_from_text_span( - originating_text_span, - originating_file_id, - compiler_db, - ); - if let Some(cl) = cairo_location { - cairo_locations.push(cl); - } - } - sierra_statements_to_cairo_info - .insert(statement_idx.0, SierraStatementToCairoDebugInfo { cairo_locations }); - } - - SierraToCairoDebugInfo { sierra_statements_to_cairo_info } -} - -pub fn get_location_from_text_span( - text_span: TextSpan, - file_id: FileId, - compiler_db: &RootDatabase, -) -> Option { - let current_dir = env::current_dir().expect("Failed to get current directory"); - // dbg!(¤t_dir); - // let file_path = match compiler_db.lookup_intern_file(file_id) { - // FileLongId::OnDisk(path) => { - // path.strip_prefix(current_dir).expect("Failed to get relative - // path").to_path_buf().to_str().unwrap_or("").to_string() }, - // FileLongId::Virtual(_) => file_id.full_path(compiler_db), - // }; - let file_path = match compiler_db.lookup_intern_file(file_id) { - FileLongId::OnDisk(path) => match path.strip_prefix(¤t_dir) { - Ok(relative_path) => relative_path.to_str().unwrap_or("").to_string(), - Err(_) => { - return None; - } - }, - FileLongId::Virtual(_) => { - return None; - } - }; - - // let file_path = file_id.full_path(compiler_db); - - let start: Option = text_span - .start - .position_in_file(compiler_db, file_id) - .map(|s| TextPosition { line: s.line, col: s.col }); - - let end = text_span - .end - .position_in_file(compiler_db, file_id) - .map(|e| TextPosition { line: e.line, col: e.col }); - - start.zip(end).map(|(start, end)| Location { start, end, file_path }) -} diff --git a/crates/dojo-lang/src/scarb_internal/mod.rs b/crates/dojo-lang/src/scarb_internal/mod.rs deleted file mode 100644 index 15ba53e467..0000000000 --- a/crates/dojo-lang/src/scarb_internal/mod.rs +++ /dev/null @@ -1,266 +0,0 @@ -// I have copied source code from https://github.com/software-mansion/scarb/blob/main/scarb/src/compiler/db.rs -// since build_scarb_root_database is not public. -// -// NOTE: This files needs to be updated whenever scarb version is updated. -// NOTE: This file was moved here from `sozo` as we need to compile here too, -// and `sozo` has `dojo-lang` as dependency. -use anyhow::Result; -use cairo_lang_compiler::db::RootDatabase; -use cairo_lang_compiler::project::{ProjectConfig, ProjectConfigContent}; -use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; -use cairo_lang_filesystem::db::{CrateSettings, ExperimentalFeaturesConfig}; -use cairo_lang_filesystem::ids::Directory; -use cairo_lang_project::AllCratesConfig; -use cairo_lang_starknet::starknet_plugin_suite; -use cairo_lang_test_plugin::test_plugin_suite; -use cairo_lang_utils::ordered_hash_map::OrderedHashMap; -use camino::Utf8PathBuf; -use dojo_world::config::{ - NamespaceConfig, DEFAULT_NAMESPACE_CFG_KEY, DOJO_MANIFESTS_DIR_CFG_KEY, NAMESPACE_CFG_PREFIX, -}; -use dojo_world::metadata::dojo_metadata_from_package; -use regex::Regex; -use scarb::compiler::{ - CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes, CompilationUnitComponent, -}; -use scarb::core::{Config, PackageId, Workspace}; -use scarb::ops::CompileOpts; -use scarb_ui::Ui; -use smol_str::SmolStr; -use tracing::trace; - -use crate::plugin::dojo_plugin_suite; - -pub(crate) const LOG_TARGET: &str = "dojo_lang::scarb_internal"; -pub mod debug; - -/// Compilation information of all the units found in the workspace. -#[derive(Debug, Default)] -pub struct CompileInfo { - /// The name of the profile used to compile. - pub profile_name: String, - /// The path to the manifest file. - pub manifest_path: Utf8PathBuf, - /// The path to the target directory. - pub target_dir: Utf8PathBuf, - /// The name of the root package. - pub root_package_name: Option, - /// The list of units that failed to compile. - pub compile_error_units: Vec, -} - -pub fn crates_config_for_compilation_unit(unit: &CairoCompilationUnit) -> AllCratesConfig { - let crates_config: OrderedHashMap = unit - .components() - .iter() - .map(|component| { - // Ensure experimental features are only enable if required. - let experimental_features = component.package.manifest.experimental_features.clone(); - let experimental_features = experimental_features.unwrap_or_default(); - - ( - component.cairo_package_name(), - CrateSettings { - edition: component.package.manifest.edition, - experimental_features: ExperimentalFeaturesConfig { - negative_impls: experimental_features - .contains(&SmolStr::new_inline("negative_impls")), - coupons: experimental_features.contains(&SmolStr::new_inline("coupons")), - }, - cfg_set: component.cfg_set.clone(), - }, - ) - }) - .collect(); - - AllCratesConfig { override_map: crates_config, ..Default::default() } -} - -/// Builds the scarb root database injecting the dojo plugin suite, additionaly to the -/// default Starknet and Test suites. -pub fn build_scarb_root_database(unit: &CairoCompilationUnit) -> Result { - let mut b = RootDatabase::builder(); - b.with_project_config(build_project_config(unit)?); - b.with_cfg(unit.cfg_set.clone()); - - b.with_plugin_suite(test_plugin_suite()); - b.with_plugin_suite(dojo_plugin_suite()); - b.with_plugin_suite(starknet_plugin_suite()); - - b.build() -} - -/// This function is an alternative to `ops::compile`, it's doing the same job. -/// However, we can control the injection of the plugins, required to have dojo plugin present -/// for each compilation. -pub fn compile_workspace( - config: &Config, - opts: CompileOpts, - packages: Vec, -) -> Result { - let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - let resolve = scarb::ops::resolve_workspace(&ws)?; - let ui = config.ui(); - - let compilation_units = scarb::ops::generate_compilation_units(&resolve, &opts.features, &ws)? - .into_iter() - .filter(|cu| !opts.exclude_target_kinds.contains(&cu.main_component().target_kind())) - .filter(|cu| { - opts.include_target_kinds.is_empty() - || opts.include_target_kinds.contains(&cu.main_component().target_kind()) - }) - .filter(|cu| packages.contains(&cu.main_package_id())) - .collect::>(); - - let mut compile_error_units = vec![]; - - for unit in compilation_units { - trace!(target: LOG_TARGET, unit_name = %unit.name(), target_kind = %unit.main_component().target_kind(), "Compiling unit."); - - // Proc macro are not supported yet on Dojo, hence we only consider processing Cairo - // compilation units. - if let CompilationUnit::Cairo(mut unit) = unit { - let unit_name = unit.name(); - let re = Regex::new(r"\s*\([^()]*\)$").unwrap(); - let unit_name_no_path = re.replace(&unit_name, ""); - - ui.print(format!("compiling {}", unit_name_no_path)); - ui.verbose(format!("target kind: {}", unit.main_component().target_kind())); - - let dojo_metadata = dojo_metadata_from_package(&unit.components[0].package, &ws)?; - - // let root_package_data = - // PackageData::from_scarb_package(&unit.components[0].package)?; - - ui.verbose(dojo_metadata.namespace.display_mappings()); - - // For each component in the compilation unit (namely, the dependencies being - // compiled) we inject into the `CfgSet` the component name and - // namespace configuration. Doing this here ensures the parsing of - // of the manifest is done once at compile time, and not everytime - // the plugin is called. - for c in unit.components.iter_mut() { - c.cfg_set = Some(cfg_set_from_component(c, &dojo_metadata.namespace, &ui, &ws)?); - } - - let mut db = build_scarb_root_database(&unit).unwrap(); - if let Err(err) = ws.config().compilers().compile(unit.clone(), &mut (db), &ws) { - ws.config().ui().anyhow(&err); - compile_error_units.push(unit.name()); - } - } - } - - let manifest_path = ws.manifest_path().into(); - let target_dir = ws.target_dir().path_existent().unwrap(); - let target_dir = target_dir.join(ws.config().profile().as_str()); - - // The root package may be non existent in a scarb project/workspace. - // Please refer here: - let root_package_name = if let Some(package) = ws.root_package() { - Some(package.id.name.to_string()) - } else { - None - }; - - let profile_name = - if let Ok(p) = ws.current_profile() { p.to_string() } else { "NO_PROFILE".to_string() }; - - Ok(CompileInfo { - manifest_path, - target_dir, - root_package_name, - profile_name, - compile_error_units, - }) -} - -fn build_project_config(unit: &CairoCompilationUnit) -> Result { - let crate_roots = unit - .components() - .iter() - .filter(|model| !model.package.id.is_core()) - // NOTE: We're taking the first target of each compilation unit, which should always be the - // main package source root due to the order maintained by scarb. - .map(|model| (model.cairo_package_name(), model.targets[0].source_root().into())) - .collect(); - - let corelib = - // NOTE: We're taking the first target of the corelib, which should always be the - // main package source root due to the order maintained by scarb. - unit.core_package_component().map(|c| Directory::Real(c.targets[0].source_root().into())); - - let content = ProjectConfigContent { - crate_roots, - crates_config: crates_config_for_compilation_unit(unit), - }; - - let project_config = - ProjectConfig { base_path: unit.main_component().package.root().into(), corelib, content }; - - trace!(target: LOG_TARGET, ?project_config); - - Ok(project_config) -} - -pub fn cfg_set_from_component( - c: &CompilationUnitComponent, - root_package_namespace: &NamespaceConfig, - ui: &Ui, - ws: &Workspace<'_>, -) -> Result { - let cname = c.cairo_package_name().clone(); - let package_dojo_metadata = dojo_metadata_from_package(&c.package, ws)?; - - let dojo_manifests_dir = ws - .config() - .manifest_path() - .parent() - .expect("Scarb.toml manifest should always have parent") - .join("manifests") - .join(ws.current_profile().expect("profile should be set").to_string()); - - ui.verbose(format!("component: {} ({})", cname, c.package.manifest_path())); - - tracing::debug!(target: LOG_TARGET, ?c, ?package_dojo_metadata); - - let component_cfg = Cfg { key: "component_name".into(), value: Some(cname) }; - - let mut cfg_set = CfgSet::new(); - - // Keep orinigal cfg set of the component. - if let Some(component_cfg_set) = c.cfg_set.clone() { - for cfg in component_cfg_set.into_iter() { - cfg_set.insert(cfg); - } - } - - // Add it's name for debugging on the plugin side. - cfg_set.insert(component_cfg); - - cfg_set.insert(Cfg { - key: DOJO_MANIFESTS_DIR_CFG_KEY.into(), - value: Some(dojo_manifests_dir.to_string().into()), - }); - - cfg_set.insert(Cfg { - key: DEFAULT_NAMESPACE_CFG_KEY.into(), - value: Some(package_dojo_metadata.namespace.default.into()), - }); - - // We ignore mappings for dependencies as the [[target.dojo]] package is - // defining them. - - // Inject the mapping from the root package with [[target.dojo]] to - // all dependencies to ensure correct namespace mappings. - if let Some(mappings) = &root_package_namespace.mappings { - for (k, v) in mappings.iter() { - cfg_set.insert(Cfg { - key: format!("{}{}", NAMESPACE_CFG_PREFIX, k).into(), - value: Some(v.into()), - }); - } - } - - Ok(cfg_set) -} diff --git a/crates/dojo-lang/src/semantics/mod.rs b/crates/dojo-lang/src/semantics/mod.rs deleted file mode 100644 index 4570554d21..0000000000 --- a/crates/dojo-lang/src/semantics/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod utils; - -#[cfg(test)] -pub mod test_utils; - -#[cfg(test)] -pub mod tests; diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs deleted file mode 100644 index 13f2a76755..0000000000 --- a/crates/dojo-lang/src/utils.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::fs; - -use anyhow::Result; -use cairo_lang_filesystem::ids::Directory; -use cairo_lang_syntax::node::db::SyntaxGroup; -use dojo_world::config::NamespaceConfig; -use regex::Regex; -use toml::Table; - -/// Check if the provided name follows the format rules. -pub fn is_name_valid(name: &str) -> bool { - Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(name) -} - -/// Get the namespace configuration from the workspace. -// TODO: Ask to Scarb team to expose this information with the new macro system. -pub fn get_namespace_config(db: &dyn SyntaxGroup) -> Result { - // Super verbose print, but useful to get the CfgSet. - // debug!(cfg_set = ?db.cfg_set(), crates = ?db.crates(), "Retrieving namespace - // configuration."); - - let crates = db.crates(); - - if crates.is_empty() { - return Err(anyhow::anyhow!( - "No crates found in the workspace, hence no namespace configuration." - )); - } - - // Crates[0] is always the root crate that triggered the build origin. - // In case of a library, crates[0] refers to the lib itself if compiled directly, - // or the crate using the library otherwise. - let configuration = match db - .crate_config(*crates.first().expect("No root crate found in the workspace.")) - { - Option::Some(cfg) => cfg, - Option::None => return Err(anyhow::anyhow!("No configuration found for the root crate.")), - }; - - if let Directory::Real(ref path) = configuration.root { - let config_path = path.parent().unwrap().join("Scarb.toml"); - - // Very verbose. - // tracing::debug!(config_path = %config_path.to_string_lossy(), "Reading Scarb.toml file - // for namespace config."); - - let config_content = match fs::read_to_string(&config_path) { - Ok(x) => x, - Err(e) => return Err(anyhow::anyhow!("Failed to read Scarb.toml file: {e}.")), - }; - let config = match config_content.parse::() { - Ok(x) => x, - Err(e) => return Err(anyhow::anyhow!("Failed to parse Scarb.toml file: {e}.")), - }; - - if let Some(tool) = config.get("tool").and_then(|t| t.as_table()) { - if let Some(dojo) = tool.get("dojo").and_then(|d| d.as_table()) { - if let Some(world) = dojo.get("world").and_then(|w| w.as_table()) { - if let Some(namespace_config) = - world.get("namespace").and_then(|n| n.as_table()) - { - match toml::from_str::(&namespace_config.to_string()) { - Ok(config) => return config.validate(), - Err(e) => { - return Err(anyhow::anyhow!( - "Failed to parse namespace configuration of {}: {}", - config_path.to_string_lossy().to_string(), - e - )); - } - } - } - } - } - } - } - - // If no namespace is found, we return a default one as it's surely a crate that doesn't - // need it. This only concern the tests. - Ok(NamespaceConfig { default: "__NO_NAMESPACE__".into(), mappings: None }) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_is_name_valid() { - assert!(is_name_valid("valid_name")); - assert!(is_name_valid("ValidName")); - assert!(is_name_valid("valid123")); - assert!(is_name_valid("_valid")); - assert!(is_name_valid("valid_")); - - assert!(!is_name_valid("")); - assert!(!is_name_valid("invalid-name")); - assert!(!is_name_valid("invalid name")); - assert!(!is_name_valid("invalid!name")); - assert!(!is_name_valid("invalid.name")); - } -} diff --git a/crates/dojo-lang/src/version.rs b/crates/dojo-lang/src/version.rs deleted file mode 100644 index 1a1c023dad..0000000000 --- a/crates/dojo-lang/src/version.rs +++ /dev/null @@ -1,31 +0,0 @@ -use anyhow::Result; -use semver::Version; - -pub trait ToVersion { - fn to_version(self) -> Result; -} - -impl ToVersion for Version { - fn to_version(self) -> Result { - Ok(self) - } -} - -impl<'a> ToVersion for &'a str { - fn to_version(self) -> Result { - Version::parse(self.trim()) - .map_err(|_| anyhow::format_err!("cannot parse '{}' as a semver", self)) - } -} - -impl<'a> ToVersion for &'a String { - fn to_version(self) -> Result { - (**self).to_version() - } -} - -impl<'a> ToVersion for &'a Version { - fn to_version(self) -> Result { - Ok(self.clone()) - } -} diff --git a/crates/dojo-test-utils/src/migration.rs b/crates/dojo-test-utils/src/migration.rs deleted file mode 100644 index 1ee5d561f6..0000000000 --- a/crates/dojo-test-utils/src/migration.rs +++ /dev/null @@ -1,83 +0,0 @@ -use anyhow::Result; -use camino::Utf8PathBuf; -use dojo_world::manifest::{BaseManifest, OverlayManifest, BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR}; -use dojo_world::migration::strategy::{prepare_for_migration, MigrationStrategy}; -use dojo_world::migration::world::WorldDiff; -use starknet::core::types::Felt; -use starknet::core::utils::cairo_short_string_to_felt; -use starknet::macros::felt; - -pub const SPAWN_AND_MOVE_TEST_DB_DIR: &str = "/tmp/spawn-and-move-db"; -pub const TYPES_TEST_DB_DIR: &str = "/tmp/types-test-db"; - -/// Copies the spawn and move test database to a temporary directory and returns the path to the -/// temporary directory. Must be used if the test is going to modify the database. -pub fn copy_spawn_and_move_db() -> Utf8PathBuf { - crate::compiler::copy_tmp_dir(&Utf8PathBuf::from(SPAWN_AND_MOVE_TEST_DB_DIR)) -} - -/// Copies the types test database to a temporary directory and returns the path to the temporary -/// directory. Must be used if the test is going to modify the database. -pub fn copy_types_test_db() -> Utf8PathBuf { - crate::compiler::copy_tmp_dir(&Utf8PathBuf::from(TYPES_TEST_DB_DIR)) -} - -pub fn prepare_migration( - manifest_dir: Utf8PathBuf, - target_dir: Utf8PathBuf, - skip_migration: Option>, - default_namespace: &str, -) -> Result<(MigrationStrategy, WorldDiff)> { - // In testing, profile name is always dev. - let profile_name = "dev"; - - let mut manifest = BaseManifest::load_from_path( - &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), - ) - .unwrap(); - - if let Some(skip_manifests) = &skip_migration { - manifest.remove_tags(skip_manifests); - } - - let overlay_dir = manifest_dir.join(OVERLAYS_DIR).join(profile_name); - - if overlay_dir.exists() { - let overlay_manifest = OverlayManifest::load_from_path(&overlay_dir, &manifest).unwrap(); - manifest.merge(overlay_manifest); - } - - let world = WorldDiff::compute(manifest, None, default_namespace)?; - - let strat = prepare_for_migration(None, felt!("0x12345"), &target_dir, world.clone()).unwrap(); - - Ok((strat, world)) -} - -pub fn prepare_migration_with_world_and_seed( - manifest_dir: Utf8PathBuf, - target_dir: Utf8PathBuf, - world_address: Option, - seed: &str, - default_namespace: &str, -) -> Result<(MigrationStrategy, WorldDiff)> { - // In testing, profile name is always dev. - let profile_name = "dev"; - - let mut manifest = BaseManifest::load_from_path( - &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), - ) - .unwrap(); - - let overlay_dir = manifest_dir.join(OVERLAYS_DIR).join(profile_name); - if overlay_dir.exists() { - let overlay_manifest = OverlayManifest::load_from_path(&overlay_dir, &manifest).unwrap(); - manifest.merge(overlay_manifest); - } - - let world = WorldDiff::compute(manifest.clone(), None, default_namespace)?; - - let seed = cairo_short_string_to_felt(seed).unwrap(); - let strat = prepare_for_migration(world_address, seed, &target_dir, world.clone())?; - Ok((strat, world)) -} diff --git a/crates/dojo-utils/src/lib.rs b/crates/dojo-utils/src/lib.rs deleted file mode 100644 index 519a7027c4..0000000000 --- a/crates/dojo-utils/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![cfg_attr(not(test), warn(unused_crate_dependencies))] - -pub mod parse; -mod tx; - -pub use tx::waiter::*; -pub use tx::{TransactionExt, TxnAction, TxnConfig}; - -pub mod env; -pub mod keystore; - -pub mod signal; diff --git a/crates/dojo-utils/src/tx/mod.rs b/crates/dojo-utils/src/tx/mod.rs deleted file mode 100644 index d1d5f90110..0000000000 --- a/crates/dojo-utils/src/tx/mod.rs +++ /dev/null @@ -1,126 +0,0 @@ -pub mod waiter; - -use anyhow::Result; -use starknet::accounts::{ - AccountDeploymentV1, AccountError, AccountFactory, AccountFactoryError, ConnectedAccount, - DeclarationV2, ExecutionV1, -}; -use starknet::core::types::{ - DeclareTransactionResult, DeployAccountTransactionResult, Felt, InvokeTransactionResult, -}; - -/// The transaction configuration to use when sending a transaction. -#[derive(Debug, Copy, Clone, Default)] -pub struct TxnConfig { - /// The multiplier for how much the actual transaction max fee should be relative to the - /// estimated fee. If `None` is provided, the multiplier is set to `1.1`. - pub fee_estimate_multiplier: Option, - pub wait: bool, - pub receipt: bool, - pub max_fee_raw: Option, - pub walnut: bool, -} - -#[derive(Debug, Copy, Clone)] -pub enum TxnAction { - Send { - wait: bool, - receipt: bool, - max_fee_raw: Option, - /// The multiplier for how much the actual transaction max fee should be relative to the - /// estimated fee. If `None` is provided, the multiplier is set to `1.1`. - fee_estimate_multiplier: Option, - walnut: bool, - }, - Estimate, - Simulate, -} - -impl TxnConfig { - pub fn init_wait() -> Self { - Self { wait: true, ..Default::default() } - } -} - -/// Helper trait to abstract away setting `TxnConfig` configurations before sending a transaction -/// Implemented by types from `starknet-accounts` like `Execution`, `Declaration`, etc... -#[allow(async_fn_in_trait)] -pub trait TransactionExt { - type R; - type U; - - /// Sets `fee_estimate_multiplier` and `max_fee_raw` from `TxnConfig` if its present before - /// calling `send` method on the respective type. - /// NOTE: If both are specified `max_fee_raw` will take precedence and `fee_estimate_multiplier` - /// will be ignored by `starknet-rs` - async fn send_with_cfg(self, txn_config: &TxnConfig) -> Result; -} - -impl TransactionExt for ExecutionV1<'_, T> -where - T: ConnectedAccount + Sync, -{ - type R = InvokeTransactionResult; - type U = AccountError; - - async fn send_with_cfg( - mut self, - txn_config: &TxnConfig, - ) -> Result> { - if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { - self = self.fee_estimate_multiplier(*fee_est_mul); - } - - if let TxnConfig { max_fee_raw: Some(max_fee_r), .. } = txn_config { - self = self.max_fee(*max_fee_r); - } - - self.send().await - } -} - -impl TransactionExt for DeclarationV2<'_, T> -where - T: ConnectedAccount + Sync, -{ - type R = DeclareTransactionResult; - type U = AccountError; - - async fn send_with_cfg( - mut self, - txn_config: &TxnConfig, - ) -> Result> { - if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { - self = self.fee_estimate_multiplier(*fee_est_mul); - } - - if let TxnConfig { max_fee_raw: Some(max_raw_f), .. } = txn_config { - self = self.max_fee(*max_raw_f); - } - - self.send().await - } -} - -impl TransactionExt for AccountDeploymentV1<'_, T> -where - T: AccountFactory + Sync, -{ - type R = DeployAccountTransactionResult; - type U = AccountFactoryError; - - async fn send_with_cfg( - mut self, - txn_config: &TxnConfig, - ) -> Result::SignError>> { - if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { - self = self.fee_estimate_multiplier(*fee_est_mul); - } - - if let TxnConfig { max_fee_raw: Some(max_raw_f), .. } = txn_config { - self = self.max_fee(*max_raw_f); - } - - self.send().await - } -} diff --git a/crates/dojo-world/Cargo.toml b/crates/dojo-world/Cargo.toml deleted file mode 100644 index b380b04615..0000000000 --- a/crates/dojo-world/Cargo.toml +++ /dev/null @@ -1,55 +0,0 @@ -[package] -description = "Dojo world specification. For example, crates and flags used for compilation." -edition.workspace = true -license-file.workspace = true -name = "dojo-world" -repository.workspace = true -version.workspace = true - -[dependencies] -anyhow.workspace = true -async-trait.workspace = true -cairo-lang-filesystem.workspace = true -cairo-lang-project.workspace = true -cairo-lang-starknet.workspace = true -cairo-lang-starknet-classes.workspace = true -camino.workspace = true -convert_case.workspace = true -dojo-utils = { workspace = true, optional = true } -num-traits = { workspace = true, optional = true } -regex.workspace = true -serde.workspace = true -serde_json.workspace = true -serde_with.workspace = true -smol_str.workspace = true -starknet.workspace = true -starknet-crypto.workspace = true -thiserror.workspace = true -topological-sort.workspace = true -tracing.workspace = true - -cainome.workspace = true -dojo-types = { path = "../dojo-types", optional = true } -http = { workspace = true, optional = true } -ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ], optional = true } -scarb = { workspace = true, optional = true } -tokio = { version = "1.32.0", features = [ "time" ], default-features = false, optional = true } -toml.workspace = true -url = { workspace = true, optional = true } -walkdir.workspace = true - -[dev-dependencies] -assert_fs.workspace = true -assert_matches.workspace = true -dojo-lang.workspace = true -dojo-test-utils = { path = "../dojo-test-utils" } -katana-runner.workspace = true -similar-asserts.workspace = true -tempfile.workspace = true -tokio.workspace = true - -[features] -contracts = [ "dep:dojo-types", "dep:http", "dep:num-traits" ] -manifest = [ "contracts", "dep:dojo-types", "dep:scarb", "dep:url" ] -metadata = [ "dep:ipfs-api-backend-hyper", "dep:scarb", "dep:url" ] -migration = [ "dep:dojo-utils", "dep:scarb", "dep:tokio", "manifest" ] diff --git a/crates/dojo-world/abigen/src/main.rs b/crates/dojo-world/abigen/src/main.rs deleted file mode 100644 index c4dec4702d..0000000000 --- a/crates/dojo-world/abigen/src/main.rs +++ /dev/null @@ -1,145 +0,0 @@ -/// Script that generates the bindings for World and Executor contracts. -use std::fs::{self, File}; -use std::io::Write; -use std::path::Path; - -use cairo_lang_starknet_classes::contract_class::ContractClass; -use camino::Utf8PathBuf; -use scarb::core::{Config, TargetKind}; -use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; - -const SCARB_MANIFEST: &str = "crates/dojo-core/Scarb.toml"; -const SCARB_MANIFEST_BACKUP: &str = "crates/dojo-core/bak.Scarb.toml"; -const SCARB_LOCK: &str = "crates/dojo-core/Scarb.lock"; -const SCARB_LOCK_BACKUP: &str = "crates/dojo-core/bak.Scarb.lock"; -const WORLD_ARTIFACT: &str = "crates/dojo-core/target/dev/dojo_world.contract_class.json"; -const MODEL_ARTIFACT: &str = - "crates/dojo-core/target/dev/dojo_resource_metadata.contract_class.json"; -const OUT_DIR: &str = "crates/dojo-world/src/contracts/abi"; - -fn define_check_only() -> bool { - let args: Vec<_> = std::env::args().collect(); - - args.len() > 1 && args[1] == "--check" -} - -fn main() { - let is_check_only = define_check_only(); - - compile_dojo_core(); - - generate_bindings("WorldContract", WORLD_ARTIFACT, "world.rs", is_check_only); - generate_bindings("ModelContract", MODEL_ARTIFACT, "model.rs", is_check_only); -} - -/// Generates the bindings for the given contracts, or verifies -/// if the bindings are up to date. -fn generate_bindings( - contract_name: &str, - contract_artifact_path: &str, - bindings_filename: &str, - is_check_only: bool, -) { - let contract = - serde_json::from_reader::<_, ContractClass>(File::open(contract_artifact_path).unwrap()) - .expect("Could not read World Contract Class file"); - - let bindings = get_bindings_file_content(contract_name, contract); - let out_path = format!("{OUT_DIR}/{bindings_filename}"); - - if is_check_only { - if Path::new(&out_path).exists() { - let existing_bindings = fs::read_to_string(out_path).expect("Could not read file"); - - // Trim to remove the last empty line of the file. - if existing_bindings.trim() != bindings { - panic!( - "{contract_name} ABI bindings are not up to date. Consider generating them \ - running `cargo run -p dojo-world-abigen`" - ); - } - } else { - println!("No bindings found for {contract_name}, check skipped"); - } - } else { - write_file(&out_path, &bindings); - } -} - -fn rename_file(old_path: &str, new_path: &str) { - let o = Path::new(old_path); - let n = Path::new(new_path); - fs::rename(o, n) - .unwrap_or_else(|e| panic!("Could not rename file {old_path} into {new_path}: {e}")); -} - -fn write_file(file_path: &str, content: &str) { - let mut file = File::create(file_path).expect("Could not create file"); - writeln!(file, "{}", content).expect("Could not write Scarb.toml file"); -} - -/// Writes a binding file using cainome inlined ABI for the given contract. -fn get_bindings_file_content(contract_name: &str, contract_class: ContractClass) -> String { - format!( - "// AUTOGENERATED FILE, DO NOT EDIT.\n// To generate the bindings, please run `cargo run \ - --bin dojo-world-abigen` instead.\nuse cainome::rs::abigen;\n\nabigen!(\n {},\n \ - r#\"{}\"#,\ntype_aliases {{\ndojo::world::config::Config::Event as \ - DojoConfigEvent;\n}},derives(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, \ - Clone),contract_derives(Debug)\n);", - contract_name, - serde_json::to_string_pretty(&contract_class.abi).unwrap() - ) -} - -/// Compiles dojo-core contracts targetting starknet contract without using dojo-plugin. -fn compile_dojo_core() { - rename_file(SCARB_MANIFEST, SCARB_MANIFEST_BACKUP); - - if Path::new(SCARB_LOCK).exists() { - rename_file(SCARB_LOCK, SCARB_LOCK_BACKUP); - } - - // Write new Scarb.toml file with starknet contract target. - let mut file = File::create(SCARB_MANIFEST).expect("Could not create file"); - writeln!( - file, - r#" -[package] -cairo-version = "2.7.0" -edition = "2024_07" -name = "dojo" -version = "1.0.0-alpha.4" - -[dependencies] -starknet = "2.7.0" - -[[target.starknet-contract]] -sierra = true -"#, - ) - .expect("Could not write Scarb.toml file"); - - let path = Utf8PathBuf::from(SCARB_MANIFEST); - let config = Config::builder(path.canonicalize_utf8().unwrap()).build().unwrap(); - let ws = scarb::ops::read_workspace(config.manifest_path(), &config) - .expect("Could not read Scarb workspace"); - let packages = ws.members().map(|p| p.id).collect(); - - let features_opts = - FeaturesOpts { features: FeaturesSelector::AllFeatures, no_default_features: false }; - - scarb::ops::compile( - packages, - CompileOpts { - include_target_names: vec![], - include_target_kinds: vec![], - exclude_target_kinds: vec![TargetKind::TEST], - features: features_opts, - }, - &ws, - ) - .expect("Could not run Scarb compile"); - - rename_file(SCARB_MANIFEST_BACKUP, SCARB_MANIFEST); - rename_file(SCARB_LOCK_BACKUP, SCARB_LOCK); -} diff --git a/crates/dojo-world/src/config/migration_config.rs b/crates/dojo-world/src/config/migration_config.rs deleted file mode 100644 index deab3f57aa..0000000000 --- a/crates/dojo-world/src/config/migration_config.rs +++ /dev/null @@ -1,6 +0,0 @@ -use serde::Deserialize; - -#[derive(Debug, Clone, Deserialize)] -pub struct MigrationConfig { - pub skip_contracts: Vec, -} diff --git a/crates/dojo-world/src/config/namespace_config.rs b/crates/dojo-world/src/config/namespace_config.rs deleted file mode 100644 index 89a709f090..0000000000 --- a/crates/dojo-world/src/config/namespace_config.rs +++ /dev/null @@ -1,264 +0,0 @@ -use std::collections::HashMap; - -use anyhow::Result; -use cairo_lang_filesystem::cfg::CfgSet; -use regex::Regex; -use serde::Deserialize; - -pub const NAMESPACE_CFG_PREFIX: &str = "nm|"; -pub const DEFAULT_NAMESPACE_CFG_KEY: &str = "namespace_default"; -pub const DOJO_MANIFESTS_DIR_CFG_KEY: &str = "dojo_manifests_dir"; -pub const DEFAULT_NAMESPACE: &str = "DEFAULT_NAMESPACE"; - -/// Namespace configuration. -#[derive(Debug, Clone, Deserialize)] -pub struct NamespaceConfig { - pub default: String, - pub mappings: Option>, -} - -impl Default for NamespaceConfig { - fn default() -> Self { - NamespaceConfig { default: DEFAULT_NAMESPACE.to_string(), mappings: None } - } -} - -impl NamespaceConfig { - /// Creates a new namespace configuration with a default namespace. - pub fn new(default: &str) -> Self { - NamespaceConfig { default: default.to_string(), mappings: None } - } - - /// Adds mappings to the namespace configuration. - pub fn with_mappings(mut self, mappings: HashMap) -> Self { - self.mappings = Some(mappings); - self - } - - /// Displays the namespace mappings as a string. - pub fn display_mappings(&self) -> String { - if let Some(mappings) = &self.mappings { - let mut result = String::from("\n-- Mappings --\n"); - for (k, v) in mappings.iter() { - result += &format!("{} -> {}\n", k, v); - } - result - } else { - "No mapping to apply".to_string() - } - } - - /// Gets the namespace for a given tag or namespace, or return the default - /// namespace if no mapping was found. - /// - /// If the input is a tag, a first perfect match is checked. If no match - /// for the tag, then a check is done against the namespace of the tag. - /// If the input is a namespace, a perfect match if checked. - /// - /// Examples: - /// - `get_mapping("armory-Flatbow")` first checks for `armory-Flatbow` tag, then for `armory` - /// namespace in mapping keys. - /// - `get_mapping("armory")` checks for `armory` namespace in mapping keys. - /// - /// # Arguments - /// - /// * `tag_or_namespace`: the tag or namespace to get the namespace for. - /// - /// # Returns - /// - /// A [`String`] object containing the namespace. - pub fn get_mapping(&self, tag_or_namespace: &str) -> String { - if let Some(namespace_from_tag) = - self.mappings.as_ref().and_then(|m| m.get(tag_or_namespace)) - { - namespace_from_tag.clone() - } else if tag_or_namespace.contains('-') { - // TODO: we can't access the dojo-world/contracts from here as it belongs to a different - // feature. The naming module has to be relocated in more generic place, - // always available. - let (namespace, _) = tag_or_namespace.split_at(tag_or_namespace.rfind('-').unwrap()); - self.mappings - .as_ref() - .and_then(|m| m.get(namespace)) - .unwrap_or(&self.default) - .to_string() - } else { - self.default.clone() - } - } - - /// Validates the namespace configuration and their names. - /// - /// # Returns - /// - /// A [`Result`] object containing the namespace configuration if valid, error otherwise. - pub fn validate(self) -> Result { - if self.default.is_empty() { - return Err(anyhow::anyhow!("Default namespace is empty")); - } - - if !Self::is_name_valid(&self.default) { - return Err(anyhow::anyhow!("Invalid default namespace `{}`", self.default)); - } - - for (tag_or_namespace, namespace) in self.mappings.as_ref().unwrap_or(&HashMap::new()) { - if !Self::is_name_valid(namespace) { - return Err(anyhow::anyhow!( - "Invalid namespace `{}` for tag or namespace `{}`", - namespace, - tag_or_namespace - )); - } - } - - Ok(self) - } - - /// Checks if the provided namespace follows the format rules. - pub fn is_name_valid(namespace: &str) -> bool { - Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(namespace) - } -} - -impl From<&CfgSet> for NamespaceConfig { - fn from(cfg_set: &CfgSet) -> Self { - let mut default = "".to_string(); - let mut mappings = HashMap::new(); - - for cfg in cfg_set.into_iter() { - if cfg.key == DEFAULT_NAMESPACE_CFG_KEY { - if let Some(v) = &cfg.value { - default = v.to_string(); - } - } else if cfg.key.starts_with(NAMESPACE_CFG_PREFIX) { - let key = cfg.key.replace(NAMESPACE_CFG_PREFIX, ""); - if let Some(v) = &cfg.value { - mappings.insert(key, v.to_string()); - } - } - } - - let mappings = if mappings.is_empty() { None } else { Some(mappings) }; - - NamespaceConfig { default: default.to_string(), mappings } - } -} - -#[cfg(test)] -mod tests { - use cairo_lang_filesystem::cfg::Cfg; - use smol_str::SmolStr; - - use super::*; - - #[test] - fn test_namespace_config_get_mapping() { - let config = NamespaceConfig { - default: "nm".to_string(), - mappings: Some(HashMap::from([ - ("tag1".to_string(), "namespace1".to_string()), - ("namespace2".to_string(), "namespace2".to_string()), - ("armory-Flatbow".to_string(), "weapons".to_string()), - ])), - }; - - assert_eq!(config.get_mapping("tag1"), "namespace1"); - assert_eq!(config.get_mapping("tag1-TestModel"), "namespace1"); - assert_eq!(config.get_mapping("namespace2"), "namespace2"); - assert_eq!(config.get_mapping("armory-Flatbow"), "weapons"); - assert_eq!(config.get_mapping("armory"), "nm"); - assert_eq!(config.get_mapping("unknown"), "nm"); - } - - #[test] - fn test_namespace_config_validate() { - let valid_config = NamespaceConfig { - default: "valid_default".to_string(), - mappings: Some(HashMap::from([ - ("tag1".to_string(), "valid_namespace1".to_string()), - ("tag2".to_string(), "valid_namespace2".to_string()), - ])), - }; - assert!(valid_config.validate().is_ok()); - - let empty_default_config = NamespaceConfig { default: "".to_string(), mappings: None }; - assert!(empty_default_config.validate().is_err()); - - let invalid_default_config = - NamespaceConfig { default: "invalid-default".to_string(), mappings: None }; - assert!(invalid_default_config.validate().is_err()); - - let invalid_mapping_config = NamespaceConfig { - default: "valid_default".to_string(), - mappings: Some(HashMap::from([ - ("tag1".to_string(), "valid_namespace".to_string()), - ("tag2".to_string(), "invalid-namespace".to_string()), - ])), - }; - assert!(invalid_mapping_config.validate().is_err()); - } - - #[test] - fn test_namespace_config_new() { - let config = NamespaceConfig::new("default_namespace"); - assert_eq!(config.default, "default_namespace"); - assert_eq!(config.mappings, None); - } - - #[test] - fn test_namespace_config_with_mappings() { - let mut mappings = HashMap::new(); - mappings.insert("tag1".to_string(), "namespace1".to_string()); - mappings.insert("tag2".to_string(), "namespace2".to_string()); - - let config = NamespaceConfig::new("default_namespace").with_mappings(mappings.clone()); - assert_eq!(config.default, "default_namespace"); - assert_eq!(config.mappings, Some(mappings)); - } - - #[test] - fn test_is_name_valid_with_valid_names() { - assert!(NamespaceConfig::is_name_valid("validName")); - assert!(NamespaceConfig::is_name_valid("valid_name")); - assert!(NamespaceConfig::is_name_valid("ValidName123")); - assert!(NamespaceConfig::is_name_valid("VALID_NAME")); - assert!(NamespaceConfig::is_name_valid("v")); - } - - #[test] - fn test_is_name_valid_with_invalid_names() { - assert!(!NamespaceConfig::is_name_valid("invalid-name")); - assert!(!NamespaceConfig::is_name_valid("invalid name")); - assert!(!NamespaceConfig::is_name_valid("invalid.name")); - assert!(!NamespaceConfig::is_name_valid("invalid!name")); - assert!(!NamespaceConfig::is_name_valid("")); - } - - #[test] - fn test_namespace_config_from_cfg_set() { - let mut cfg_set = CfgSet::new(); - cfg_set.insert(Cfg::kv(DEFAULT_NAMESPACE_CFG_KEY, SmolStr::from("default_namespace"))); - cfg_set - .insert(Cfg::kv(format!("{}tag1", NAMESPACE_CFG_PREFIX), SmolStr::from("namespace1"))); - cfg_set - .insert(Cfg::kv(format!("{}tag2", NAMESPACE_CFG_PREFIX), SmolStr::from("namespace2"))); - - let namespace_config = NamespaceConfig::from(&cfg_set); - - assert_eq!(namespace_config.default, "default_namespace"); - assert_eq!( - namespace_config.mappings, - Some(HashMap::from([ - ("tag1".to_string(), "namespace1".to_string()), - ("tag2".to_string(), "namespace2".to_string()), - ])) - ); - - // Test with empty CfgSet - let empty_cfg_set = CfgSet::new(); - let empty_namespace_config = NamespaceConfig::from(&empty_cfg_set); - - assert_eq!(empty_namespace_config.default, ""); - assert_eq!(empty_namespace_config.mappings, None); - } -} diff --git a/crates/dojo-world/src/contracts/abi/executor.rs b/crates/dojo-world/src/contracts/abi/executor.rs deleted file mode 100644 index 653243644c..0000000000 --- a/crates/dojo-world/src/contracts/abi/executor.rs +++ /dev/null @@ -1,60 +0,0 @@ -// AUTOGENERATED FILE, DO NOT EDIT. -// To generate the bindings, please run `cargo run --bin dojo-world-abigen` instead. -use cainome::rs::abigen; - -abigen!( - ExecutorContract, - r#"[ - { - "type": "impl", - "name": "Executor", - "interface_name": "dojo::executor::IExecutor" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "interface", - "name": "dojo::executor::IExecutor", - "items": [ - { - "type": "function", - "name": "call", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "entrypoint", - "type": "core::felt252" - }, - { - "name": "calldata", - "type": "core::array::Span::" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo::executor::executor::Event", - "kind": "enum", - "variants": [] - } -]"# -); diff --git a/crates/dojo-world/src/contracts/abi/mod.rs b/crates/dojo-world/src/contracts/abi/mod.rs deleted file mode 100644 index 3a145dcfd5..0000000000 --- a/crates/dojo-world/src/contracts/abi/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod executor; -pub mod model; -pub mod world; diff --git a/crates/dojo-world/src/contracts/abi/model.rs b/crates/dojo-world/src/contracts/abi/model.rs deleted file mode 100644 index da4cf01ee1..0000000000 --- a/crates/dojo-world/src/contracts/abi/model.rs +++ /dev/null @@ -1,329 +0,0 @@ -// AUTOGENERATED FILE, DO NOT EDIT. -// To generate the bindings, please run `cargo run --bin dojo-world-abigen` instead. -use cainome::rs::abigen; - -abigen!( - ModelContract, - r#"[ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "event", - "name": "dojo::model::metadata::resource_metadata::Event", - "kind": "enum", - "variants": [] - } -]"#, -type_aliases { -dojo::world::config::Config::Event as DojoConfigEvent; -},derives(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone),contract_derives(Debug) -); diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs deleted file mode 100644 index bba5aa4b44..0000000000 --- a/crates/dojo-world/src/contracts/abi/world.rs +++ /dev/null @@ -1,1241 +0,0 @@ -// AUTOGENERATED FILE, DO NOT EDIT. -// To generate the bindings, please run `cargo run --bin dojo-world-abigen` instead. -use cainome::rs::abigen; - -abigen!( - WorldContract, - r#"[ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::world_contract::IWorld" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::model::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "enum", - "name": "dojo::world::world_contract::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Contract", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Namespace", - "type": "()" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::world_contract::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::world_contract::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::world::update::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::world::update::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::world::update::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::update::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::world::update::ProgramOutput" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "ConfigImpl", - "interface_name": "dojo::world::config::IConfig" - }, - { - "type": "interface", - "name": "dojo::world::config::IConfig", - "items": [ - { - "type": "function", - "name": "set_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_facts_registry", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_facts_registry", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::Event", - "kind": "enum", - "variants": [ - { - "name": "DifferProgramHashUpdate", - "type": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "nested" - }, - { - "name": "FactsRegistryUpdate", - "type": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StateUpdated", - "kind": "struct", - "members": [ - { - "name": "da_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world_contract::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::world::config::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world_contract::world::StateUpdated", - "kind": "nested" - } - ] - } -]"#, -type_aliases { -dojo::world::config::Config::Event as DojoConfigEvent; -},derives(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone),contract_derives(Debug) -); diff --git a/crates/dojo-world/src/contracts/mod.rs b/crates/dojo-world/src/contracts/mod.rs deleted file mode 100644 index d70cf4fd80..0000000000 --- a/crates/dojo-world/src/contracts/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod abi; -pub mod cairo_utils; -pub mod model; -pub mod naming; -pub mod world; - -pub use world::{WorldContract, WorldContractReader}; diff --git a/crates/dojo-world/src/lib.rs b/crates/dojo-world/src/lib.rs deleted file mode 100644 index 03fd6239d5..0000000000 --- a/crates/dojo-world/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[cfg(feature = "metadata")] -pub mod config; -#[cfg(feature = "contracts")] -pub mod contracts; -#[cfg(feature = "manifest")] -pub mod manifest; -#[cfg(feature = "metadata")] -pub mod metadata; -#[cfg(feature = "migration")] -pub mod migration; -#[cfg(feature = "metadata")] -pub mod uri; diff --git a/crates/dojo-world/src/manifest/manifest_test.rs b/crates/dojo-world/src/manifest/manifest_test.rs deleted file mode 100644 index eb66cb326a..0000000000 --- a/crates/dojo-world/src/manifest/manifest_test.rs +++ /dev/null @@ -1,645 +0,0 @@ -use std::io::Write; - -use cainome::cairo_serde::{ByteArray, CairoSerde}; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::{copy_spawn_and_move_db, prepare_migration_with_world_and_seed}; -use dojo_test_utils::rpc::MockJsonRpcTransport; -use katana_runner::RunnerCtx; -use scarb::compiler::Profile; -use serde_json::json; -use starknet::accounts::ConnectedAccount; -use starknet::core::types::contract::AbiEntry; -use starknet::core::types::{EmittedEvent, Felt}; -use starknet::macros::{felt, selector}; -use starknet::providers::jsonrpc::{JsonRpcClient, JsonRpcMethod}; - -use super::{ - parse_contracts_events, AbiFormat, BaseManifest, DojoContract, DojoModel, OverlayDojoContract, - OverlayManifest, -}; -use crate::contracts::naming::{get_filename_from_tag, get_tag}; -use crate::manifest::{ - parse_models_events, AbstractManifestError, DeploymentManifest, Manifest, OverlayClass, - OverlayDojoModel, BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR, -}; -use crate::metadata::dojo_metadata_from_workspace; -use crate::migration::world::WorldDiff; - -#[tokio::test] -async fn manifest_from_remote_throw_error_on_not_deployed() { - let mut mock_transport = MockJsonRpcTransport::new(); - mock_transport.set_response( - JsonRpcMethod::GetClassHashAt, - json!(["pending", "0x1"]), - json!({ - "id": 1, - "error": { - "code": 20, - "message": "Contract not found" - }, - }), - ); - - let rpc = JsonRpcClient::new(mock_transport); - let err = DeploymentManifest::load_from_remote(rpc, Felt::ONE).await.unwrap_err(); - - match err { - AbstractManifestError::RemoteWorldNotFound => { - // World not deployed. - } - err => panic!("Unexpected error: {err}"), - } -} - -#[test] -fn parse_registered_model_events() { - let expected_models = vec![ - Manifest::new( - DojoModel { - tag: get_tag("ns", "modelA"), - class_hash: felt!("0x5555"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns", "modelA")), - ), - Manifest::new( - DojoModel { - tag: get_tag("ns", "modelB"), - class_hash: felt!("0x6666"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns", "modelB")), - ), - ]; - - let events = vec![ - build_model_registered_event(vec![felt!("0x5555"), felt!("0xbeef")], "ns", "modelA"), - build_model_registered_event(vec![felt!("0x5555"), felt!("0xbeef")], "ns", "modelA"), - build_model_registered_event(vec![felt!("0x6666"), felt!("0xbaaf")], "ns", "modelB"), - ]; - - let actual_models = parse_models_events(events); - - assert_eq!(actual_models.len(), 2); - assert!(expected_models.contains(&actual_models[0])); - assert!(expected_models.contains(&actual_models[1])); -} - -#[test] -fn parse_deployed_contracts_events_without_upgrade() { - let expected_contracts = vec![ - Manifest::new( - DojoContract { - class_hash: felt!("0x1"), - address: Some(felt!("0x123")), - tag: get_tag("ns1", "c1"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns1", "c1")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x2"), - address: Some(felt!("0x456")), - tag: get_tag("ns2", "c2"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns2", "c2")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x3"), - address: Some(felt!("0x789")), - tag: get_tag("ns3", "c3"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns3", "c3")), - ), - ]; - - let events = vec![ - build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1", "c1"), - build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2", "c2"), - build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3", "c3"), - ]; - - let actual_contracts = parse_contracts_events(events, vec![], vec![]); - assert_eq!(actual_contracts, expected_contracts); -} - -#[test] -fn parse_deployed_contracts_events_with_upgrade() { - let expected_contracts = vec![ - Manifest::new( - DojoContract { - class_hash: felt!("0x69"), - address: Some(felt!("0x123")), - tag: get_tag("ns1", "c1"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns1", "c1")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x2"), - address: Some(felt!("0x456")), - tag: get_tag("ns2", "c2"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns2", "c2")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x88"), - address: Some(felt!("0x789")), - tag: get_tag("ns3", "c3"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns3", "c3")), - ), - ]; - - let deployed_events = vec![ - build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1", "c1"), - build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2", "c2"), - build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3", "c3"), - ]; - - let upgrade_events = vec![ - EmittedEvent { - data: vec![felt!("0x66"), felt!("0x123")], - keys: vec![], - block_number: Some(2), - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x69"), felt!("0x123")], - keys: vec![], - block_number: Some(9), - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x77"), felt!("0x123")], - keys: vec![], - block_number: Some(5), - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x88"), felt!("0x789")], - keys: vec![], - block_number: Some(5), - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - ]; - - let actual_contracts = parse_contracts_events(deployed_events, upgrade_events, vec![]); - similar_asserts::assert_eq!(actual_contracts, expected_contracts); -} - -#[test] -fn events_without_block_number_arent_parsed() { - let expected_contracts = vec![ - Manifest::new( - DojoContract { - class_hash: felt!("0x66"), - address: Some(felt!("0x123")), - tag: get_tag("ns1", "c1"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns1", "c1")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x2"), - address: Some(felt!("0x456")), - tag: get_tag("ns2", "c2"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns2", "c2")), - ), - Manifest::new( - DojoContract { - class_hash: felt!("0x3"), - address: Some(felt!("0x789")), - tag: get_tag("ns3", "c3"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("ns3", "c3")), - ), - ]; - - let deployed_events = vec![ - build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1", "c1"), - build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2", "c2"), - build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3", "c3"), - ]; - - // only the first upgrade event has a block number and is parsed - // meaning that the second and third upgrade events are ignored - // and are not evaluated when parsing the remote contracts - let upgrade_events = vec![ - EmittedEvent { - data: vec![felt!("0x66"), felt!("0x123")], - keys: vec![], - block_number: Some(2), - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x69"), felt!("0x123")], - keys: vec![], - block_number: None, - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x77"), felt!("0x123")], - keys: vec![], - block_number: None, - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x88"), felt!("0x789")], - keys: vec![], - block_number: None, - block_hash: Default::default(), - from_address: Default::default(), - transaction_hash: Default::default(), - }, - ]; - - let actual_contracts = parse_contracts_events(deployed_events, upgrade_events, vec![]); - similar_asserts::assert_eq!(actual_contracts, expected_contracts); -} - -#[katana_runner::test(db_dir = copy_spawn_and_move_db().as_str())] -fn fetch_remote_manifest(sequencer: &RunnerCtx) { - let account = sequencer.account(0); - let provider = account.provider(); - - let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); - let config = setup.build_test_config("spawn-and-move", Profile::DEV); - let profile_name = Profile::DEV.to_string(); - - let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_dir = Utf8PathBuf::from(ws.target_dir().to_string()).join("dev"); - let dojo_metadata = - dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); - - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path.clone(), - target_dir, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); - - let mut local_manifest = BaseManifest::load_from_path( - &manifest_path.join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), - ) - .unwrap(); - - if let Some(m) = dojo_metadata.migration { - local_manifest.remove_tags(&m.skip_contracts); - } - - let overlay_dir = manifest_path.join(OVERLAYS_DIR).join(&profile_name); - if overlay_dir.exists() { - let overlay_manifest = - OverlayManifest::load_from_path(&overlay_dir, &local_manifest).unwrap(); - - local_manifest.merge(overlay_manifest); - } - - let remote_manifest = config.tokio_handle().block_on(async { - DeploymentManifest::load_from_remote(provider, strat.world_address).await.unwrap() - }); - - assert_eq!(local_manifest.models.len(), 10); - assert_eq!(local_manifest.contracts.len(), 4); - - assert_eq!(remote_manifest.models.len(), 10); - assert_eq!(remote_manifest.contracts.len(), 4); - - // compute diff from local and remote manifest - - let diff = WorldDiff::compute(local_manifest, Some(remote_manifest), "dojo-test").unwrap(); - - assert_eq!(diff.count_diffs(), 0, "there should not be any diff"); -} - -#[test] -fn test_abi_format_to_embed() -> Result<(), Box> { - let temp_dir = tempfile::tempdir()?; - let temp_path = temp_dir.path().join("abi.json"); - let mut temp_file = std::fs::File::create(&temp_path)?; - - let temp_dir_utf8 = Utf8PathBuf::from_path_buf(temp_dir.path().into()).unwrap(); - - writeln!( - temp_file, - "[{{\"type\":\"function\",\"name\":\"testFunction\",\"inputs\":[],\"outputs\":[],\"\ - state_mutability\":\"view\"}}]" - )?; - - let abi_format_path = AbiFormat::Path(Utf8PathBuf::from_path_buf(temp_path).unwrap()); - let embedded_abi = abi_format_path.to_embed(&temp_dir_utf8)?; - - let abi_format_not_changed = embedded_abi.clone(); - - match &embedded_abi { - AbiFormat::Embed(abi_entries) => { - assert_eq!(abi_entries.len(), 1); - let entry_0 = &abi_entries[0]; - if let AbiEntry::Function(function) = entry_0 { - assert_eq!(function.name, "testFunction"); - } - } - _ => panic!("Expected AbiFormat::Embed variant"), - } - - assert_eq!(embedded_abi, abi_format_not_changed.to_embed(&temp_dir_utf8).unwrap()); - - Ok(()) -} - -#[test] -fn test_abi_format_to_path() { - let embedded = AbiFormat::Embed(vec![]); - assert!(embedded.to_path().is_none()); - - let path = AbiFormat::Path(Utf8PathBuf::from("/tmp")); - assert!(path.to_path().is_some()); -} - -#[test] -fn test_abi_format_load_abi_string() -> Result<(), Box> { - let temp_dir = tempfile::tempdir()?; - let temp_path = temp_dir.path().join("abi.json"); - let mut temp_file = std::fs::File::create(&temp_path)?; - - write!(temp_file, "[]")?; - - let path = AbiFormat::Path(Utf8PathBuf::from_path_buf(temp_path.clone()).unwrap()); - assert_eq!(path.load_abi_string(&Utf8PathBuf::new()).unwrap(), "[]"); - - let embedded = AbiFormat::Embed(vec![]); - assert_eq!(embedded.load_abi_string(&Utf8PathBuf::new()).unwrap(), "[]"); - - Ok(()) -} - -#[test] -fn overlay_merge_for_contract_and_model_work_as_expected() { - let other = OverlayManifest { - contracts: vec![ - OverlayDojoContract { tag: "ns:othercontract1".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:othercontract2".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:existingcontract".into(), ..Default::default() }, - ], - models: vec![ - OverlayDojoModel { tag: "ns:othermodel1".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:othermodel2".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:existingmodel".into(), ..Default::default() }, - ], - ..Default::default() - }; - - let mut current = OverlayManifest { - contracts: vec![ - OverlayDojoContract { tag: "ns:currentcontract1".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:currentcontract2".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:existingcontract".into(), ..Default::default() }, - ], - models: vec![ - OverlayDojoModel { tag: "ns:currentmodel1".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:currentmodel2".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:existingmodel".into(), ..Default::default() }, - ], - ..Default::default() - }; - - let expected = OverlayManifest { - contracts: vec![ - OverlayDojoContract { tag: "ns:currentcontract1".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:currentcontract2".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:existingcontract".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:othercontract1".into(), ..Default::default() }, - OverlayDojoContract { tag: "ns:othercontract2".into(), ..Default::default() }, - ], - models: vec![ - OverlayDojoModel { tag: "ns:currentmodel1".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:currentmodel2".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:existingmodel".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:othermodel1".into(), ..Default::default() }, - OverlayDojoModel { tag: "ns:othermodel2".into(), ..Default::default() }, - ], - ..Default::default() - }; - - current.merge(other); - - assert_eq!(current, expected); -} - -#[test] -fn overlay_merge_for_world_work_as_expected() { - // when other.world is none and current.world is some - let other = OverlayManifest { ..Default::default() }; - let mut current = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:world".to_string(), ..Default::default() }), - ..Default::default() - }; - let expected = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:world".to_string(), ..Default::default() }), - ..Default::default() - }; - current.merge(other); - - assert_eq!(current, expected); - - // when other.world is some and current.world is none - let other = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:world".to_string(), ..Default::default() }), - ..Default::default() - }; - let mut current = OverlayManifest { ..Default::default() }; - let expected = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:world".to_string(), ..Default::default() }), - ..Default::default() - }; - - current.merge(other); - assert_eq!(current, expected); - - // when other.world is some and current.world is some - let other = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:worldother".to_string(), ..Default::default() }), - ..Default::default() - }; - let mut current = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:worldcurrent".to_string(), ..Default::default() }), - ..Default::default() - }; - let expected = OverlayManifest { - world: Some(OverlayClass { tag: "dojo:worldcurrent".to_string(), ..Default::default() }), - ..Default::default() - }; - - current.merge(other); - assert_eq!(current, expected); - - // when other.world is none and current.world is none - let other = OverlayManifest { ..Default::default() }; - let mut current = OverlayManifest { ..Default::default() }; - let expected = OverlayManifest { ..Default::default() }; - - current.merge(other); - assert_eq!(current, expected); -} - -#[test] -fn overlay_merge_for_base_work_as_expected() { - // when other.base is none and current.base is some - let other = OverlayManifest { ..Default::default() }; - let mut current = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:base".to_string(), ..Default::default() }), - ..Default::default() - }; - let expected = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:base".to_string(), ..Default::default() }), - ..Default::default() - }; - current.merge(other); - - assert_eq!(current, expected); - - // when other.base is some and current.base is none - let other = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:base".to_string(), ..Default::default() }), - ..Default::default() - }; - let mut current = OverlayManifest { ..Default::default() }; - let expected = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:base".to_string(), ..Default::default() }), - ..Default::default() - }; - - current.merge(other); - assert_eq!(current, expected); - - // when other.base is some and current.base is some - let other = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:baseother".to_string(), ..Default::default() }), - ..Default::default() - }; - let mut current = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:basecurrent".to_string(), ..Default::default() }), - ..Default::default() - }; - let expected = OverlayManifest { - base: Some(OverlayClass { tag: "dojo:basecurrent".to_string(), ..Default::default() }), - ..Default::default() - }; - - current.merge(other); - assert_eq!(current, expected); - - // when other.base is none and current.base is none - let other = OverlayManifest { ..Default::default() }; - let mut current = OverlayManifest { ..Default::default() }; - let expected = OverlayManifest { ..Default::default() }; - - current.merge(other); - assert_eq!(current, expected); -} - -#[test] -fn base_manifest_remove_items_work_as_expected() { - let contracts = ["ns:c1", "ns:c2", "ns:c3"]; - let models = ["ns:m1", "ns:m2", "ns:m3"]; - - let world = Manifest { manifest_name: "world".into(), inner: Default::default() }; - let base = Manifest { manifest_name: "dojo-base".to_string(), inner: Default::default() }; - - let contracts = contracts - .iter() - .map(|c| Manifest { - manifest_name: c.to_string(), - inner: DojoContract { tag: c.to_string(), ..Default::default() }, - }) - .collect(); - let models = models - .iter() - .map(|c| Manifest { - manifest_name: c.to_string(), - inner: DojoModel { tag: c.to_string(), ..Default::default() }, - }) - .collect(); - - let mut base = BaseManifest { contracts, models, world, base }; - - base.remove_tags(&["ns:c1".to_string(), "ns:c3".to_string(), "ns:m2".to_string()]); - - assert_eq!(base.contracts.len(), 1); - assert_eq!( - base.contracts.iter().map(|c| c.manifest_name.clone()).collect::>(), - vec!["ns:c2"] - ); - - assert_eq!(base.models.len(), 2); - assert_eq!( - base.models.iter().map(|c| c.manifest_name.clone()).collect::>(), - vec!["ns:m1", "ns:m3"] - ); -} - -fn serialize_bytearray(s: &str) -> Vec { - let ba = ByteArray::from_string(s).unwrap(); - ByteArray::cairo_serialize(&ba) -} - -fn build_model_registered_event(values: Vec, namespace: &str, model: &str) -> EmittedEvent { - let mut data = ByteArray::cairo_serialize(&ByteArray::from_string(model).unwrap()); - data.extend(ByteArray::cairo_serialize(&ByteArray::from_string(namespace).unwrap())); - data.extend(values); - - EmittedEvent { - data, - keys: vec![selector!("ModelRegistered")], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - } -} - -fn build_deploy_event(values: Vec, ns: &str, name: &str) -> EmittedEvent { - let mut data = values.to_vec(); - data.extend(serialize_bytearray(ns).iter()); - data.extend(serialize_bytearray(name).iter()); - - EmittedEvent { - data, - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - } -} diff --git a/crates/dojo-world/src/manifest/mod.rs b/crates/dojo-world/src/manifest/mod.rs deleted file mode 100644 index 9f33421770..0000000000 --- a/crates/dojo-world/src/manifest/mod.rs +++ /dev/null @@ -1,902 +0,0 @@ -use std::collections::HashMap; -use std::path::PathBuf; -use std::{fs, io}; - -use anyhow::Result; -use cainome::cairo_serde::{ByteArray, CairoSerde, Error as CainomeError, Zeroable}; -use camino::Utf8PathBuf; -use serde::de::DeserializeOwned; -use serde::Serialize; -use starknet::core::types::{BlockId, BlockTag, EmittedEvent, EventFilter, Felt, StarknetError}; -use starknet::core::utils::{ - starknet_keccak, CairoShortStringToFeltError, ParseCairoShortStringError, -}; -use starknet::providers::{Provider, ProviderError}; -use thiserror::Error; -use toml; -use toml::Table; -use tracing::error; -use walkdir::WalkDir; - -use crate::contracts::model::ModelError; -use crate::contracts::world::WorldEvent; -use crate::contracts::{naming, WorldContractReader}; - -#[cfg(test)] -#[path = "manifest_test.rs"] -mod test; - -mod types; - -pub use types::{ - AbiFormat, BaseManifest, Class, DeploymentManifest, DojoContract, DojoModel, Manifest, - ManifestMethods, Member, OverlayClass, OverlayContract, OverlayDojoContract, OverlayDojoModel, - OverlayManifest, WorldContract, WorldMetadata, -}; - -pub const WORLD_CONTRACT_TAG: &str = "dojo-world"; -pub const BASE_CONTRACT_TAG: &str = "dojo-base"; - -pub const WORLD_QUALIFIED_PATH: &str = "dojo::world::world_contract::world"; -pub const BASE_QUALIFIED_PATH: &str = "dojo::contract::base_contract::base"; - -pub const MANIFESTS_DIR: &str = "manifests"; -pub const DEPLOYMENT_DIR: &str = "deployment"; -pub const TARGET_DIR: &str = "target"; -pub const BASE_DIR: &str = "base"; -pub const OVERLAYS_DIR: &str = "overlays"; -pub const ABIS_DIR: &str = "abis"; - -pub const CONTRACTS_DIR: &str = "contracts"; -pub const MODELS_DIR: &str = "models"; - -#[derive(Error, Debug)] -pub enum AbstractManifestError { - #[error("Remote World not found.")] - RemoteWorldNotFound, - #[error("Entry point name contains non-ASCII characters.")] - InvalidEntryPointError, - #[error(transparent)] - CairoShortStringToFelt(#[from] CairoShortStringToFeltError), - #[error(transparent)] - ParseCairoShortString(#[from] ParseCairoShortStringError), - #[error(transparent)] - Provider(#[from] ProviderError), - #[error(transparent)] - ContractRead(#[from] CainomeError), - #[error(transparent)] - Model(#[from] ModelError), - #[error(transparent)] - TomlDe(#[from] toml::de::Error), - #[error(transparent)] - TomlSer(#[from] toml::ser::Error), - #[error(transparent)] - IO(#[from] io::Error), - #[error("Abi couldn't be loaded from path: {0}")] - AbiError(String), - #[error(transparent)] - Json(#[from] serde_json::Error), - #[error("Duplicated manifest : {0}")] - DuplicatedManifest(String), - #[error("{0}")] - TagError(String), - #[error("{0}")] - UnknownTarget(String), -} - -impl From> for Manifest { - fn from(value: Manifest) -> Self { - Manifest::new( - WorldContract { - class_hash: value.inner.class_hash, - abi: value.inner.abi, - original_class_hash: value.inner.original_class_hash, - ..Default::default() - }, - value.manifest_name, - ) - } -} - -impl From for DeploymentManifest { - fn from(value: BaseManifest) -> Self { - DeploymentManifest { - world: value.world.into(), - base: value.base, - contracts: value.contracts, - models: value.models, - } - } -} - -impl BaseManifest { - /// Load the manifest from a file at the given path. - pub fn load_from_path(path: &Utf8PathBuf) -> Result { - let world: Manifest = toml::from_str(&fs::read_to_string( - path.join(naming::get_filename_from_tag(WORLD_CONTRACT_TAG)).with_extension("toml"), - )?)?; - - let base: Manifest = toml::from_str(&fs::read_to_string( - path.join(naming::get_filename_from_tag(BASE_CONTRACT_TAG)).with_extension("toml"), - )?)?; - - let contracts = elements_from_path::(&path.join(CONTRACTS_DIR))?; - let models = elements_from_path::(&path.join(MODELS_DIR))?; - - Ok(Self { world, base, contracts, models }) - } - - /// Given a list of contract or model tags, remove those from the manifest. - pub fn remove_tags(&mut self, tags: &[String]) { - self.contracts.retain(|contract| !tags.contains(&contract.inner.tag)); - self.models.retain(|model| !tags.contains(&model.inner.tag)); - } - - /// Generates a map of `tag -> ManifestKind` - pub fn build_kind_from_tags(&self) -> HashMap { - let mut kind_from_tags = HashMap::::new(); - - kind_from_tags.insert(WORLD_CONTRACT_TAG.to_string(), ManifestKind::WorldClass); - kind_from_tags.insert(BASE_CONTRACT_TAG.to_string(), ManifestKind::BaseClass); - - for model in self.models.as_slice() { - kind_from_tags.insert(model.inner.tag.clone(), ManifestKind::Model); - } - - for contract in self.contracts.as_slice() { - kind_from_tags.insert(contract.inner.tag.clone(), ManifestKind::Contract); - } - - kind_from_tags - } - - pub fn merge(&mut self, overlay: OverlayManifest) { - let mut base_map = HashMap::new(); - - for contract in self.contracts.iter_mut() { - base_map.insert(contract.inner.tag.clone(), contract); - } - - for contract in overlay.contracts { - if let Some(manifest) = base_map.get_mut(&contract.tag) { - manifest.inner.merge(contract); - } else { - error!( - "OverlayManifest configured for contract \"{}\", but contract is not present \ - in BaseManifest.", - contract.tag - ); - } - } - - if let Some(overlay_world) = overlay.world { - self.world.inner.merge(overlay_world); - } - if let Some(overlay_base) = overlay.base { - self.base.inner.merge(overlay_base); - } - } -} - -#[derive(Clone, Debug, Copy)] -pub enum ManifestKind { - BaseClass, - WorldClass, - Contract, - Model, -} - -impl OverlayManifest { - fn load_overlay( - path: &PathBuf, - kind: ManifestKind, - overlays: &mut OverlayManifest, - ) -> Result<(), AbstractManifestError> { - match kind { - ManifestKind::BaseClass => { - let overlay: OverlayClass = toml::from_str(&fs::read_to_string(path)?)?; - overlays.base = Some(overlay); - } - ManifestKind::WorldClass => { - let overlay: OverlayClass = toml::from_str(&fs::read_to_string(path)?)?; - overlays.world = Some(overlay); - } - ManifestKind::Model => { - let overlay: OverlayDojoModel = toml::from_str(&fs::read_to_string(path)?)?; - overlays.models.push(overlay); - } - ManifestKind::Contract => { - let overlay: OverlayDojoContract = toml::from_str(&fs::read_to_string(path)?)?; - overlays.contracts.push(overlay); - } - }; - - Ok(()) - } - - pub fn load_from_path( - path: &Utf8PathBuf, - base_manifest: &BaseManifest, - ) -> Result { - fs::create_dir_all(path)?; - - let kind_from_tags = base_manifest.build_kind_from_tags(); - let mut loaded_tags = HashMap::::new(); - let mut overlays = OverlayManifest::default(); - - for entry in WalkDir::new(path).into_iter() { - let entry = match entry { - Ok(e) => e, - Err(e) => return Err(AbstractManifestError::IO(e.into())), - }; - let file_path = entry.path(); - let file_name = entry.file_name().to_string_lossy().to_string(); - - if !file_name.clone().ends_with(".toml") { - continue; - } - - // an overlay file must contain a 'tag' key. - let toml_data = toml::from_str::
(&fs::read_to_string(file_path)?)?; - if !toml_data.contains_key("tag") { - return Err(AbstractManifestError::TagError(format!( - "The overlay '{file_name}' must contain the 'tag' key." - ))); - } - - // the tag key must be a string - let tag = match toml_data["tag"].as_str() { - Some(x) => x.to_string(), - None => { - return Err(AbstractManifestError::TagError(format!( - "The tag key of the overlay '{file_name}' must be a string." - ))); - } - }; - - // an overlay must target an existing class/model/contract - if !kind_from_tags.contains_key(&tag) { - return Err(AbstractManifestError::UnknownTarget(format!( - "The tag '{tag}' of the overlay '{file_name}' does not target an existing \ - class/model/contract." - ))); - } - - // a same tag cannot be used in multiple overlays. - if loaded_tags.contains_key(&tag) { - return Err(AbstractManifestError::DuplicatedManifest(format!( - "The tag '{tag}' is used in multiple overlays." - ))); - } - - Self::load_overlay(&file_path.to_path_buf(), kind_from_tags[&tag], &mut overlays)?; - loaded_tags.insert(tag, true); - } - - Ok(overlays) - } - - /// Writes `Self` to overlay manifests folder. - /// - /// - `world` and `base` manifest are written to root of the folder. - /// - `contracts` and `models` are written to their respective directories. - pub fn write_to_path(&self, path: &Utf8PathBuf) -> Result<(), AbstractManifestError> { - fs::create_dir_all(path)?; - - if let Some(ref world) = self.world { - let world = toml::to_string(world)?; - let file_name = - path.join(naming::get_filename_from_tag(WORLD_CONTRACT_TAG)).with_extension("toml"); - fs::write(file_name, world)?; - } - - if let Some(ref base) = self.base { - let base = toml::to_string(base)?; - let file_name = - path.join(naming::get_filename_from_tag(BASE_CONTRACT_TAG)).with_extension("toml"); - fs::write(file_name, base)?; - } - - overlay_to_path::(path, self.contracts.as_slice(), |c| c.tag.clone())?; - overlay_to_path::(path, self.models.as_slice(), |m| m.tag.clone())?; - Ok(()) - } - - /// Add missing overlay items from `others` to `self`. - /// Note that this method don't override if certain item already exists in `self`. - pub fn merge(&mut self, other: OverlayManifest) { - if self.world.is_none() { - self.world = other.world; - } - - if self.base.is_none() { - self.base = other.base; - } - - for other_contract in other.contracts { - let found = self.contracts.iter().find(|c| c.tag == other_contract.tag); - if found.is_none() { - self.contracts.push(other_contract); - } - } - - for other_model in other.models { - let found = self.models.iter().find(|m| m.tag == other_model.tag); - if found.is_none() { - self.models.push(other_model); - } - } - } -} - -impl DeploymentManifest { - pub fn load_from_path(path: &Utf8PathBuf) -> Result { - let manifest: Self = toml::from_str(&fs::read_to_string(path)?)?; - Ok(manifest) - } - - pub fn merge_from_previous(&mut self, previous: DeploymentManifest) { - self.world.inner.transaction_hash = previous.world.inner.transaction_hash; - self.world.inner.block_number = previous.world.inner.block_number; - self.world.inner.seed = previous.world.inner.seed; - - self.contracts.iter_mut().for_each(|contract| { - let previous_contract = - previous.contracts.iter().find(|c| c.manifest_name == contract.manifest_name); - if let Some(previous_contract) = previous_contract { - if previous_contract.inner.base_class_hash != Felt::ZERO { - contract.inner.base_class_hash = previous_contract.inner.base_class_hash; - } - } - }); - } - - pub fn write_to_path_toml(&self, path: &Utf8PathBuf) -> Result<()> { - fs::create_dir_all(path.parent().unwrap())?; - - let deployed_manifest = toml::to_string_pretty(&self)?; - fs::write(path, deployed_manifest)?; - - Ok(()) - } - - // Writes the Deployment manifest in JSON format, with ABIs embedded. - pub fn write_to_path_json(&self, path: &Utf8PathBuf, root_dir: &Utf8PathBuf) -> Result<()> { - fs::create_dir_all(path.parent().unwrap())?; - - // Embedding ABIs into the manifest. - let mut manifest_with_abis = self.clone(); - - if let Some(abi_format) = &manifest_with_abis.world.inner.abi { - manifest_with_abis.world.inner.abi = Some(abi_format.to_embed(root_dir)?); - } - - for contract in &mut manifest_with_abis.contracts { - if let Some(abi_format) = &contract.inner.abi { - contract.inner.abi = Some(abi_format.to_embed(root_dir)?); - } - } - - for model in &mut manifest_with_abis.models { - if let Some(abi_format) = &model.inner.abi { - model.inner.abi = Some(abi_format.to_embed(root_dir)?); - } - } - - let deployed_manifest = serde_json::to_string_pretty(&manifest_with_abis)?; - fs::write(path, deployed_manifest)?; - - Ok(()) - } - - /// Construct a manifest of a remote World. - /// - /// # Arguments - /// * `provider` - A Starknet RPC provider. - /// * `world_address` - The address of the remote World contract. - pub async fn load_from_remote

( - provider: P, - world_address: Felt, - ) -> Result - where - P: Provider + Send + Sync, - { - const BLOCK_ID: BlockId = BlockId::Tag(BlockTag::Pending); - - let world_class_hash = - provider.get_class_hash_at(BLOCK_ID, world_address).await.map_err(|err| match err { - ProviderError::StarknetError(StarknetError::ContractNotFound) => { - AbstractManifestError::RemoteWorldNotFound - } - err => err.into(), - })?; - - let world = WorldContractReader::new(world_address, provider); - - let base_class_hash = world.base().block_id(BLOCK_ID).call().await?; - let base_class_hash = base_class_hash.into(); - - let (models, contracts) = - get_remote_models_and_contracts(world_address, &world.provider()).await?; - - Ok(DeploymentManifest { - models, - contracts, - world: Manifest::new( - WorldContract { - address: Some(world_address), - class_hash: world_class_hash, - ..Default::default() - }, - naming::get_filename_from_tag(WORLD_CONTRACT_TAG), - ), - base: Manifest::new( - Class { - class_hash: base_class_hash, - abi: None, - original_class_hash: base_class_hash, - tag: BASE_CONTRACT_TAG.to_string(), - }, - naming::get_filename_from_tag(BASE_CONTRACT_TAG), - ), - }) - } -} - -// impl DeploymentMetadata { -// pub fn load_from_path(path: &Utf8PathBuf) -> Result { -// let manifest: Self = toml::from_str(&fs::read_to_string(path)?).unwrap(); - -// Ok(manifest) -// } - -// pub fn write_to_path_toml(&self, path: &Utf8PathBuf) -> Result<()> { -// fs::create_dir_all(path.parent().unwrap())?; - -// let deployed_manifest = toml::to_string_pretty(&self)?; -// fs::write(path, deployed_manifest)?; - -// Ok(()) -// } -// } - -// TODO: currently implementing this method using trait is causing lifetime issue due to -// `async_trait` macro which is hard to debug. So moved it as a async method on type itself. -// #[async_trait] -// pub trait RemoteLoadable { -// async fn load_from_remote( -// provider: P, -// world_address: FieldElement, -// ) -> Result; -// } - -// #[async_trait] -// impl RemoteLoadable

for DeploymentManifest {} - -async fn get_remote_models_and_contracts

( - world: Felt, - provider: P, -) -> Result<(Vec>, Vec>), AbstractManifestError> -where - P: Provider + Send + Sync, -{ - let registered_models_event_name = starknet_keccak("ModelRegistered".as_bytes()); - let contract_deployed_event_name = starknet_keccak("ContractDeployed".as_bytes()); - let contract_upgraded_event_name = starknet_keccak("ContractUpgraded".as_bytes()); - let writer_updated_event_name = starknet_keccak("WriterUpdated".as_bytes()); - - let events = get_events( - &provider, - world, - vec![vec![ - registered_models_event_name, - contract_deployed_event_name, - contract_upgraded_event_name, - writer_updated_event_name, - ]], - ) - .await?; - - let mut registered_models_events = vec![]; - let mut contract_deployed_events = vec![]; - let mut contract_upgraded_events = vec![]; - let mut writer_updated_events = vec![]; - - for event in events { - match event.keys.first() { - Some(event_name) if *event_name == registered_models_event_name => { - registered_models_events.push(event) - } - Some(event_name) if *event_name == contract_deployed_event_name => { - contract_deployed_events.push(event) - } - Some(event_name) if *event_name == contract_upgraded_event_name => { - contract_upgraded_events.push(event) - } - Some(event_name) if *event_name == writer_updated_event_name => { - writer_updated_events.push(event) - } - _ => {} - } - } - - let models = parse_models_events(registered_models_events); - let mut contracts = parse_contracts_events( - contract_deployed_events, - contract_upgraded_events, - writer_updated_events, - ); - - for contract in &mut contracts { - contract.manifest_name = naming::get_filename_from_tag(&contract.inner.tag); - } - - Ok((models, contracts)) -} - -async fn get_events( - provider: P, - world: Felt, - keys: Vec>, -) -> Result, ProviderError> { - const DEFAULT_CHUNK_SIZE: u64 = 100; - - let mut events: Vec = vec![]; - let mut continuation_token = None; - - let filter = - EventFilter { to_block: None, from_block: None, address: Some(world), keys: Some(keys) }; - - loop { - let res = - provider.get_events(filter.clone(), continuation_token, DEFAULT_CHUNK_SIZE).await?; - continuation_token = res.continuation_token; - - // stop when there are no more events being returned - if res.events.is_empty() { - break; - } else { - events.extend(res.events); - } - - if continuation_token.is_none() { - break; - } - } - - Ok(events) -} - -fn parse_contracts_events( - deployed: Vec, - upgraded: Vec, - granted: Vec, -) -> Vec> { - fn retain_only_latest_grant_events(events: Vec) -> HashMap> { - // create a map with some extra data which will be flattened later - // system -> (block_num, (resource -> perm)) - let mut grants: HashMap)> = HashMap::new(); - events.into_iter().for_each(|event| { - let mut data = event.data.into_iter(); - let block_num = event.block_number; - let resource = data.next().expect("resource is missing from event"); - let contract = data.next().expect("contract is missing from event"); - let value = data.next().expect("value is missing from event"); - - let value = !value.is_zero(); - - // Events that do not have a block number are ignored because we are unable to evaluate - // whether the events happened before or after the latest event that has been processed. - if let Some(num) = block_num { - grants - .entry(contract) - .and_modify(|(current_block, current_resource)| { - if *current_block <= num { - *current_block = num; - current_resource.insert(resource, value); - } - }) - .or_insert((num, HashMap::from([(resource, value)]))); - } - }); - - // flatten out the map to remove block_number information and only include resources that - // are true i.e. system -> [resources] - grants - .into_iter() - .map(|(contract, (_, resources))| { - ( - contract, - resources - .into_iter() - .filter_map(|(resource, bool)| if bool { Some(resource) } else { None }) - .collect(), - ) - }) - .collect() - } - - fn retain_only_latest_upgrade_events(events: Vec) -> HashMap { - // addr -> (block_num, class_hash) - let mut upgrades: HashMap = HashMap::new(); - - events.into_iter().for_each(|event| { - let mut data = event.data.into_iter(); - - let block_num = event.block_number; - let class_hash = data.next().expect("qed; missing class hash"); - let address = data.next().expect("qed; missing address"); - - // Events that do not have a block number are ignored because we are unable to evaluate - // whether the events happened before or after the latest event that has been processed. - if let Some(num) = block_num { - upgrades - .entry(address) - .and_modify(|(current_block, current_class_hash)| { - if *current_block <= num { - *current_block = num; - *current_class_hash = class_hash; - } - }) - .or_insert((num, class_hash)); - } - }); - - upgrades.into_iter().map(|(addr, (_, class_hash))| (addr, class_hash)).collect() - } - - let upgradeds = retain_only_latest_upgrade_events(upgraded); - let grants = retain_only_latest_grant_events(granted); - - deployed - .into_iter() - .map(|event| { - let mut data = event.data.into_iter(); - - let _ = data.next().expect("salt is missing from event"); - let mut class_hash = data.next().expect("class hash is missing from event"); - let address = data.next().expect("addresss is missing from event"); - - let str_data = data.as_slice(); - let namespace = - ByteArray::cairo_deserialize(str_data, 0).expect("namespace is missing from event"); - let offset = ByteArray::cairo_serialized_size(&namespace); - let name = - ByteArray::cairo_deserialize(str_data, offset).expect("name is missing from event"); - - let tag = naming::get_tag( - &namespace.to_string().expect("ASCII encoded namespace"), - &name.to_string().expect("ASCII encoded name"), - ); - - if let Some(upgrade) = upgradeds.get(&address) { - class_hash = *upgrade; - } - - let mut writes = vec![]; - if let Some(contract) = grants.get(&address) { - writes.extend(contract.iter().map(|f| f.to_hex_string())); - } - - Manifest::new( - DojoContract { - address: Some(address), - class_hash, - abi: None, - tag: tag.clone(), - writes, - ..Default::default() - }, - naming::get_filename_from_tag(&tag), - ) - }) - .collect() -} - -fn parse_models_events(events: Vec) -> Vec> { - let mut models: HashMap = HashMap::with_capacity(events.len()); - - for e in events { - let model_event = match e.try_into() { - Ok(WorldEvent::ModelRegistered(mr)) => mr, - Ok(_) => panic!("ModelRegistered expected as already filtered"), - Err(_) => { - // As models were registered with the new event type, we can - // skip old ones. We are sure at least 1 new event was emitted - // when models were migrated. - continue; - } - }; - - let model_name = model_event.name.to_string().expect("ASCII encoded name"); - let namespace = model_event.namespace.to_string().expect("ASCII encoded namespace"); - let model_tag = naming::get_tag(&namespace, &model_name); - - models.insert(model_tag, model_event.class_hash.into()); - } - - // TODO: include address of the model in the manifest. - models - .into_iter() - .map(|(tag, class_hash)| Manifest:: { - inner: DojoModel { tag: tag.clone(), class_hash, abi: None, ..Default::default() }, - manifest_name: naming::get_filename_from_tag(&tag), - }) - .collect() -} - -fn elements_from_path(path: &Utf8PathBuf) -> Result>, AbstractManifestError> -where - T: DeserializeOwned + ManifestMethods, -{ - let mut elements = vec![]; - - let mut entries = path - .read_dir()? - .map(|entry| entry.map(|e| e.path())) - .collect::, io::Error>>()?; - - // `read_dir` doesn't guarantee any order, so we sort the entries ourself. - // see: https://doc.rust-lang.org/std/fs/fn.read_dir.html#platform-specific-behavior - entries.sort(); - - for path in entries { - if path.is_file() { - let manifest: Manifest = toml::from_str(&fs::read_to_string(path)?)?; - elements.push(manifest); - } else { - continue; - } - } - - Ok(elements) -} - -fn overlay_to_path( - path: &Utf8PathBuf, - elements: &[T], - get_tag: fn(&T) -> String, -) -> Result<(), AbstractManifestError> -where - T: Serialize, -{ - fs::create_dir_all(path)?; - - for element in elements { - let filename = naming::get_filename_from_tag(&get_tag(element)); - let path = path.join(filename).with_extension("toml"); - fs::write(path, toml::to_string(element)?)?; - } - Ok(()) -} - -impl ManifestMethods for DojoContract { - type OverlayType = OverlayDojoContract; - - fn abi(&self) -> Option<&AbiFormat> { - self.abi.as_ref() - } - - fn set_abi(&mut self, abi: Option) { - self.abi = abi; - } - - fn class_hash(&self) -> &Felt { - self.class_hash.as_ref() - } - - fn set_class_hash(&mut self, class_hash: Felt) { - self.class_hash = class_hash; - } - - fn original_class_hash(&self) -> &Felt { - self.original_class_hash.as_ref() - } - - fn merge(&mut self, old: Self::OverlayType) { - // ignore name and namespace - - if let Some(class_hash) = old.original_class_hash { - self.original_class_hash = class_hash; - } - if let Some(reads) = old.reads { - self.reads = reads; - } - if let Some(writes) = old.writes { - self.writes = writes; - } - if let Some(init_calldata) = old.init_calldata { - self.init_calldata = init_calldata; - } - } -} - -impl ManifestMethods for DojoModel { - type OverlayType = OverlayDojoModel; - - fn abi(&self) -> Option<&AbiFormat> { - self.abi.as_ref() - } - - fn set_abi(&mut self, abi: Option) { - self.abi = abi; - } - - fn class_hash(&self) -> &Felt { - self.class_hash.as_ref() - } - - fn set_class_hash(&mut self, class_hash: Felt) { - self.class_hash = class_hash; - } - - fn original_class_hash(&self) -> &Felt { - self.original_class_hash.as_ref() - } - - fn merge(&mut self, old: Self::OverlayType) { - if let Some(class_hash) = old.original_class_hash { - self.original_class_hash = class_hash; - } - } -} - -impl ManifestMethods for WorldContract { - type OverlayType = OverlayContract; - - fn abi(&self) -> Option<&AbiFormat> { - self.abi.as_ref() - } - - fn set_abi(&mut self, abi: Option) { - self.abi = abi; - } - - fn class_hash(&self) -> &Felt { - self.class_hash.as_ref() - } - - fn set_class_hash(&mut self, class_hash: Felt) { - self.class_hash = class_hash; - } - - fn original_class_hash(&self) -> &Felt { - self.original_class_hash.as_ref() - } - - fn merge(&mut self, old: Self::OverlayType) { - if let Some(class_hash) = old.original_class_hash { - self.original_class_hash = class_hash; - } - } -} - -impl ManifestMethods for Class { - type OverlayType = OverlayClass; - - fn abi(&self) -> Option<&AbiFormat> { - self.abi.as_ref() - } - - fn set_abi(&mut self, abi: Option) { - self.abi = abi; - } - - fn class_hash(&self) -> &Felt { - self.class_hash.as_ref() - } - - fn set_class_hash(&mut self, class_hash: Felt) { - self.class_hash = class_hash; - } - - fn original_class_hash(&self) -> &Felt { - self.original_class_hash.as_ref() - } - - fn merge(&mut self, old: Self::OverlayType) { - if let Some(class_hash) = old.original_class_hash { - self.original_class_hash = class_hash; - } - } -} diff --git a/crates/dojo-world/src/manifest/types.rs b/crates/dojo-world/src/manifest/types.rs deleted file mode 100644 index 49f6b9163e..0000000000 --- a/crates/dojo-world/src/manifest/types.rs +++ /dev/null @@ -1,299 +0,0 @@ -use std::fs; - -use camino::Utf8PathBuf; -use serde::{Deserialize, Serialize}; -use serde_with::serde_as; -use smol_str::SmolStr; -use starknet::core::serde::unsigned_field_element::UfeHex; -use starknet::core::types::contract::AbiEntry; -use starknet::core::types::Felt; - -use crate::manifest::AbstractManifestError; - -// Collection of different types of `Manifest`'s which are used by dojo compiler/sozo -// For example: -// - `BaseManifest` is generated by the compiler and wrote to `manifests/base` folder of project -// - `DeploymentManifest` is generated by sozo which represents the future onchain state after a -// successful migration -// - `OverlayManifest` is used by sozo to override values of specific manifest of `BaseManifest` -// thats generated by compiler - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct BaseManifest { - pub world: Manifest, - pub base: Manifest, - pub contracts: Vec>, - pub models: Vec>, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct DeploymentManifest { - pub world: Manifest, - pub base: Manifest, - // NOTE: `writes` field in contracts is of String but we read the values which are resource - // hashes from the events, so needs to be handled accordingly - pub contracts: Vec>, - pub models: Vec>, -} - -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct OverlayManifest { - pub world: Option, - pub base: Option, - pub contracts: Vec, - pub models: Vec, -} - -#[derive(Clone, Serialize, Default, Deserialize, Debug)] -#[cfg_attr(test, derive(PartialEq))] -pub struct Manifest -where - T: ManifestMethods, -{ - #[serde(flatten)] - pub inner: T, - - // name of the manifest which is used as filename - pub manifest_name: String, -} - -// Utility methods thats needs to be implemented by manifest types -pub trait ManifestMethods { - type OverlayType; - fn abi(&self) -> Option<&AbiFormat>; - fn set_abi(&mut self, abi: Option); - fn class_hash(&self) -> &Felt; - fn set_class_hash(&mut self, class_hash: Felt); - fn original_class_hash(&self) -> &Felt; - - /// This method is called when during compilation base manifest file already exists. - /// Manifest generated during compilation won't contains properties manually updated by users - /// (like calldata) so this method should override those fields - fn merge(&mut self, old: Self::OverlayType); -} - -impl Manifest -where - T: ManifestMethods, -{ - pub fn new(inner: T, manifest_name: String) -> Self { - Self { inner, manifest_name } - } -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -#[serde(tag = "kind")] -pub struct DojoContract { - #[serde_as(as = "Option")] - pub address: Option, - #[serde_as(as = "UfeHex")] - pub class_hash: Felt, - #[serde_as(as = "UfeHex")] - pub original_class_hash: Felt, - // base class hash used to deploy the contract - #[serde_as(as = "UfeHex")] - pub base_class_hash: Felt, - pub abi: Option, - #[serde(default)] - pub reads: Vec, - #[serde(default)] - pub writes: Vec, - #[serde(default)] - pub init_calldata: Vec, - pub tag: String, - pub systems: Vec, -} - -/// Represents a declaration of a model. -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -#[serde(tag = "kind")] -pub struct DojoModel { - pub members: Vec, - #[serde_as(as = "UfeHex")] - pub class_hash: Felt, - #[serde_as(as = "UfeHex")] - pub original_class_hash: Felt, - pub abi: Option, - pub tag: String, - pub qualified_path: String, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -#[serde(tag = "kind")] -pub struct WorldContract { - #[serde_as(as = "UfeHex")] - pub class_hash: Felt, - #[serde_as(as = "UfeHex")] - pub original_class_hash: Felt, - pub abi: Option, - #[serde_as(as = "Option")] - pub address: Option, - #[serde_as(as = "Option")] - pub transaction_hash: Option, - pub block_number: Option, - pub seed: String, - pub metadata: Option, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -#[serde(tag = "kind")] -pub struct Class { - #[serde_as(as = "UfeHex")] - pub class_hash: Felt, - #[serde_as(as = "UfeHex")] - pub original_class_hash: Felt, - pub abi: Option, - pub tag: String, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct OverlayDojoContract { - pub tag: String, - pub original_class_hash: Option, - pub reads: Option>, - pub writes: Option>, - pub init_calldata: Option>, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct OverlayDojoModel { - pub tag: String, - pub original_class_hash: Option, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct OverlayContract { - pub name: SmolStr, - pub original_class_hash: Option, -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct OverlayClass { - pub tag: String, - pub original_class_hash: Option, -} - -// Types used by manifest - -/// Represents a model member. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct Member { - /// Name of the member. - pub name: String, - /// Type of the member. - #[serde(rename = "type")] - pub ty: String, - pub key: bool, -} - -impl From for Member { - fn from(m: dojo_types::schema::Member) -> Self { - Self { name: m.name, ty: m.ty.name(), key: m.key } - } -} - -/// System input ABI. -#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)] -pub struct Input { - pub name: String, - #[serde(rename = "type")] - pub ty: String, -} - -/// System Output ABI. -#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)] -pub struct Output { - #[serde(rename = "type")] - pub ty: String, -} - -/// Format of the ABI into the manifest. -#[serde_as] -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AbiFormat { - /// Only a relative path to the ABI file is stored. - Path(Utf8PathBuf), - /// The full ABI is embedded. - Embed(Vec), -} - -impl AbiFormat { - /// Get the [`Utf8PathBuf`] if the ABI is stored as a path. - pub fn to_path(&self) -> Option<&Utf8PathBuf> { - match self { - AbiFormat::Path(p) => Some(p), - AbiFormat::Embed(_) => None, - } - } - - /// Loads an ABI from the path or embedded entries. - /// - /// # Arguments - /// - /// * `root_dir` - The root directory of the ABI file. - pub fn load_abi_string(&self, root_dir: &Utf8PathBuf) -> Result { - match self { - AbiFormat::Path(abi_path) => Ok(fs::read_to_string(root_dir.join(abi_path))?), - AbiFormat::Embed(abi) => Ok(serde_json::to_string(&abi)?), - } - } - - /// Convert to embed variant. - /// - /// # Arguments - /// - /// * `root_dir` - The root directory for the abi file resolution. - pub fn to_embed(&self, root_dir: &Utf8PathBuf) -> Result { - if let AbiFormat::Path(abi_path) = self { - let mut abi_file = std::fs::File::open(root_dir.join(abi_path))?; - Ok(serde_json::from_reader(&mut abi_file)?) - } else { - Ok(self.clone()) - } - } -} - -#[cfg(test)] -impl PartialEq for AbiFormat { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (AbiFormat::Path(p1), AbiFormat::Path(p2)) => p1 == p2, - (AbiFormat::Embed(e1), AbiFormat::Embed(e2)) => { - // Currently, [`AbiEntry`] does not implement [`PartialEq`] so we cannot compare - // them directly. - let e1_json = serde_json::to_string(e1).expect("valid JSON from ABI"); - let e2_json = serde_json::to_string(e2).expect("valid JSON from ABI"); - e1_json == e2_json - } - _ => false, - } - } -} - -#[serde_as] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq))] -pub struct WorldMetadata { - pub profile_name: String, - pub rpc_url: String, -} diff --git a/crates/dojo-world/src/metadata.rs b/crates/dojo-world/src/metadata.rs deleted file mode 100644 index ad7459dcd3..0000000000 --- a/crates/dojo-world/src/metadata.rs +++ /dev/null @@ -1,374 +0,0 @@ -use std::collections::HashMap; -use std::io::Cursor; - -use anyhow::Result; -use camino::Utf8PathBuf; -use ipfs_api_backend_hyper::{IpfsApi, IpfsClient, TryFromUri}; -use scarb::core::{Package, TargetKind, Workspace}; -use serde::{Deserialize, Serialize}; -use serde_json::json; -use url::Url; - -use crate::config::{Environment, MigrationConfig, NamespaceConfig, ProfileConfig, WorldConfig}; -use crate::contracts::naming; -use crate::manifest::{BaseManifest, CONTRACTS_DIR, MODELS_DIR, WORLD_CONTRACT_TAG}; -use crate::uri::Uri; - -const LOG_TARGET: &str = "dojo_world::metadata"; - -#[cfg(test)] -#[path = "metadata_test.rs"] -mod test; - -pub const IPFS_CLIENT_URL: &str = "https://ipfs.infura.io:5001"; -pub const IPFS_USERNAME: &str = "2EBrzr7ZASQZKH32sl2xWauXPSA"; -pub const IPFS_PASSWORD: &str = "12290b883db9138a8ae3363b6739d220"; - -// copy constants from dojo-lang to avoid circular dependency -pub const MANIFESTS_DIR: &str = "manifests"; -pub const ABIS_DIR: &str = "abis"; -pub const BASE_DIR: &str = "base"; - -/// Get the default namespace from the workspace. -/// -/// # Arguments -/// -/// * `ws`: the workspace. -/// -/// # Returns -/// -/// A [`String`] object containing the namespace. -pub fn get_default_namespace_from_ws(ws: &Workspace<'_>) -> Result { - let metadata = dojo_metadata_from_workspace(ws)?; - Ok(metadata.namespace.default) -} - -/// Get the namespace configuration from the workspace. -/// -/// # Arguments -/// -/// * `ws`: the workspace. -/// -/// # Returns -/// -/// A [`NamespaceConfig`] object containing the namespace configuration. -pub fn get_namespace_config_from_ws(ws: &Workspace<'_>) -> Result { - let metadata = dojo_metadata_from_workspace(ws)?; - Ok(metadata.namespace) -} - -/// Loads the Dojo metadata for the given package, where the `profile.toml` file is expected to be -/// located in the package directory, next to the `Scarb.toml` file. -pub fn dojo_metadata_from_package(package: &Package, ws: &Workspace<'_>) -> Result { - tracing::debug!(target: LOG_TARGET, package_id = package.id.to_string(), "Collecting Dojo metadata from package."); - - // If it's a lib, we can try to extract dojo data. If failed -> then we can return default. - // But like so, if some metadata are here, we get them. - // [[target.dojo]] shouldn't be used with [lib] as no files will be deployed. - let is_lib = package.target(&TargetKind::new("lib")).is_some(); - let is_dojo = package.target(&TargetKind::new("dojo")).is_some(); - - if is_lib && is_dojo { - return Err(anyhow::anyhow!("[lib] package cannot have [[target.dojo]].")); - } - - // If not dojo dependent, we should skip metadata gathering. - if !package.manifest.summary.dependencies.iter().any(|dep| dep.name.as_str() == "dojo") { - // Some tests (like dojo-core) may depend on dojo, but there is no dojo dependency in the - // manifest. In case the profile config file exists, we extract the default - // namespace from it. - if let Ok(profile_config) = ProfileConfig::new( - &Utf8PathBuf::from(package.manifest_path().parent().unwrap()), - ws.current_profile()?, - ) { - let metadata = - DojoMetadata { namespace: profile_config.namespace, ..Default::default() }; - - return Ok(metadata); - } else { - tracing::trace!(target: LOG_TARGET, package = ?package.manifest_path(), "No dojo dependency or profile config file found, skipping metadata collection."); - return Ok(DojoMetadata::default()); - } - } - - let profile_config = ProfileConfig::new( - &Utf8PathBuf::from(package.manifest_path().parent().unwrap()), - ws.current_profile()?, - )?; - - let mut dojo_metadata = DojoMetadata { - world: WorldMetadata::from(profile_config.world), - namespace: profile_config.namespace.clone(), - env: profile_config.env.clone(), - migration: profile_config.migration.clone(), - resources_artifacts: HashMap::new(), - }; - - metadata_artifacts_load(&mut dojo_metadata, ws)?; - - tracing::trace!(target: LOG_TARGET, ?dojo_metadata); - - Ok(dojo_metadata) -} - -/// Loads the Dojo metadata from the workspace, where one [[target.dojo]] package is required. -pub fn dojo_metadata_from_workspace(ws: &Workspace<'_>) -> Result { - let dojo_packages: Vec = ws - .members() - .filter(|package| { - package.target(&TargetKind::new("dojo")).is_some() - && package.target(&TargetKind::new("lib")).is_none() - }) - .collect(); - - match dojo_packages.len() { - 0 => { - ws.config().ui().warn("No package with [[target.dojo]] found in workspace."); - Ok(DojoMetadata::default()) - } - 1 => { - let dojo_package = - dojo_packages.into_iter().next().expect("Package must exist as len is 1."); - Ok(dojo_metadata_from_package(&dojo_package, ws)?) - } - _ => Err(anyhow::anyhow!( - "Multiple packages with dojo target found in workspace. Please specify a package \ - using --package option or maybe one of them must be declared as a [lib]." - )), - } -} - -/// Loads the artifacts metadata for the world. -fn metadata_artifacts_load(dojo_metadata: &mut DojoMetadata, ws: &Workspace<'_>) -> Result<()> { - let profile = ws.config().profile(); - - // Use package.manifest_path() if supported by the compiler. - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - let manifest_dir = manifest_dir.join(MANIFESTS_DIR).join(profile.as_str()); - let abi_dir = manifest_dir.join(BASE_DIR).join(ABIS_DIR); - let source_dir = ws.target_dir().path_existent().unwrap(); - let source_dir = source_dir.join(profile.as_str()); - - let world_artifact = build_artifact_from_filename( - &abi_dir, - &source_dir, - &naming::get_filename_from_tag(WORLD_CONTRACT_TAG), - ); - - dojo_metadata.world.artifacts = world_artifact; - - // load models and contracts metadata - if manifest_dir.join(BASE_DIR).exists() { - if let Ok(manifest) = BaseManifest::load_from_path(&manifest_dir.join(BASE_DIR)) { - for model in manifest.models { - let tag = model.inner.tag.clone(); - let abi_model_dir = abi_dir.join(MODELS_DIR); - let source_model_dir = source_dir.join(MODELS_DIR); - dojo_metadata.resources_artifacts.insert( - tag.clone(), - ResourceMetadata { - name: tag.clone(), - artifacts: build_artifact_from_filename( - &abi_model_dir, - &source_model_dir, - &naming::get_filename_from_tag(&tag), - ), - }, - ); - } - - for contract in manifest.contracts { - let tag = contract.inner.tag.clone(); - let abi_contract_dir = abi_dir.join(CONTRACTS_DIR); - let source_contract_dir = source_dir.join(CONTRACTS_DIR); - dojo_metadata.resources_artifacts.insert( - tag.clone(), - ResourceMetadata { - name: tag.clone(), - artifacts: build_artifact_from_filename( - &abi_contract_dir, - &source_contract_dir, - &naming::get_filename_from_tag(&tag), - ), - }, - ); - } - } - } - - Ok(()) -} - -fn build_artifact_from_filename( - abi_dir: &Utf8PathBuf, - source_dir: &Utf8PathBuf, - filename: &str, -) -> ArtifactMetadata { - let abi_file = abi_dir.join(format!("{filename}.json")); - let src_file = source_dir.join(format!("{filename}.cairo")); - - ArtifactMetadata { - abi: if abi_file.exists() { Some(Uri::File(abi_file.into_std_path_buf())) } else { None }, - source: if src_file.exists() { - Some(Uri::File(src_file.into_std_path_buf())) - } else { - None - }, - } -} - -/// Metadata for a user defined resource (models, contracts). -#[derive(Default, Serialize, Deserialize, Debug, Clone)] -pub struct ResourceMetadata { - pub name: String, - pub artifacts: ArtifactMetadata, -} - -/// Metadata collected from the project configuration and the Dojo workspace -#[derive(Default, Deserialize, Debug, Clone)] -pub struct DojoMetadata { - pub world: WorldMetadata, - pub resources_artifacts: HashMap, - pub namespace: NamespaceConfig, - pub env: Option, - pub migration: Option, -} - -/// Metadata Artifacts collected for one Dojo element (world, model, contract...) -#[derive(Default, Serialize, Deserialize, Debug, Clone)] -pub struct ArtifactMetadata { - pub abi: Option, - pub source: Option, -} - -/// World metadata collected from the project configuration and the Dojo workspace -#[derive(Default, Serialize, Deserialize, Debug, Clone)] -pub struct WorldMetadata { - pub name: String, - pub seed: String, - pub description: Option, - pub cover_uri: Option, - pub icon_uri: Option, - pub website: Option, - pub socials: Option>, - pub artifacts: ArtifactMetadata, -} - -impl From for WorldMetadata { - fn from(config: WorldConfig) -> Self { - WorldMetadata { - name: config.name, - seed: config.seed, - description: config.description, - cover_uri: config.cover_uri, - icon_uri: config.icon_uri, - website: config.website, - socials: config.socials, - ..Default::default() - } - } -} - -impl WorldMetadata { - pub async fn upload(&self) -> Result { - let mut meta = self.clone(); - let client = - IpfsClient::from_str(IPFS_CLIENT_URL)?.with_credentials(IPFS_USERNAME, IPFS_PASSWORD); - - if let Some(Uri::File(icon)) = &self.icon_uri { - let icon_data = std::fs::read(icon)?; - let reader = Cursor::new(icon_data); - let response = client.add(reader).await?; - meta.icon_uri = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - if let Some(Uri::File(cover)) = &self.cover_uri { - let cover_data = std::fs::read(cover)?; - let reader = Cursor::new(cover_data); - let response = client.add(reader).await?; - meta.cover_uri = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - if let Some(Uri::File(abi)) = &self.artifacts.abi { - let abi_data = std::fs::read(abi)?; - let reader = Cursor::new(abi_data); - let response = client.add(reader).await?; - meta.artifacts.abi = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - if let Some(Uri::File(source)) = &self.artifacts.source { - let source_data = std::fs::read(source)?; - let reader = Cursor::new(source_data); - let response = client.add(reader).await?; - meta.artifacts.source = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - let serialized = json!(meta).to_string(); - let reader = Cursor::new(serialized); - let response = client.add(reader).await?; - - Ok(response.hash) - } -} - -impl ArtifactMetadata { - pub async fn upload(&self) -> Result { - let mut meta = self.clone(); - let client = - IpfsClient::from_str(IPFS_CLIENT_URL)?.with_credentials(IPFS_USERNAME, IPFS_PASSWORD); - - if let Some(Uri::File(abi)) = &self.abi { - let abi_data = std::fs::read(abi)?; - let reader = Cursor::new(abi_data); - let response = client.add(reader).await?; - meta.abi = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - if let Some(Uri::File(source)) = &self.source { - let source_data = std::fs::read(source)?; - let reader = Cursor::new(source_data); - let response = client.add(reader).await?; - meta.source = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - let serialized = json!(meta).to_string(); - let reader = Cursor::new(serialized); - let response = client.add(reader).await?; - - Ok(response.hash) - } -} - -impl ResourceMetadata { - pub async fn upload(&self) -> Result { - let mut meta = self.clone(); - let client = - IpfsClient::from_str(IPFS_CLIENT_URL)?.with_credentials(IPFS_USERNAME, IPFS_PASSWORD); - - if let Some(Uri::File(abi)) = &self.artifacts.abi { - let abi_data = std::fs::read(abi)?; - let reader = Cursor::new(abi_data); - let response = client.add(reader).await?; - meta.artifacts.abi = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - if let Some(Uri::File(source)) = &self.artifacts.source { - let source_data = std::fs::read(source)?; - let reader = Cursor::new(source_data); - let response = client.add(reader).await?; - meta.artifacts.source = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) - }; - - let serialized = json!(meta).to_string(); - let reader = Cursor::new(serialized); - let response = client.add(reader).await?; - - Ok(response.hash) - } -} - -impl DojoMetadata { - pub fn env(&self) -> Option<&Environment> { - self.env.as_ref() - } -} diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs deleted file mode 100644 index 46d9fb7851..0000000000 --- a/crates/dojo-world/src/metadata_test.rs +++ /dev/null @@ -1,166 +0,0 @@ -use std::collections::HashMap; -use std::fs; - -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; -use scarb::compiler::Profile; -use scarb::ops; -use url::Url; - -use crate::contracts::naming::{get_filename_from_tag, TAG_SEPARATOR}; -use crate::manifest::{CONTRACTS_DIR, MODELS_DIR, WORLD_CONTRACT_TAG}; -use crate::metadata::{ - dojo_metadata_from_workspace, ArtifactMetadata, Uri, WorldMetadata, ABIS_DIR, BASE_DIR, - MANIFESTS_DIR, -}; - -#[tokio::test] -async fn world_metadata_hash_and_upload() { - let meta = WorldMetadata { - name: "Test World".to_string(), - seed: String::from("dojo_examples"), - description: Some("A world used for testing".to_string()), - cover_uri: Some(Uri::File("src/metadata_test_data/cover.png".into())), - icon_uri: Some(Uri::File("src/metadata_test_data/cover.png".into())), - website: Some(Url::parse("https://dojoengine.org").unwrap()), - socials: Some(HashMap::from([("x".to_string(), "https://x.com/dojostarknet".to_string())])), - artifacts: ArtifactMetadata { - abi: Some(Uri::File("src/metadata_test_data/abi.json".into())), - source: Some(Uri::File("src/metadata_test_data/source.cairo".into())), - }, - }; - - let _ = meta.upload().await.unwrap(); -} - -#[tokio::test] -async fn get_full_dojo_metadata_from_workspace() { - let config = - compiler::build_test_config("../../examples/spawn-and-move/Scarb.toml", Profile::DEV) - .unwrap(); - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - - let profile = ws.config().profile(); - let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - let manifest_dir = manifest_dir.join(MANIFESTS_DIR).join(profile.as_str()); - let target_dir = ws.target_dir().path_existent().unwrap(); - let target_dir = target_dir.join(profile.as_str()); - let abis_dir = manifest_dir.join(BASE_DIR).join(ABIS_DIR); - - let dojo_metadata = - dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); - - // env - assert!(dojo_metadata.env.is_some()); - let env = dojo_metadata.env.unwrap(); - - assert!(env.rpc_url.is_some()); - assert!(env.rpc_url.unwrap().eq("http://localhost:5050/")); - - assert!(env.account_address.is_some()); - assert!( - env.account_address - .unwrap() - .eq("0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba") - ); - - assert!(env.private_key.is_some()); - assert!( - env.private_key.unwrap().eq("0x1800000000300000180000000000030000000000003006001800006600") - ); - - assert!(env.world_address.is_some()); - - assert!(env.keystore_path.is_none()); - assert!(env.keystore_password.is_none()); - - // world - assert_eq!(dojo_metadata.world.name, "example"); - - assert!(dojo_metadata.world.description.is_some()); - assert!(dojo_metadata.world.description.unwrap().eq("example world")); - - assert!(dojo_metadata.world.cover_uri.is_none()); - assert!(dojo_metadata.world.icon_uri.is_none()); - assert!(dojo_metadata.world.website.is_none()); - assert!(dojo_metadata.world.socials.is_none()); - - let world_filename = get_filename_from_tag(WORLD_CONTRACT_TAG); - assert!(dojo_metadata.world.artifacts.abi.is_some(), "No abi for {world_filename}"); - let abi = dojo_metadata.world.artifacts.abi.unwrap(); - assert_eq!( - abi, - Uri::File(abis_dir.join(format!("{world_filename}.json")).into()), - "Bad abi for {world_filename}", - ); - - let artifacts = get_artifacts_from_manifest(&manifest_dir); - - for (subdir, filename) in artifacts { - let tag = get_tag_from_filename(&filename); - let resource = dojo_metadata.resources_artifacts.get(&tag); - - assert!(resource.is_some(), "bad resource metadata for {}", tag); - let resource = resource.unwrap(); - - check_artifact( - resource.artifacts.clone(), - filename, - &abis_dir.join(subdir), - &target_dir.join(subdir), - ); - } -} - -fn check_artifact( - artifact: ArtifactMetadata, - basename: String, - abis_dir: &Utf8PathBuf, - source_dir: &Utf8PathBuf, -) { - assert!(artifact.abi.is_some(), "No abi for {}", basename); - let abi = artifact.abi.unwrap(); - assert_eq!( - abi, - Uri::File(abis_dir.join(format!("{basename}.json")).into()), - "Bad abi for {}", - basename - ); - - assert!(artifact.source.is_some(), "No source for {}", basename); - let source = artifact.source.unwrap(); - assert_eq!( - source, - Uri::File(source_dir.join(format!("{basename}.cairo")).into()), - "Bad source for {}", - basename - ); -} - -fn get_artifacts_from_manifest(manifest_dir: &Utf8PathBuf) -> Vec<(&str, String)> { - let contracts_dir = manifest_dir.join(BASE_DIR).join(CONTRACTS_DIR); - let models_dir = manifest_dir.join(BASE_DIR).join(MODELS_DIR); - - let mut artifacts = vec![]; - - // models - for entry in fs::read_dir(models_dir).unwrap().flatten() { - let filename = entry.path().file_stem().unwrap().to_string_lossy().to_string(); - artifacts.push((MODELS_DIR, filename)); - } - - // contracts - for entry in fs::read_dir(contracts_dir).unwrap().flatten() { - let filename = entry.path().file_stem().unwrap().to_string_lossy().to_string(); - artifacts.push((CONTRACTS_DIR, filename)); - } - - artifacts -} - -fn get_tag_from_filename(filename: &str) -> String { - let parts = filename.split(TAG_SEPARATOR).collect::>(); - assert!(parts.len() >= 2); - format!("{}{TAG_SEPARATOR}{}", parts[0], parts[1]) -} diff --git a/crates/dojo-world/src/migration/class.rs b/crates/dojo-world/src/migration/class.rs deleted file mode 100644 index d49561a2d2..0000000000 --- a/crates/dojo-world/src/migration/class.rs +++ /dev/null @@ -1,66 +0,0 @@ -use std::fmt::Display; -use std::path::PathBuf; - -use async_trait::async_trait; -use starknet::core::types::Felt; - -use super::{Declarable, MigrationType, StateDiff}; - -/// Represents differences between a local and remote class. -#[derive(Debug, Default, Clone)] -pub struct ClassDiff { - // The tag is used to identify the corresponding artifact produced by the compiler. - pub tag: String, - pub local_class_hash: Felt, - pub original_class_hash: Felt, - pub remote_class_hash: Option, -} - -impl StateDiff for ClassDiff { - fn is_same(&self) -> bool { - if let Some(remote) = self.remote_class_hash { - self.local_class_hash == remote - } else { - false - } - } -} - -impl Display for ClassDiff { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "{}:", self.tag)?; - writeln!(f, " Local: {:#x}", self.local_class_hash)?; - - if let Some(remote) = self.remote_class_hash { - writeln!(f, " Remote: {remote:#x}")?; - } - - Ok(()) - } -} - -#[derive(Debug, Default, Clone)] -pub struct ClassMigration { - pub diff: ClassDiff, - pub artifact_path: PathBuf, -} - -impl ClassMigration { - pub fn migration_type(&self) -> MigrationType { - let Some(remote) = self.diff.remote_class_hash else { - return MigrationType::New; - }; - - match self.diff.local_class_hash == remote { - true => MigrationType::New, - false => MigrationType::Update, - } - } -} - -#[async_trait] -impl Declarable for ClassMigration { - fn artifact_path(&self) -> &PathBuf { - &self.artifact_path - } -} diff --git a/crates/dojo-world/src/migration/contract.rs b/crates/dojo-world/src/migration/contract.rs deleted file mode 100644 index 7cbc78eba5..0000000000 --- a/crates/dojo-world/src/migration/contract.rs +++ /dev/null @@ -1,87 +0,0 @@ -use std::fmt::Display; -use std::path::PathBuf; - -use async_trait::async_trait; -use starknet::core::types::{DeclareTransactionResult, Felt}; - -use super::{Declarable, Deployable, MigrationType, StateDiff, Upgradable}; - -pub type DeclareOutput = DeclareTransactionResult; - -/// Represents differences between a local and remote contract. -#[derive(Debug, Default, Clone)] -pub struct ContractDiff { - // The tag is used to identify the corresponding artifact produced by the compiler. - pub tag: String, - pub local_class_hash: Felt, - pub original_class_hash: Felt, - pub base_class_hash: Felt, - pub remote_class_hash: Option, - pub init_calldata: Vec, - pub local_writes: Vec, - pub remote_writes: Vec, -} - -impl StateDiff for ContractDiff { - fn is_same(&self) -> bool { - if let Some(remote) = self.remote_class_hash { - self.local_class_hash == remote - } else { - false - } - } -} - -impl Display for ContractDiff { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "{}:", self.tag)?; - writeln!(f, " Local Class Hash: {:#x}", self.local_class_hash)?; - writeln!(f, " Original Class Hash: {:#x}", self.original_class_hash)?; - writeln!(f, " Base Class Hash: {:#x}", self.base_class_hash)?; - - if let Some(remote) = self.remote_class_hash { - writeln!(f, " Remote Class Hash: {remote:#x}")?; - } - - Ok(()) - } -} - -// Represents a contract that needs to be migrated to the remote state -#[derive(Debug, Default, Clone)] -pub struct ContractMigration { - pub salt: Felt, - pub diff: ContractDiff, - pub artifact_path: PathBuf, - pub contract_address: Felt, -} - -impl ContractMigration { - pub fn migration_type(&self) -> MigrationType { - let Some(remote) = self.diff.remote_class_hash else { - return MigrationType::New; - }; - - match self.diff.local_class_hash == remote { - true => MigrationType::New, - false => MigrationType::Update, - } - } -} - -#[async_trait] -impl Declarable for ContractMigration { - fn artifact_path(&self) -> &PathBuf { - &self.artifact_path - } -} - -#[async_trait] -impl Deployable for ContractMigration { - fn salt(&self) -> Felt { - self.salt - } -} - -#[async_trait] -impl Upgradable for ContractMigration {} diff --git a/crates/dojo-world/src/migration/mod.rs b/crates/dojo-world/src/migration/mod.rs deleted file mode 100644 index 1c3396a022..0000000000 --- a/crates/dojo-world/src/migration/mod.rs +++ /dev/null @@ -1,415 +0,0 @@ -use std::fs::File; -use std::path::PathBuf; -use std::sync::Arc; - -use anyhow::{anyhow, Result}; -use async_trait::async_trait; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use cairo_lang_starknet_classes::contract_class::ContractClass; -use dojo_utils::{TransactionExt, TransactionWaiter, TransactionWaitingError, TxnConfig}; -use starknet::accounts::{Account, AccountError, ConnectedAccount}; -use starknet::core::types::contract::{CompiledClass, SierraClass}; -use starknet::core::types::{ - BlockId, BlockTag, Call, DeclareTransactionResult, Felt, FlattenedSierraClass, - InvokeTransactionResult, ReceiptBlock, StarknetError, TransactionReceiptWithBlockInfo, -}; -use starknet::core::utils::{get_contract_address, CairoShortStringToFeltError}; -use starknet::macros::{felt, selector}; -use starknet::providers::{Provider, ProviderError}; -use thiserror::Error; - -use crate::contracts::naming::compute_selector_from_tag; - -pub mod class; -pub mod contract; -pub mod strategy; -pub mod world; - -pub type DeclareOutput = DeclareTransactionResult; - -#[derive(Clone, Debug)] -pub struct DeployOutput { - pub transaction_hash: Felt, - pub block_number: Option, - pub contract_address: Felt, - pub declare: Option, - // base class hash at time of deployment - pub base_class_hash: Felt, - pub was_upgraded: bool, - pub tag: Option, -} - -#[derive(Clone, Debug)] -pub struct UpgradeOutput { - pub transaction_hash: Felt, - pub block_number: Option, - pub contract_address: Felt, - pub declare: Option, -} - -#[derive(Debug)] -pub struct RegisterOutput { - pub transaction_hash: Felt, - pub declare_output: Vec, - pub registered_models: Vec, -} - -#[derive(Debug, Error)] -pub enum MigrationError { - #[error("Compiling contract.")] - CompilingContract, - #[error("Class already declared.")] - ClassAlreadyDeclared, - #[error("Contract already deployed.")] - ContractAlreadyDeployed(Felt), - #[error(transparent)] - Migrator(#[from] AccountError), - #[error(transparent)] - CairoShortStringToFelt(#[from] CairoShortStringToFeltError), - #[error(transparent)] - Provider(#[from] ProviderError), - #[error(transparent)] - WaitingError(#[from] TransactionWaitingError), - #[error(transparent)] - ArtifactError(#[from] anyhow::Error), - #[error("Bad init calldata.")] - BadInitCalldata, -} - -/// Represents the type of migration that should be performed. -#[derive(Debug)] -pub enum MigrationType { - /// When the remote class/contract already exists and has - /// to be updated to match the local state. - Update, - /// When the class/contract does not exist on the remote state or - /// when a new World is to be deployed. - New, -} - -pub trait StateDiff { - /// Returns `true` if the local and remote states are equivalent. - fn is_same(&self) -> bool; -} - -#[cfg_attr(not(target_arch = "wasm32"), async_trait)] -#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -pub trait Declarable { - async fn declare( - &self, - account: A, - txn_config: &TxnConfig, - ) -> Result::SignError>> - where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, - { - let (flattened_class, casm_class_hash) = - prepare_contract_declaration_params(self.artifact_path())?; - - match account - .provider() - .get_class(BlockId::Tag(BlockTag::Pending), flattened_class.class_hash()) - .await - { - Err(ProviderError::StarknetError(StarknetError::ClassHashNotFound)) => {} - Ok(_) => return Err(MigrationError::ClassAlreadyDeclared), - Err(e) => return Err(MigrationError::Provider(e)), - } - - let DeclareTransactionResult { transaction_hash, class_hash } = account - .declare_v2(Arc::new(flattened_class), casm_class_hash) - .send_with_cfg(txn_config) - .await - .map_err(MigrationError::Migrator)?; - - TransactionWaiter::new(transaction_hash, account.provider()) - .await - .map_err(MigrationError::WaitingError)?; - - return Ok(DeclareOutput { transaction_hash, class_hash }); - } - - fn artifact_path(&self) -> &PathBuf; -} - -#[cfg_attr(not(target_arch = "wasm32"), async_trait)] -#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -pub trait Deployable: Declarable + Sync { - #[allow(clippy::too_many_arguments)] - async fn deploy_dojo_contract_call( - &self, - world_address: Felt, - class_hash: Felt, - base_class_hash: Felt, - account: A, - tag: &str, - ) -> Result<(Call, Felt, bool), MigrationError<::SignError>> - where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, - { - let contract_address = - get_contract_address(self.salt(), base_class_hash, &[], world_address); - - let mut was_upgraded = false; - - let call = match account - .provider() - .get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address) - .await - { - Ok(current_class_hash) if current_class_hash != class_hash => { - was_upgraded = true; - - let contract_selector = compute_selector_from_tag(tag); - - Call { - calldata: vec![contract_selector, class_hash], - selector: selector!("upgrade_contract"), - to: world_address, - } - } - - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { - let calldata = vec![self.salt(), class_hash]; - Call { calldata, selector: selector!("deploy_contract"), to: world_address } - } - - Ok(_) => { - return Err(MigrationError::ContractAlreadyDeployed(contract_address)); - } - - Err(e) => return Err(MigrationError::Provider(e)), - }; - - Ok((call, contract_address, was_upgraded)) - } - - #[allow(clippy::too_many_arguments)] - async fn deploy_dojo_contract( - &self, - world_address: Felt, - class_hash: Felt, - base_class_hash: Felt, - account: A, - txn_config: &TxnConfig, - tag: &str, - ) -> Result::SignError>> - where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, - { - let contract_address = - get_contract_address(self.salt(), base_class_hash, &[], world_address); - - let mut was_upgraded = false; - - let call = match account - .provider() - .get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address) - .await - { - Ok(current_class_hash) if current_class_hash != class_hash => { - was_upgraded = true; - - let contract_selector = compute_selector_from_tag(tag); - - Call { - calldata: vec![contract_selector, class_hash], - selector: selector!("upgrade_contract"), - to: world_address, - } - } - - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { - let calldata = vec![self.salt(), class_hash]; - Call { calldata, selector: selector!("deploy_contract"), to: world_address } - } - - Ok(_) => { - return Err(MigrationError::ContractAlreadyDeployed(contract_address)); - } - - Err(e) => return Err(MigrationError::Provider(e)), - }; - - let InvokeTransactionResult { transaction_hash } = account - .execute_v1(vec![call]) - .send_with_cfg(txn_config) - .await - .map_err(MigrationError::Migrator)?; - - let receipt = TransactionWaiter::new(transaction_hash, account.provider()).await?; - let block_number = get_block_number_from_receipt(receipt); - - Ok(DeployOutput { - transaction_hash, - block_number, - contract_address, - declare: None, - base_class_hash, - was_upgraded, - tag: None, - }) - } - - async fn deploy( - &self, - class_hash: Felt, - constructor_calldata: Vec, - account: A, - txn_config: &TxnConfig, - ) -> Result::SignError>> - where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, - { - let declare = match self.declare(&account, txn_config).await { - Ok(res) => Some(res), - Err(MigrationError::ClassAlreadyDeclared) => None, - Err(e) => return Err(e), - }; - - let calldata = [ - vec![ - class_hash, // class hash - self.salt(), // salt - Felt::ZERO, // unique - Felt::from(constructor_calldata.len()), // constructor calldata len - ], - constructor_calldata.clone(), - ] - .concat(); - - let contract_address = - get_contract_address(self.salt(), class_hash, &constructor_calldata, Felt::ZERO); - - match account - .provider() - .get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address) - .await - { - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => {} - Ok(_) => return Err(MigrationError::ContractAlreadyDeployed(contract_address)), - Err(e) => return Err(MigrationError::Provider(e)), - } - - let txn = account.execute_v1(vec![Call { - calldata, - // devnet UDC address - selector: selector!("deployContract"), - to: felt!("0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf"), - }]); - - let InvokeTransactionResult { transaction_hash } = - txn.send_with_cfg(txn_config).await.map_err(MigrationError::Migrator)?; - - let receipt = TransactionWaiter::new(transaction_hash, account.provider()).await?; - let block_number = get_block_number_from_receipt(receipt); - - Ok(DeployOutput { - transaction_hash, - block_number, - contract_address, - declare, - base_class_hash: Felt::default(), - was_upgraded: false, - tag: None, - }) - } - - fn salt(&self) -> Felt; -} - -#[cfg_attr(not(target_arch = "wasm32"), async_trait)] -#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -pub trait Upgradable: Deployable + Declarable + Sync { - async fn upgrade_world( - &self, - class_hash: Felt, - original_class_hash: Felt, - original_base_class_hash: Felt, - account: A, - txn_config: &TxnConfig, - ) -> Result::SignError>> - where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, - { - let declare = match self.declare(&account, txn_config).await { - Ok(res) => Some(res), - Err(MigrationError::ClassAlreadyDeclared) => None, - Err(e) => return Err(e), - }; - - let original_constructor_calldata = vec![original_base_class_hash]; - let contract_address = get_contract_address( - self.salt(), - original_class_hash, - &original_constructor_calldata, - Felt::ZERO, - ); - - match account - .provider() - .get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address) - .await - { - Ok(_) => {} - Err(e) => return Err(MigrationError::Provider(e)), - } - - let calldata = vec![class_hash]; - - let InvokeTransactionResult { transaction_hash } = account - .execute_v1(vec![Call { - calldata, - selector: selector!("upgrade"), - to: contract_address, - }]) - .send_with_cfg(txn_config) - .await - .map_err(MigrationError::Migrator)?; - - let receipt = TransactionWaiter::new(transaction_hash, account.provider()).await?; - let block_number = get_block_number_from_receipt(receipt); - - Ok(UpgradeOutput { transaction_hash, block_number, contract_address, declare }) - } -} - -fn prepare_contract_declaration_params( - artifact_path: &PathBuf, -) -> Result<(FlattenedSierraClass, Felt)> { - let flattened_class = read_class(artifact_path)? - .flatten() - .map_err(|e| anyhow!("error flattening the contract class: {e}"))?; - let compiled_class_hash = get_compiled_class_hash(artifact_path).map_err(|e| { - anyhow!("error computing compiled class hash: {} {e}", artifact_path.to_str().unwrap()) - })?; - Ok((flattened_class, compiled_class_hash)) -} - -pub fn read_class(artifact_path: &PathBuf) -> Result { - let file = File::open(artifact_path)?; - let contract_artifact: SierraClass = serde_json::from_reader(&file)?; - Ok(contract_artifact) -} - -fn get_compiled_class_hash(artifact_path: &PathBuf) -> Result { - let file = File::open(artifact_path)?; - let casm_contract_class: ContractClass = serde_json::from_reader(file)?; - let casm_contract = - CasmContractClass::from_contract_class(casm_contract_class, true, usize::MAX)?; - let res = serde_json::to_string_pretty(&casm_contract)?; - let compiled_class: CompiledClass = serde_json::from_str(&res)?; - Ok(compiled_class.class_hash()?) -} - -fn get_block_number_from_receipt(receipt: TransactionReceiptWithBlockInfo) -> Option { - match receipt.block { - ReceiptBlock::Pending => None, - ReceiptBlock::Block { block_number, .. } => Some(block_number), - } -} diff --git a/crates/dojo-world/src/migration/strategy.rs b/crates/dojo-world/src/migration/strategy.rs deleted file mode 100644 index fcce6e6f82..0000000000 --- a/crates/dojo-world/src/migration/strategy.rs +++ /dev/null @@ -1,286 +0,0 @@ -use std::collections::HashMap; -use std::fs; -use std::path::PathBuf; - -use anyhow::{anyhow, Context, Result}; -use camino::Utf8PathBuf; -use starknet::core::types::Felt; -use starknet::core::utils::{cairo_short_string_to_felt, get_contract_address}; -use starknet_crypto::{poseidon_hash_many, poseidon_hash_single}; - -use super::class::{ClassDiff, ClassMigration}; -use super::contract::{ContractDiff, ContractMigration}; -use super::world::WorldDiff; -use super::MigrationType; -use crate::contracts::naming; -use crate::manifest::{CONTRACTS_DIR, MODELS_DIR}; - -#[derive(Debug, Clone)] -pub enum MigrationMetadata { - Contract(ContractDiff), -} - -#[derive(Debug, Clone)] -pub struct MigrationStrategy { - pub world_address: Felt, - pub world: Option, - pub base: Option, - pub contracts: Vec, - pub models: Vec, - pub metadata: HashMap, -} - -#[derive(Debug)] -pub struct MigrationItemsInfo { - pub new: usize, - pub update: usize, -} - -impl MigrationStrategy { - pub fn info(&self) -> MigrationItemsInfo { - let mut new = 0; - let mut update = 0; - - if let Some(item) = &self.world { - match item.migration_type() { - MigrationType::New => new += 1, - MigrationType::Update => update += 1, - } - } - - self.contracts.iter().for_each(|item| match item.migration_type() { - MigrationType::New => new += 1, - MigrationType::Update => update += 1, - }); - - self.models.iter().for_each(|item| match item.migration_type() { - MigrationType::New => new += 1, - MigrationType::Update => update += 1, - }); - - MigrationItemsInfo { new, update } - } - - pub fn resolve_variable(&mut self, world_address: Felt) -> Result<()> { - for contract in self.contracts.iter_mut() { - for field in contract.diff.init_calldata.iter_mut() { - if let Some(dependency) = field.strip_prefix("$contract_address:") { - let dependency_contract = self.metadata.get(dependency).unwrap(); - - match dependency_contract { - MigrationMetadata::Contract(c) => { - let contract_address = get_contract_address( - generate_salt(&naming::get_name_from_tag(&c.tag)), - c.base_class_hash, - &[], - world_address, - ); - *field = contract_address.to_string(); - } - } - } else if let Some(dependency) = field.strip_prefix("$class_hash:") { - let dependency_contract = self.metadata.get(dependency).unwrap(); - match dependency_contract { - MigrationMetadata::Contract(c) => { - *field = c.local_class_hash.to_string(); - } - } - } - } - } - - Ok(()) - } -} - -/// construct migration strategy -/// evaluate which contracts/classes need to be declared/deployed -pub fn prepare_for_migration( - world_address: Option, - seed: Felt, - target_dir: &Utf8PathBuf, - diff: WorldDiff, -) -> Result { - let mut metadata = HashMap::new(); - let mut artifact_paths = HashMap::new(); - - read_artifact_paths(target_dir, &mut artifact_paths)?; - read_artifact_paths(&target_dir.join(MODELS_DIR), &mut artifact_paths)?; - read_artifact_paths(&target_dir.join(CONTRACTS_DIR), &mut artifact_paths)?; - - // We don't need to care if a contract has already been declared or not, because - // the migration strategy will take care of that. - - // If the world contract needs to be migrated, then all contracts need to be migrated - // else we need to evaluate which contracts need to be migrated. - let mut world = evaluate_contract_to_migrate(&diff.world, &artifact_paths, false)?; - let base = evaluate_class_to_migrate(&diff.base, &artifact_paths, world.is_some())?; - let contracts = evaluate_contracts_to_migrate( - &diff.contracts, - &artifact_paths, - &mut metadata, - world.is_some(), - )?; - let models = evaluate_models_to_migrate(&diff.models, &artifact_paths, world.is_some())?; - - // If world needs to be migrated, then we expect the `seed` to be provided. - if let Some(world) = &mut world { - let salt = poseidon_hash_single(seed); - - world.salt = salt; - let generated_world_address = get_contract_address( - salt, - diff.world.original_class_hash, - &[base.as_ref().unwrap().diff.original_class_hash], - Felt::ZERO, - ); - - world.contract_address = generated_world_address; - } - - // If world address is not provided, then we expect the world to be migrated. - let world_address = world_address.unwrap_or_else(|| world.as_ref().unwrap().contract_address); - - let mut migration = - MigrationStrategy { world_address, world, base, contracts, models, metadata }; - - migration.resolve_variable(world_address)?; - - Ok(migration) -} - -fn evaluate_models_to_migrate( - models: &[ClassDiff], - artifact_paths: &HashMap, - world_contract_will_migrate: bool, -) -> Result> { - let mut comps_to_migrate = vec![]; - - for c in models { - if let Ok(Some(c)) = - evaluate_class_to_migrate(c, artifact_paths, world_contract_will_migrate) - { - comps_to_migrate.push(c); - } - } - - Ok(comps_to_migrate) -} - -fn evaluate_class_to_migrate( - class: &ClassDiff, - artifact_paths: &HashMap, - world_contract_will_migrate: bool, -) -> Result> { - match class.remote_class_hash { - Some(remote) if remote == class.local_class_hash && !world_contract_will_migrate => { - Ok(None) - } - _ => { - let path = - find_artifact_path(&naming::get_filename_from_tag(&class.tag), artifact_paths)?; - Ok(Some(ClassMigration { diff: class.clone(), artifact_path: path.clone() })) - } - } -} - -fn evaluate_contracts_to_migrate( - contracts: &[ContractDiff], - artifact_paths: &HashMap, - metadata: &mut HashMap, - world_contract_will_migrate: bool, -) -> Result> { - let mut comps_to_migrate = vec![]; - - for c in contracts { - metadata.insert(c.tag.clone(), MigrationMetadata::Contract(c.clone())); - match c.remote_class_hash { - Some(remote) if remote == c.local_class_hash && !world_contract_will_migrate => { - continue; - } - _ => { - let path = - find_artifact_path(&naming::get_filename_from_tag(&c.tag), artifact_paths)?; - comps_to_migrate.push(ContractMigration { - diff: c.clone(), - artifact_path: path.clone(), - salt: generate_salt(&naming::get_name_from_tag(&c.tag)), - ..Default::default() - }); - } - } - } - - Ok(comps_to_migrate) -} - -fn evaluate_contract_to_migrate( - contract: &ContractDiff, - artifact_paths: &HashMap, - world_contract_will_migrate: bool, -) -> Result> { - if world_contract_will_migrate - || contract.remote_class_hash.is_none() - || matches!(contract.remote_class_hash, Some(remote_hash) if remote_hash != contract.local_class_hash) - { - let path = - find_artifact_path(&naming::get_filename_from_tag(&contract.tag), artifact_paths)?; - - Ok(Some(ContractMigration { - diff: contract.clone(), - artifact_path: path.clone(), - ..Default::default() - })) - } else { - Ok(None) - } -} - -fn find_artifact_path<'a>( - artifact_name: &str, - artifact_paths: &'a HashMap, -) -> Result<&'a PathBuf> { - artifact_paths - .get(artifact_name) - .with_context(|| anyhow!("missing contract artifact for `{}` contract", artifact_name)) -} - -pub fn generate_salt(value: &str) -> Felt { - poseidon_hash_many( - &value - .chars() - .collect::>() - .chunks(31) - .map(|chunk| { - let s: String = chunk.iter().collect(); - cairo_short_string_to_felt(&s).unwrap() - }) - .collect::>(), - ) -} - -fn read_artifact_paths( - input_dir: &Utf8PathBuf, - artifact_paths: &mut HashMap, -) -> Result<()> { - let entries = fs::read_dir(input_dir).with_context(|| { - format!( - "Failed trying to read target directory ({input_dir})\nNOTE: build files are profile \ - specified so make sure to run build command with correct profile. For e.g. `sozo -P \ - my_profile build`" - ) - })?; - - for entry in entries.flatten() { - let file_name = entry.file_name(); - let file_name_str = file_name.to_string_lossy(); - if file_name_str == "manifest.json" || !file_name_str.ends_with(".json") { - continue; - } - - let artifact_name = file_name_str.trim_end_matches(".json").to_string(); - artifact_paths.insert(artifact_name, entry.path()); - } - - Ok(()) -} diff --git a/crates/dojo-world/src/migration/world.rs b/crates/dojo-world/src/migration/world.rs deleted file mode 100644 index 46d76f5569..0000000000 --- a/crates/dojo-world/src/migration/world.rs +++ /dev/null @@ -1,204 +0,0 @@ -use std::fmt::Display; -use std::mem; -use std::str::FromStr; - -use anyhow::{bail, Result}; -use starknet_crypto::Felt; -use topological_sort::TopologicalSort; - -use super::class::ClassDiff; -use super::contract::ContractDiff; -use super::StateDiff; -use crate::contracts::naming; -use crate::manifest::{ - BaseManifest, DeploymentManifest, ManifestMethods, BASE_CONTRACT_TAG, WORLD_CONTRACT_TAG, -}; - -#[cfg(test)] -#[path = "world_test.rs"] -mod tests; - -/// Represents the state differences between the local and remote worlds. -#[derive(Debug, Clone)] -pub struct WorldDiff { - pub world: ContractDiff, - pub base: ClassDiff, - pub contracts: Vec, - pub models: Vec, -} - -impl WorldDiff { - pub fn compute( - local: BaseManifest, - remote: Option, - default_namespace: &str, - ) -> Result { - let models = local - .models - .iter() - .map(|model| ClassDiff { - tag: model.inner.tag.to_string(), - local_class_hash: *model.inner.class_hash(), - original_class_hash: *model.inner.original_class_hash(), - remote_class_hash: remote.as_ref().and_then(|m| { - m.models - .iter() - .find(|e| e.manifest_name == model.manifest_name) - .map(|s| *s.inner.class_hash()) - }), - }) - .collect::>(); - - let contracts = local - .contracts - .iter() - .map(|contract| { - let base_class_hash = { - let class_hash = contract.inner.base_class_hash; - if class_hash != Felt::ZERO { - class_hash - } else { - *local.base.inner.class_hash() - } - }; - - ContractDiff { - tag: contract.inner.tag.to_string(), - local_class_hash: *contract.inner.class_hash(), - original_class_hash: *contract.inner.original_class_hash(), - base_class_hash, - remote_class_hash: remote.as_ref().and_then(|m| { - m.contracts - .iter() - .find(|r| r.inner.class_hash() == contract.inner.class_hash()) - .map(|r| *r.inner.class_hash()) - }), - init_calldata: contract.inner.init_calldata.clone(), - local_writes: contract.inner.writes.clone(), - remote_writes: remote - .as_ref() - .and_then(|m| { - m.contracts - .iter() - .find(|r| r.inner.class_hash() == contract.inner.class_hash()) - .map(|r| r.inner.writes.clone()) - }) - .unwrap_or_default(), - } - }) - .collect::>(); - - let base = ClassDiff { - tag: BASE_CONTRACT_TAG.to_string(), - local_class_hash: *local.base.inner.class_hash(), - original_class_hash: *local.base.inner.original_class_hash(), - remote_class_hash: remote.as_ref().map(|m| *m.base.inner.class_hash()), - }; - - let world = ContractDiff { - tag: WORLD_CONTRACT_TAG.to_string(), - local_class_hash: *local.world.inner.class_hash(), - original_class_hash: *local.world.inner.original_class_hash(), - base_class_hash: *local.base.inner.class_hash(), - remote_class_hash: remote.map(|m| *m.world.inner.class_hash()), - init_calldata: vec![], - local_writes: vec![], - remote_writes: vec![], - }; - - let mut diff = WorldDiff { world, base, contracts, models }; - diff.update_order(default_namespace)?; - - Ok(diff) - } - - pub fn count_diffs(&self) -> usize { - let mut count = 0; - - if !self.world.is_same() { - count += 1; - } - - count += self.models.iter().filter(|s| !s.is_same()).count(); - count += self.contracts.iter().filter(|s| !s.is_same()).count(); - count - } - - pub fn update_order(&mut self, default_namespace: &str) -> Result<()> { - let mut ts = TopologicalSort::::new(); - - // make the dependency graph by reading the constructor_calldata - for contract in self.contracts.iter() { - ts.insert(contract.tag.clone()); - - for field in &contract.init_calldata { - if let Some(dependency) = field.strip_prefix("$contract_address:") { - ts.add_dependency( - naming::ensure_namespace(dependency, default_namespace), - contract.tag.clone(), - ); - } else if let Some(dependency) = field.strip_prefix("$class_hash:") { - ts.add_dependency( - naming::ensure_namespace(dependency, default_namespace), - contract.tag.clone(), - ); - } else { - // verify its a field element - match Felt::from_str(field) { - Ok(_) => continue, - Err(e) => bail!(format!( - "Expected init_calldata element to be a special variable (i.e. \ - starting with $contract_address or $class_hash) or be a \ - FieldElement. Failed with error: {e:?}" - )), - } - } - } - } - - let mut calculated_order = vec![]; - - while !ts.is_empty() { - let mut values = ts.pop_all(); - // if `ts` is not empty and `pop_all` returns an empty vector it means there is a cyclic - // dependency see: https://docs.rs/topological-sort/latest/topological_sort/struct.TopologicalSort.html#method.pop_all - if values.is_empty() { - bail!("Cyclic dependency detected in `init_calldata`"); - } - - values.sort(); - calculated_order.extend(values); - } - - let mut new_contracts = vec![]; - - for tag in calculated_order { - let contract = match self.contracts.iter().find(|c| c.tag == tag) { - Some(c) => c, - None => bail!("Unidentified contract found in `init_calldata`"), - }; - - new_contracts.push(contract.clone()); - } - - mem::swap(&mut self.contracts, &mut new_contracts); - - Ok(()) - } -} - -impl Display for WorldDiff { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "{}", self.world)?; - - for model in &self.models { - writeln!(f, "{model}")?; - } - - for contract in &self.contracts { - writeln!(f, "{contract}")?; - } - - Ok(()) - } -} diff --git a/crates/dojo-world/src/migration/world_test.rs b/crates/dojo-world/src/migration/world_test.rs deleted file mode 100644 index c6a0c8b8fa..0000000000 --- a/crates/dojo-world/src/migration/world_test.rs +++ /dev/null @@ -1,196 +0,0 @@ -use starknet::macros::felt; - -use super::*; -use crate::contracts::naming::{get_filename_from_tag, get_tag}; -use crate::manifest::{BaseManifest, Class, DojoContract, DojoModel, Manifest}; - -#[test] -fn no_diff_when_local_and_remote_are_equal() { - let world_contract = Manifest::new( - Class { class_hash: 66_u32.into(), ..Default::default() }, - get_filename_from_tag(WORLD_CONTRACT_TAG), - ); - - let base_contract = Manifest::new( - Class { class_hash: 77_u32.into(), ..Default::default() }, - get_filename_from_tag(BASE_CONTRACT_TAG), - ); - - let models = vec![Manifest::new( - DojoModel { members: vec![], class_hash: 11_u32.into(), ..Default::default() }, - "dojo_mock-model".into(), - )]; - - let remote_models = vec![Manifest::new( - DojoModel { members: vec![], class_hash: 11_u32.into(), ..Default::default() }, - "dojo_mock-model".into(), - )]; - - let local = - BaseManifest { models, world: world_contract, base: base_contract, contracts: vec![] }; - - let mut remote: DeploymentManifest = local.clone().into(); - remote.models = remote_models; - - let diff = WorldDiff::compute(local, Some(remote), "dojo-test").unwrap(); - - assert_eq!(diff.count_diffs(), 0); -} - -#[test] -fn diff_when_local_and_remote_are_different() { - let world_contract = Manifest::new( - Class { class_hash: 66_u32.into(), ..Default::default() }, - get_filename_from_tag(WORLD_CONTRACT_TAG), - ); - - let base_contract = Manifest::new( - Class { class_hash: 77_u32.into(), ..Default::default() }, - get_filename_from_tag(BASE_CONTRACT_TAG), - ); - - let models = vec![ - Manifest::new( - DojoModel { - tag: get_tag("dojo_mock", "model"), - members: vec![], - class_hash: felt!("0x11"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "model")), - ), - Manifest::new( - DojoModel { - tag: get_tag("dojo_mock", "model2"), - members: vec![], - class_hash: felt!("0x22"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "model2")), - ), - ]; - - let remote_models = vec![ - Manifest::new( - DojoModel { - tag: get_tag("dojo_mock", "model"), - members: vec![], - class_hash: felt!("0x11"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "model")), - ), - Manifest::new( - DojoModel { - tag: get_tag("dojo_mock", "model2"), - - members: vec![], - class_hash: felt!("0x33"), - ..Default::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "model2")), - ), - ]; - - let contracts = vec![ - Manifest::new( - DojoContract { - tag: get_tag("dojo_mock", "my_contract"), - class_hash: felt!("0x1111"), - address: Some(felt!("0x2222")), - ..DojoContract::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "my_contract")), - ), - Manifest::new( - DojoContract { - tag: get_tag("dojo_mock", "my_contract2"), - class_hash: felt!("0x3333"), - address: Some(felt!("4444")), - ..DojoContract::default() - }, - get_filename_from_tag(&get_tag("dojo_mock", "my_contract2")), - ), - ]; - - let local = BaseManifest { models, contracts, world: world_contract, base: base_contract }; - - let mut remote: DeploymentManifest = local.clone().into(); - remote.models = remote_models; - remote.world.inner.class_hash = 44_u32.into(); - remote.models[1].inner.class_hash = 33_u32.into(); - remote.contracts[0].inner.class_hash = felt!("0x1112"); - - let diff = WorldDiff::compute(local, Some(remote), "dojo-test").unwrap(); - - assert_eq!(diff.count_diffs(), 3); - assert!(diff.models.iter().any(|m| m.tag == get_tag("dojo_mock", "model2"))); - assert!(diff.contracts.iter().any(|c| c.tag == get_tag("dojo_mock", "my_contract"))); -} - -#[test] -fn updating_order_as_expected() { - let init_calldata = vec![ - ("ns", "c4", vec!["$contract_address:ns-c1", "0x0"]), - ("ns", "c3", vec!["0x0"]), - ("ns", "c5", vec!["$contract_address:ns-c4", "0x0"]), - ("ns", "c7", vec!["$contract_address:ns-c4", "0x0"]), - ("ns", "c2", vec!["0x0"]), - ("ns", "c6", vec!["$contract_address:ns-c4", "$contract_address:ns-c3", "0x0"]), - ("ns", "c1", vec!["0x0"]), - ]; - - let mut contracts = vec![]; - for calldata in init_calldata { - contracts.push(ContractDiff { - init_calldata: calldata.2.iter().map(|c| c.to_string()).collect(), - tag: get_tag(calldata.0, calldata.1), - ..Default::default() - }); - } - - let mut diff = WorldDiff { - world: ContractDiff::default(), - base: ClassDiff::default(), - contracts, - models: vec![], - }; - - diff.update_order("ns").unwrap(); - - let expected_order = ["ns-c1", "ns-c2", "ns-c3", "ns-c4", "ns-c5", "ns-c6", "ns-c7"]; - for (i, contract) in diff.contracts.iter().enumerate() { - assert_eq!(contract.tag, expected_order[i]); - } -} - -#[test] -fn updating_order_when_cyclic_dependency_fail() { - let init_calldata = vec![ - ("ns", "c4", vec!["$contract_address:ns-c1", "$contract_address:ns-c6", "0x0"]), - ("ns", "c3", vec!["0x0"]), - ("ns", "c5", vec!["$contract_address:ns-c4", "0x0"]), - ("ns", "c7", vec!["$contract_address:ns-c4", "0x0"]), - ("ns", "c2", vec!["0x0"]), - ("ns", "c6", vec!["$contract_address:ns-c4", "$contract_address:ns-c3", "0x0"]), - ("ns", "c1", vec!["0x0"]), - ]; - - let mut contracts = vec![]; - for calldata in init_calldata { - contracts.push(ContractDiff { - init_calldata: calldata.2.iter().map(|c| c.to_string()).collect(), - tag: get_tag(calldata.0, calldata.1), - ..Default::default() - }); - } - - let mut diff = WorldDiff { - world: ContractDiff::default(), - base: ClassDiff::default(), - contracts, - models: vec![], - }; - - assert!(diff.update_order("ns").is_err_and(|e| e.to_string().contains("Cyclic"))); -} diff --git a/crates/dojo-bindgen/Cargo.toml b/crates/dojo/bindgen/Cargo.toml similarity index 83% rename from crates/dojo-bindgen/Cargo.toml rename to crates/dojo/bindgen/Cargo.toml index bd5a505730..7a29340d31 100644 --- a/crates/dojo-bindgen/Cargo.toml +++ b/crates/dojo/bindgen/Cargo.toml @@ -7,6 +7,7 @@ repository.workspace = true version.workspace = true [dependencies] +anyhow.workspace = true async-trait.workspace = true camino.workspace = true chrono.workspace = true @@ -22,10 +23,11 @@ thiserror.workspace = true # dojo-test-utils = { path = "../dojo-test-utils", features = [ "build-examples" ] } cainome.workspace = true -dojo-world = { path = "../dojo-world", features = [ "manifest" ] } +dojo-world.workspace = true [dev-dependencies] assert_matches.workspace = true -dojo-test-utils = { path = "../dojo-test-utils", features = [ "build-examples" ] } +dojo-test-utils = { workspace = true, features = [ "build-examples" ] } scarb = { workspace = true } tokio.workspace = true +sozo-scarbext = { workspace = true } diff --git a/crates/dojo-bindgen/README.md b/crates/dojo/bindgen/README.md similarity index 100% rename from crates/dojo-bindgen/README.md rename to crates/dojo/bindgen/README.md diff --git a/crates/dojo-bindgen/src/error.rs b/crates/dojo/bindgen/src/error.rs similarity index 82% rename from crates/dojo-bindgen/src/error.rs rename to crates/dojo/bindgen/src/error.rs index 71adcd3e99..a144781fdf 100644 --- a/crates/dojo-bindgen/src/error.rs +++ b/crates/dojo/bindgen/src/error.rs @@ -1,5 +1,4 @@ use cainome::parser::Error as CainomeError; -use dojo_world::manifest::AbstractManifestError; use thiserror::Error; #[derive(Error, Debug)] @@ -13,7 +12,7 @@ pub enum Error { #[error("Format error: {0}")] Format(String), #[error(transparent)] - Manifest(#[from] AbstractManifestError), + Anyhow(#[from] anyhow::Error), } pub type BindgenResult = Result; diff --git a/crates/dojo-bindgen/src/lib.rs b/crates/dojo/bindgen/src/lib.rs similarity index 60% rename from crates/dojo-bindgen/src/lib.rs rename to crates/dojo/bindgen/src/lib.rs index c6c9145c4e..5fafebf89e 100644 --- a/crates/dojo-bindgen/src/lib.rs +++ b/crates/dojo/bindgen/src/lib.rs @@ -6,8 +6,9 @@ use std::path::PathBuf; use cainome::parser::tokens::Token; use cainome::parser::{AbiParser, TokenizedAbi}; use camino::Utf8PathBuf; -use dojo_world::manifest::BaseManifest; +use dojo_world::config::ProfileConfig; pub mod error; +use dojo_world::local::{ResourceLocal, WorldLocal}; use error::BindgenResult; mod plugins; @@ -27,6 +28,15 @@ pub struct DojoModel { pub tokens: TokenizedAbi, } +#[derive(Debug, PartialEq)] +pub struct DojoEvent { + /// event tag. + pub tag: String, + /// List of tokens found in the event contract ABI. + /// Only structs and enums are currently used. + pub tokens: TokenizedAbi, +} + #[derive(Debug, PartialEq)] pub struct DojoContract { /// Contract tag. @@ -52,6 +62,8 @@ pub struct DojoData { pub contracts: HashMap, /// All the models contracts found in the project. pub models: HashMap, + /// All the events contracts found in the project. + pub events: HashMap, } #[derive(Debug)] @@ -118,63 +130,61 @@ fn gather_dojo_data( skip_migration: Option>, ) -> BindgenResult { let root_dir: Utf8PathBuf = manifest_path.parent().unwrap().into(); - let base_manifest_dir: Utf8PathBuf = root_dir.join("manifests").join(profile_name).join("base"); - let mut base_manifest = BaseManifest::load_from_path(&base_manifest_dir)?; - if let Some(skip_manifests) = skip_migration { - base_manifest.remove_tags(&skip_manifests); - } + let profile_config = + ProfileConfig::from_toml(root_dir.join(format!("dojo_{}.toml", profile_name)))?; + let target_dir = root_dir.join("target").join(profile_name); + + let world_local = WorldLocal::from_directory(&target_dir, profile_config)?; let mut models = HashMap::new(); let mut contracts = HashMap::new(); + let mut events = HashMap::new(); - for contract_manifest in &base_manifest.contracts { - // Base manifest always use path for ABI. - let abi = contract_manifest - .inner - .abi - .as_ref() - .expect("Valid ABI for contract") - .load_abi_string(&root_dir)?; - - let tokens = AbiParser::tokens_from_abi_string(&abi, &HashMap::new())?; - let tag = contract_manifest.inner.tag.clone(); - - // Identify the systems -> for now only take the functions from the - // interfaces. - let mut systems = vec![]; - let interface_blacklist = - ["dojo::world::IWorldProvider", "dojo::contract::upgradeable::IUpgradeable"]; - - for (interface, funcs) in &tokens.interfaces { - if !interface_blacklist.contains(&interface.as_str()) { - systems.extend(funcs.clone()); + for r in world_local.resources.values() { + if let Some(skip_migrations) = &skip_migration { + if skip_migrations.contains(&r.tag()) { + continue; } } - contracts.insert(tag.clone(), DojoContract { tag, tokens, systems }); - } + match r { + ResourceLocal::Contract(c) => { + let tokens = AbiParser::collect_tokens(&c.common.class.abi, &HashMap::new())?; - for model_manifest in &base_manifest.models { - // Base manifest always use path for ABI. - let abi = model_manifest - .inner - .abi - .as_ref() - .expect("Valid ABI for contract") - .load_abi_string(&root_dir)?; + // Identify the systems -> for now only take the functions from the + // interfaces. + let mut systems = vec![]; + let interface_blacklist = + ["dojo::world::IWorldProvider", "dojo::contract::upgradeable::IUpgradeable"]; - let tokens = AbiParser::tokens_from_abi_string(&abi, &HashMap::new())?; - let tag = model_manifest.inner.tag.clone(); + for (interface, funcs) in &tokens.interfaces { + if !interface_blacklist.contains(&interface.as_str()) { + systems.extend(funcs.clone()); + } + } - let model = DojoModel { tag: tag.clone(), tokens: filter_model_tokens(&tokens) }; + let tag = r.tag(); - models.insert(tag.clone(), model); + contracts.insert(tag.clone(), DojoContract { tag, tokens, systems }); + } + ResourceLocal::Model(m) => { + let tokens = AbiParser::collect_tokens(&m.common.class.abi, &HashMap::new())?; + let tag = r.tag(); + models.insert(tag.clone(), DojoModel { tag, tokens: filter_model_tokens(&tokens) }); + } + ResourceLocal::Event(m) => { + let tokens = AbiParser::collect_tokens(&m.common.class.abi, &HashMap::new())?; + let tag = r.tag(); + events.insert(tag.clone(), DojoEvent { tag, tokens: filter_model_tokens(&tokens) }); + } + _ => {} + } } let world = DojoWorld { name: root_package_name.to_string() }; - Ok(DojoData { world, models, contracts }) + Ok(DojoData { world, models, contracts, events }) } /// Filters the model ABI to keep relevant types @@ -224,44 +234,47 @@ pub fn compare_tokens_by_type_name(a: &Token, b: &Token) -> Ordering { #[cfg(test)] mod tests { use dojo_test_utils::compiler::CompilerTestSetup; - use dojo_world::metadata::dojo_metadata_from_workspace; use scarb::compiler::Profile; + use sozo_scarbext::WorkspaceExt; use super::*; #[test] fn gather_data_ok() { - let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let setup = CompilerTestSetup::from_examples("../core", "../../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let dojo_metadata = dojo_metadata_from_workspace(&ws).expect( - "No current package with dojo metadata found, bindgen is not yet supported for \ - workspaces.", - ); + let profile_config = ws.load_profile_config().unwrap(); - let data = gather_dojo_data( - &config.manifest_path().to_path_buf(), - "dojo_example", - "dev", - dojo_metadata.migration.map(|m| m.skip_contracts), - ) - .unwrap(); + let skip_migrations = if let Some(migration) = profile_config.migration { + let mut skip_migration = vec![]; + if let Some(skip_contracts) = migration.skip_contracts { + skip_migration.extend(skip_contracts); + } + Some(skip_migration) + } else { + None + }; + + let data = + gather_dojo_data(&config.manifest_path().to_path_buf(), "ns", "dev", skip_migrations) + .unwrap(); - assert_eq!(data.models.len(), 10); + assert_eq!(data.models.len(), 6); - assert_eq!(data.world.name, "dojo_example"); + assert_eq!(data.world.name, "ns"); - let pos = data.models.get("dojo_examples-Position").unwrap(); - assert_eq!(pos.tag, "dojo_examples-Position"); + let pos = data.models.get("ns-Position").unwrap(); + assert_eq!(pos.tag, "ns-Position"); - let moves = data.models.get("dojo_examples-Moves").unwrap(); - assert_eq!(moves.tag, "dojo_examples-Moves"); + let moves = data.models.get("ns-Moves").unwrap(); + assert_eq!(moves.tag, "ns-Moves"); - let moved = data.models.get("dojo_examples-Message").unwrap(); - assert_eq!(moved.tag, "dojo_examples-Message"); + let moved = data.models.get("ns-Message").unwrap(); + assert_eq!(moved.tag, "ns-Message"); - let player_config = data.models.get("dojo_examples-PlayerConfig").unwrap(); - assert_eq!(player_config.tag, "dojo_examples-PlayerConfig"); + let player_config = data.models.get("ns-PlayerConfig").unwrap(); + assert_eq!(player_config.tag, "ns-PlayerConfig"); } } diff --git a/crates/dojo-bindgen/src/plugins/mod.rs b/crates/dojo/bindgen/src/plugins/mod.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/mod.rs rename to crates/dojo/bindgen/src/plugins/mod.rs diff --git a/crates/dojo-bindgen/src/plugins/recs/mod.rs b/crates/dojo/bindgen/src/plugins/recs/mod.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/recs/mod.rs rename to crates/dojo/bindgen/src/plugins/recs/mod.rs diff --git a/crates/dojo-bindgen/src/plugins/recs/tests.rs b/crates/dojo/bindgen/src/plugins/recs/tests.rs similarity index 99% rename from crates/dojo-bindgen/src/plugins/recs/tests.rs rename to crates/dojo/bindgen/src/plugins/recs/tests.rs index c6a18bbab2..c900b440b5 100644 --- a/crates/dojo-bindgen/src/plugins/recs/tests.rs +++ b/crates/dojo/bindgen/src/plugins/recs/tests.rs @@ -182,5 +182,6 @@ fn create_mock_dojo_data() -> DojoData { world: DojoWorld { name: 0x01.to_string() }, models: HashMap::new(), contracts: HashMap::new(), + events: HashMap::new(), } } diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/enum.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/enum.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/enum.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/enum.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/erc.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/erc.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/erc.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/erc.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/function.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/function.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/function.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/function.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/interface.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/interface.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/interface.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/interface.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/mod.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/mod.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/mod.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/mod.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/generator/schema.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/schema.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/generator/schema.rs rename to crates/dojo/bindgen/src/plugins/typescript/generator/schema.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/mod.rs b/crates/dojo/bindgen/src/plugins/typescript/mod.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/typescript/mod.rs rename to crates/dojo/bindgen/src/plugins/typescript/mod.rs diff --git a/crates/dojo-bindgen/src/plugins/typescript/writer.rs b/crates/dojo/bindgen/src/plugins/typescript/writer.rs similarity index 99% rename from crates/dojo-bindgen/src/plugins/typescript/writer.rs rename to crates/dojo/bindgen/src/plugins/typescript/writer.rs index f59d0b1cd2..f23bbbe41b 100644 --- a/crates/dojo-bindgen/src/plugins/typescript/writer.rs +++ b/crates/dojo/bindgen/src/plugins/typescript/writer.rs @@ -153,6 +153,7 @@ mod tests { models: HashMap::new(), contracts: HashMap::new(), world: DojoWorld { name: "0x01".to_string() }, + events: HashMap::new(), }; let (path, code) = writer.write("models.gen.ts", &data).unwrap(); diff --git a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs b/crates/dojo/bindgen/src/plugins/typescript_v2/mod.rs similarity index 97% rename from crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs rename to crates/dojo/bindgen/src/plugins/typescript_v2/mod.rs index 1447b785d7..f0ca48ca26 100644 --- a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs +++ b/crates/dojo/bindgen/src/plugins/typescript_v2/mod.rs @@ -627,8 +627,8 @@ mod tests { use std::io::Read; use dojo_test_utils::compiler::CompilerTestSetup; - use dojo_world::metadata::dojo_metadata_from_workspace; use scarb::compiler::Profile; + use sozo_scarbext::WorkspaceExt; use super::*; use crate::gather_dojo_data; @@ -645,19 +645,27 @@ mod tests { let expected_output_without_header = expected_output.lines().skip(1).collect::>().join("\n"); - let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let setup = CompilerTestSetup::from_examples("../dojo/core", "../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let dojo_metadata = dojo_metadata_from_workspace(&ws).expect( - "No current package with dojo metadata found, bindgen is not yet support for \ - workspaces.", - ); + let profile_config = ws.load_profile_config().unwrap(); + + let skip_migrations = if let Some(migration) = profile_config.migration { + let mut skip_migration = vec![]; + if let Some(skip_contracts) = migration.skip_contracts { + skip_migration.extend(skip_contracts); + } + Some(skip_migration) + } else { + None + }; + let data = gather_dojo_data( &config.manifest_path().to_path_buf(), "dojo_examples", "dev", - dojo_metadata.migration.map(|m| m.skip_contracts), + skip_migrations, ) .unwrap(); diff --git a/crates/dojo-bindgen/src/plugins/unity/mod.rs b/crates/dojo/bindgen/src/plugins/unity/mod.rs similarity index 100% rename from crates/dojo-bindgen/src/plugins/unity/mod.rs rename to crates/dojo/bindgen/src/plugins/unity/mod.rs diff --git a/crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts b/crates/dojo/bindgen/src/test_data/mocks/dojo_examples.ts similarity index 100% rename from crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts rename to crates/dojo/bindgen/src/test_data/mocks/dojo_examples.ts diff --git a/crates/dojo-bindgen/src/test_data/spawn-and-move b/crates/dojo/bindgen/src/test_data/spawn-and-move similarity index 100% rename from crates/dojo-bindgen/src/test_data/spawn-and-move rename to crates/dojo/bindgen/src/test_data/spawn-and-move diff --git a/crates/dojo/core-cairo-test/Scarb.lock b/crates/dojo/core-cairo-test/Scarb.lock new file mode 100644 index 0000000000..2c1a7ab14c --- /dev/null +++ b/crates/dojo/core-cairo-test/Scarb.lock @@ -0,0 +1,20 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "1.0.0-rc.0" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_cairo_test" +version = "1.0.0-rc.0" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo_plugin" +version = "2.8.4" diff --git a/crates/dojo/core-cairo-test/Scarb.toml b/crates/dojo/core-cairo-test/Scarb.toml new file mode 100644 index 0000000000..b7e2111a73 --- /dev/null +++ b/crates/dojo/core-cairo-test/Scarb.toml @@ -0,0 +1,15 @@ +[package] +cairo-version = "=2.8.4" +edition = "2024_07" +description = "Testing library for Dojo using Cairo test runner." +name = "dojo_cairo_test" +version = "1.0.0-rc.0" + +[dependencies] +starknet = "=2.8.4" +dojo = { path = "../core" } + +[dev-dependencies] +cairo_test = "=2.8.4" + +[lib] diff --git a/crates/dojo/core-cairo-test/src/lib.cairo b/crates/dojo/core-cairo-test/src/lib.cairo new file mode 100644 index 0000000000..d1170f442d --- /dev/null +++ b/crates/dojo/core-cairo-test/src/lib.cairo @@ -0,0 +1,59 @@ +//! Testing library for Dojo using Cairo test runner. + +#[cfg(target: "test")] +mod utils; +#[cfg(target: "test")] +mod world; + +#[cfg(target: "test")] +pub use utils::{GasCounter, assert_array, GasCounterTrait}; +#[cfg(target: "test")] +pub use world::{ + deploy_contract, deploy_with_world_address, spawn_test_world, NamespaceDef, TestResource, + ContractDef, ContractDefTrait +}; + +#[cfg(test)] +mod tests { + mod meta { + mod introspect; + } + + mod event { + mod event; + } + + // mod model { + // mod model; + // } + + mod storage { + mod database; + mod packing; + mod storage; + } + + mod contract; + // mod benchmarks; + + mod expanded { + pub(crate) mod selector_attack; + } + + mod helpers; + + mod world { + mod acl; + //mod entities; + //mod resources; + //mod world; + } + + mod utils { + mod hash; + mod key; + mod layout; + mod misc; + mod naming; + } +} diff --git a/crates/dojo-core/src/tests/benchmarks.cairo b/crates/dojo/core-cairo-test/src/tests/benchmarks.cairo similarity index 94% rename from crates/dojo-core/src/tests/benchmarks.cairo rename to crates/dojo/core-cairo-test/src/tests/benchmarks.cairo index 298057be2a..c33d63ef6f 100644 --- a/crates/dojo-core/src/tests/benchmarks.cairo +++ b/crates/dojo/core-cairo-test/src/tests/benchmarks.cairo @@ -3,22 +3,21 @@ use core::poseidon::poseidon_hash_span; use core::result::ResultTrait; use core::serde::Serde; -use starknet::{ - contract_address_const, ContractAddress, ClassHash, get_caller_address, SyscallResultTrait -}; +use starknet::{ContractAddress, SyscallResultTrait}; use starknet::storage_access::{ storage_base_address_from_felt252, storage_address_from_base, storage_address_from_base_and_offset }; use starknet::syscalls::{storage_read_syscall, storage_write_syscall}; -use dojo::model::{Model, Layout, ModelIndex}; -use dojo::model::introspect::Introspect; +use dojo::meta::Layout; +use dojo::model::{Model, ModelIndex, ModelStore}; use dojo::storage::{database, storage}; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -use dojo::tests::helpers::{Foo, Sword, Case, CaseStore, case, Character, Abilities, Stats, Weapon}; -use dojo::utils::test::{spawn_test_world, GasCounterTrait}; +use crate::tests::helpers::{Foo, Sword, Case, case, Character, Abilities, Stats, Weapon, DOJO_NSH}; +use crate::world::{spawn_test_world, NamespaceDef, TestResource}; +use crate::utils::GasCounterTrait; #[derive(Drop, Serde)] #[dojo::model] @@ -44,12 +43,15 @@ struct ComplexModel { } fn deploy_world() -> IWorldDispatcher { - spawn_test_world( - ["dojo"].span(), - [ - case::TEST_CLASS_HASH, case_not_packed::TEST_CLASS_HASH, complex_model::TEST_CLASS_HASH - ].span() - ) + let namespace_def = NamespaceDef { + namespace: "dojo", resources: [ + TestResource::Model(case::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Model(case_not_packed::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Model(complex_model::TEST_CLASS_HASH.try_into().unwrap()), + ].span(), + }; + + spawn_test_world([namespace_def].span()) } #[test] @@ -464,7 +466,7 @@ fn test_benchmark_set_entity() { let gas = GasCounterTrait::start(); world .set_entity( - model_selector: Model::::selector(), + model_selector: Model::::selector(DOJO_NSH), index: ModelIndex::Keys(simple_entity_packed.keys()), values: simple_entity_packed.values(), layout: Model::::layout() @@ -492,15 +494,15 @@ fn test_benchmark_set_entity() { gas.end("World::SetEntity::ComplexModel"); let gas = GasCounterTrait::start(); - simple_entity_packed.set(world); + world.set(@simple_entity_packed); gas.end("Model::Set::SimplePacked"); let gas = GasCounterTrait::start(); - simple_entity_not_packed.set(world); + world.set(@simple_entity_not_packed); gas.end("Model::Set::SimpleNotPacked"); let gas = GasCounterTrait::start(); - complex_entity.set(world); + world.set(@complex_entity); gas.end("Model::Set::ComplexModel"); let gas = GasCounterTrait::start(); diff --git a/crates/dojo/core-cairo-test/src/tests/contract.cairo b/crates/dojo/core-cairo-test/src/tests/contract.cairo new file mode 100644 index 0000000000..d206303612 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/contract.cairo @@ -0,0 +1,179 @@ +use core::option::OptionTrait; +use core::traits::TryInto; + +use starknet::ClassHash; + +use dojo::contract::components::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; +use dojo::world::IWorldDispatcherTrait; + +use crate::tests::helpers::deploy_world; + +#[starknet::contract] +pub mod contract_invalid_upgrade { + #[storage] + struct Storage {} + + #[abi(per_item)] + #[generate_trait] + pub impl InvalidImpl of InvalidContractTrait { + #[external(v0)] + fn no_dojo_name(self: @ContractState) -> ByteArray { + "test_contract" + } + } +} + +#[dojo::contract] +mod test_contract {} + +#[starknet::interface] +pub trait IQuantumLeap { + fn plz_more_tps(self: @T) -> felt252; +} + +#[starknet::contract] +pub mod test_contract_upgrade { + use dojo::contract::IContract; + use dojo::world::IWorldDispatcher; + use dojo::contract::components::world_provider::IWorldProvider; + + #[storage] + struct Storage {} + + #[constructor] + fn constructor(ref self: ContractState) {} + + #[abi(embed_v0)] + pub impl QuantumLeap of super::IQuantumLeap { + fn plz_more_tps(self: @ContractState) -> felt252 { + 'daddy' + } + } + + #[abi(embed_v0)] + pub impl WorldProviderImpl of IWorldProvider { + fn world_dispatcher(self: @ContractState) -> IWorldDispatcher { + IWorldDispatcher { contract_address: starknet::contract_address_const::<'world'>() } + } + } + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn dojo_name(self: @ContractState) -> ByteArray { + "test_contract" + } + } +} + +#[test] +#[available_gas(7000000)] +fn test_upgrade_from_world() { + let world = deploy_world(); + + let base_address = world + .register_contract('salt', "dojo", test_contract::TEST_CLASS_HASH.try_into().unwrap()); + let new_class_hash: ClassHash = test_contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); + + world.upgrade_contract("dojo", new_class_hash); + + let quantum_dispatcher = IQuantumLeapDispatcher { contract_address: base_address }; + assert(quantum_dispatcher.plz_more_tps() == 'daddy', 'quantum leap failed'); +} + +#[test] +#[available_gas(7000000)] +#[should_panic(expected: ('ENTRYPOINT_NOT_FOUND', 'ENTRYPOINT_FAILED'))] +fn test_upgrade_from_world_not_world_provider() { + let world = deploy_world(); + + let _ = world + .register_contract('salt', "dojo", test_contract::TEST_CLASS_HASH.try_into().unwrap()); + let new_class_hash: ClassHash = contract_invalid_upgrade::TEST_CLASS_HASH.try_into().unwrap(); + + world.upgrade_contract("dojo", new_class_hash); +} + +#[test] +#[available_gas(6000000)] +#[should_panic(expected: ('must be called by world', 'ENTRYPOINT_FAILED'))] +fn test_upgrade_direct() { + let world = deploy_world(); + + let base_address = world + .register_contract('salt', "dojo", test_contract::TEST_CLASS_HASH.try_into().unwrap()); + let new_class_hash: ClassHash = test_contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); + + let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address: base_address }; + upgradeable_dispatcher.upgrade(new_class_hash); +} + +#[starknet::interface] +trait IMetadataOnly { + fn dojo_name(self: @T) -> ByteArray; +} + +#[starknet::contract] +mod invalid_legacy_model { + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl InvalidModelMetadata of super::IMetadataOnly { + fn dojo_name(self: @ContractState) -> ByteArray { + "invalid_legacy_model" + } + } +} + +#[starknet::contract] +mod invalid_legacy_model_world { + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl InvalidModelName of super::IMetadataOnly { + fn dojo_name(self: @ContractState) -> ByteArray { + "invalid_legacy_model" + } + } +} + +#[starknet::contract] +mod invalid_model { + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl InvalidModelSelector of super::IMetadataOnly { + fn dojo_name(self: @ContractState) -> ByteArray { + "invalid_model" + } + } +} + +#[starknet::contract] +mod invalid_model_world { + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl InvalidModelSelector of super::IMetadataOnly { + fn dojo_name(self: @ContractState) -> ByteArray { + "invalid_model_world" + } + } +} + +#[test] +#[available_gas(6000000)] +#[should_panic( + expected: ( + "Namespace `` is invalid according to Dojo naming rules: ^[a-zA-Z0-9_]+$", + 'ENTRYPOINT_FAILED', + ) +)] +fn test_register_namespace_empty_name() { + let world = deploy_world(); + + world.register_namespace(""); +} diff --git a/crates/dojo/core-cairo-test/src/tests/event/event.cairo b/crates/dojo/core-cairo-test/src/tests/event/event.cairo new file mode 100644 index 0000000000..2c8e3e3bd0 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/event/event.cairo @@ -0,0 +1,19 @@ +#[dojo::event] +struct FooEvent { + #[key] + k1: u8, + #[key] + k2: felt252, + v1: u128, + v2: u32 +} + +#[test] +fn test_event_definition() { + let definition = dojo::event::Event::::definition(); + + assert_eq!(definition.name, dojo::event::Event::::name()); + assert_eq!(definition.version, dojo::event::Event::::version()); + assert_eq!(definition.layout, dojo::event::Event::::layout()); + assert_eq!(definition.schema, dojo::event::Event::::schema()); +} diff --git a/crates/dojo/core-cairo-test/src/tests/expanded/selector_attack.cairo b/crates/dojo/core-cairo-test/src/tests/expanded/selector_attack.cairo new file mode 100644 index 0000000000..17f1266074 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/expanded/selector_attack.cairo @@ -0,0 +1,73 @@ +//! Test some manually expanded code for permissioned contract deployment and resource registration. +//! + +#[starknet::contract] +pub mod attacker_contract { + use dojo::world::IWorldDispatcher; + use dojo::contract::components::world_provider::IWorldProvider; + use dojo::contract::IContract; + use starknet::storage::StoragePointerReadAccess; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn dojo_name(self: @ContractState) -> ByteArray { + "test_1" + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world_dispatcher(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } +} + +#[starknet::contract] +pub mod attacker_model { + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel { + fn dojo_name(self: @ContractState) -> ByteArray { + "foo" + } + + fn version(self: @ContractState) -> u8 { + 1 + } + + fn unpacked_size(self: @ContractState) -> Option { + Option::None + } + + fn packed_size(self: @ContractState) -> Option { + Option::None + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::meta::Layout::Fixed([].span()) + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Primitive('felt252') + } + + fn definition(self: @ContractState) -> dojo::model::ModelDef { + dojo::model::ModelDef { + name: Self::dojo_name(self), + version: Self::version(self), + layout: Self::layout(self), + schema: Self::schema(self), + packed_size: Self::packed_size(self), + unpacked_size: Self::unpacked_size(self), + } + } + } +} diff --git a/crates/dojo/core-cairo-test/src/tests/helpers.cairo b/crates/dojo/core-cairo-test/src/tests/helpers.cairo new file mode 100644 index 0000000000..68f07d0d53 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/helpers.cairo @@ -0,0 +1,263 @@ +use starknet::ContractAddress; + +use dojo::world::{ + IWorldDispatcher, IWorldDispatcherTrait, IWorldTestDispatcher, IWorldTestDispatcherTrait +}; +use dojo::model::Model; + +use crate::world::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait}; + +pub const DOJO_NSH: felt252 = 0x309e09669bc1fdc1dd6563a7ef862aa6227c97d099d08cc7b81bad58a7443fa; + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::event] +pub struct SimpleEvent { + #[key] + pub id: u32, + pub data: (felt252, felt252), +} + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +pub struct Foo { + #[key] + pub caller: ContractAddress, + pub a: felt252, + pub b: u128, +} + +#[starknet::contract] +pub mod foo_invalid_name { + use dojo::model::IModel; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + pub impl ModelImpl of IModel { + fn dojo_name(self: @ContractState) -> ByteArray { + "foo-bis" + } + + fn version(self: @ContractState) -> u8 { + 1 + } + + fn unpacked_size(self: @ContractState) -> Option { + Option::None + } + + fn packed_size(self: @ContractState) -> Option { + Option::None + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::meta::Layout::Fixed([].span()) + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'foo', attrs: [].span(), children: [].span() + } + ) + } + + fn definition(self: @ContractState) -> dojo::model::ModelDef { + dojo::model::ModelDef { + name: Self::dojo_name(self), + version: Self::version(self), + layout: Self::layout(self), + schema: Self::schema(self), + packed_size: Self::packed_size(self), + unpacked_size: Self::unpacked_size(self), + } + } + } +} + +#[starknet::interface] +pub trait IFooSetter { + fn set_foo(ref self: T, a: felt252, b: u128); +} + +#[dojo::contract] +pub mod foo_setter { + use super::{Foo, IFooSetter}; + use dojo::model::ModelStorage; + + #[abi(embed_v0)] + impl IFooSetterImpl of IFooSetter { + fn set_foo(ref self: ContractState, a: felt252, b: u128) { + let mut world = self.world(@"dojo"); + world.write_model(@Foo { caller: starknet::get_caller_address(), a, b }); + } + } +} + +#[dojo::contract] +pub mod test_contract {} + +#[dojo::contract] +pub mod test_contract_with_dojo_init_args { + fn dojo_init(ref self: ContractState, arg1: felt252) { + let _a = arg1; + } +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +pub struct Sword { + pub swordsmith: ContractAddress, + pub damage: u32, +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +#[dojo::model] +pub struct Case { + #[key] + pub owner: ContractAddress, + pub sword: Sword, + pub material: felt252, +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +#[dojo::model] +pub struct Character { + #[key] + pub caller: ContractAddress, + pub heigth: felt252, + pub abilities: Abilities, + pub stats: Stats, + pub weapon: Weapon, + pub gold: u32, +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +pub struct Abilities { + pub strength: u8, + pub dexterity: u8, + pub constitution: u8, + pub intelligence: u8, + pub wisdom: u8, + pub charisma: u8, +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +pub struct Stats { + pub kills: u128, + pub deaths: u16, + pub rests: u32, + pub hits: u64, + pub blocks: u32, + pub walked: felt252, + pub runned: felt252, + pub finished: bool, + pub romances: u16, +} + +#[derive(IntrospectPacked, Copy, Drop, Serde)] +pub enum Weapon { + DualWield: (Sword, Sword), + Fists: (Sword, Sword), // Introspect requires same arms +} + +#[starknet::interface] +pub trait Ibar { + fn set_foo(self: @TContractState, a: felt252, b: u128); + fn delete_foo(self: @TContractState); + fn delete_foo_macro(self: @TContractState, foo: Foo); + fn set_char(self: @TContractState, a: felt252, b: u32); +} + +#[starknet::contract] +pub mod bar { + use core::traits::Into; + use starknet::{get_caller_address, ContractAddress}; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + use dojo::model::{Model, ModelIndex}; + use super::DOJO_NSH; + + use super::{Foo, IWorldDispatcher, IWorldDispatcherTrait}; + + #[storage] + struct Storage { + world: IWorldDispatcher, + } + #[constructor] + fn constructor(ref self: ContractState, world: ContractAddress) { + self.world.write(IWorldDispatcher { contract_address: world }) + } + + #[abi(embed_v0)] + impl IbarImpl of super::Ibar { + fn set_foo( + self: @ContractState, a: felt252, b: u128 + ) { // set!(self.world.read(), Foo { caller: get_caller_address(), a, b }); + } + + fn delete_foo(self: @ContractState) { + self + .world + .read() + .delete_entity( + Model::::selector(DOJO_NSH), + ModelIndex::Keys([get_caller_address().into()].span()), + Model::::layout() + ); + } + + fn delete_foo_macro( + self: @ContractState, foo: Foo + ) { //delete!(self.world.read(), Foo { caller: foo.caller, a: foo.a, b: foo.b }); + } + + fn set_char(self: @ContractState, a: felt252, b: u32) {} + } +} + +/// Deploys an empty world with the `dojo` namespace. +pub fn deploy_world() -> IWorldDispatcher { + let namespace_def = NamespaceDef { namespace: "dojo", resources: [].span(), }; + + spawn_test_world([namespace_def].span()).dispatcher +} + +/// Deploys an empty world with the `dojo` namespace and registers the `foo` model. +/// No permissions are granted. +pub fn deploy_world_and_foo() -> (IWorldDispatcher, felt252) { + let world = deploy_world(); + world.register_model("dojo", m_Foo::TEST_CLASS_HASH.try_into().unwrap()); + let foo_selector = Model::::selector(DOJO_NSH); + + (world, foo_selector) +} + +/// Deploys an empty world with the `dojo` namespace and registers the `foo` model. +/// Grants the `bar` contract writer permissions to the `foo` model. +pub fn deploy_world_and_bar() -> (IWorldDispatcher, IbarDispatcher) { + let namespace_def = NamespaceDef { + namespace: "dojo", resources: [ + TestResource::Model(m_Foo::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Contract(ContractDefTrait::new(bar::TEST_CLASS_HASH, "bar")), + ].span(), + }; + + let world = spawn_test_world([namespace_def].span()).dispatcher; + let bar_address = IWorldTestDispatcher { contract_address: world.contract_address } + .dojo_contract_address(selector_from_tag!("dojo-bar")); + + let bar_contract = IbarDispatcher { contract_address: bar_address }; + + world.grant_writer(Model::::selector(DOJO_NSH), bar_address); + + (world, bar_contract) +} + +pub fn drop_all_events(address: ContractAddress) { + loop { + match starknet::testing::pop_log_raw(address) { + core::option::Option::Some(_) => {}, + core::option::Option::None => { break; }, + }; + } +} diff --git a/crates/dojo-core/src/tests/model/introspect.cairo b/crates/dojo/core-cairo-test/src/tests/meta/introspect.cairo similarity index 98% rename from crates/dojo-core/src/tests/model/introspect.cairo rename to crates/dojo/core-cairo-test/src/tests/meta/introspect.cairo index 8a519afd97..bfa89e3023 100644 --- a/crates/dojo-core/src/tests/model/introspect.cairo +++ b/crates/dojo/core-cairo-test/src/tests/meta/introspect.cairo @@ -1,5 +1,5 @@ -use dojo::model::introspect::Introspect; -use dojo::model::{Layout, FieldLayout}; +use dojo::meta::introspect::Introspect; +use dojo::meta::{Layout, FieldLayout}; #[derive(Drop, Introspect)] struct Base { diff --git a/crates/dojo/core-cairo-test/src/tests/model/model.cairo b/crates/dojo/core-cairo-test/src/tests/model/model.cairo new file mode 100644 index 0000000000..51f3e6bd40 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/model/model.cairo @@ -0,0 +1,197 @@ +use dojo::model::{Model, ModelValue, ModelStorage, ModelValueStorage, ModelMemberStorage}; +use dojo::world::{IWorldDispatcherTrait, WorldStorageTrait, WorldStorage}; + +use crate::tests::helpers::{deploy_world}; + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +struct Foo { + #[key] + k1: u8, + #[key] + k2: felt252, + v1: u128, + v2: u32 +} + + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +struct Foo2 { + #[key] + k1: u8, + #[key] + k2: felt252, + v1: u128, + v2: u32 +} + +#[test] +fn test_model_definition() { + let definition = dojo::model::Model::::definition(); + + assert_eq!(definition.name, dojo::model::Model::::name()); + assert_eq!(definition.version, dojo::model::Model::::version()); + assert_eq!(definition.layout, dojo::model::Model::::layout()); + assert_eq!(definition.schema, dojo::model::Model::::schema()); + assert_eq!(definition.packed_size, dojo::model::Model::::packed_size()); + assert_eq!(definition.unpacked_size, dojo::meta::introspect::Introspect::::size()); +} + +#[test] +fn test_values() { + let mvalues = FooValue { v1: 3, v2: 4 }; + let expected_values = [3, 4].span(); + + let values = mvalues.values(); + assert!(expected_values == values); +} + +#[test] +fn test_from_values() { + let mut values = [3, 4].span(); + + let model_values: Option = ModelValue::::from_values(1, ref values); + assert!(model_values.is_some()); + let model_values = model_values.unwrap(); + assert!(model_values.v1 == 3 && model_values.v2 == 4); +} + +#[test] +fn test_from_values_bad_data() { + let mut values = [3].span(); + let res: Option = ModelValue::::from_values(1, ref values); + assert!(res.is_none()); +} + +#[test] +fn test_get_and_update_model_value() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + let entity_id = foo.entity_id(); + let mut model_value: FooValue = world.read_model_value(foo.key()); + assert_eq!(model_value.v1, foo.v1); + assert_eq!(model_value.v2, foo.v2); + + model_value.v1 = 12; + model_value.v2 = 18; + + world.write_model_value_from_id(entity_id, @model_value); + + let read_values: FooValue = world.read_model_value(foo.key()); + assert!(read_values.v1 == model_value.v1 && read_values.v2 == model_value.v2); +} + +#[test] +fn test_delete_model_value() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + let entity_id = foo.entity_id(); + ModelStorage::::erase_model(ref world, @foo); + + let read_values: FooValue = world.read_model_value_from_id(entity_id); + assert!(read_values.v1 == 0 && read_values.v2 == 0); +} + +#[test] +fn test_get_and_set_field_name() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + // Inference fails here, we need something better without too generics + // which also fails. + let v1 = world.read_member(foo.key(), selector!("v1")); + assert!(foo.v1 == v1); + + world.write_member_from_id(foo.entity_id(), selector!("v1"), 42); + + let v1 = world.read_member_from_id(foo.key(), selector!("v1")); + assert!(v1 == 42); +} + +#[test] +fn test_get_and_set_from_model() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + let foo2: Foo = world.read_model((foo.k1, foo.k2)); + + assert!(foo.k1 == foo2.k1 && foo.k2 == foo2.k2 && foo.v1 == foo2.v1 && foo.v2 == foo2.v2); +} + +#[test] +fn test_delete_from_model() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + world.erase_model(@foo); + + let foo2: Foo = world.read_model((foo.k1, foo.k2)); + assert!(foo2.k1 == foo.k1 && foo2.k2 == foo.k2 && foo2.v1 == 0 && foo2.v2 == 0); +} + +#[test] +fn test_get_and_set_member_from_model() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + let key: (u8, felt252) = foo.key(); + let v1: u128 = world.read_member(key, selector!("v1")); + + assert!(v1 == 3); + + world.write_member(key, selector!("v1"), 42); + let foo: Foo = world.read_model(key); + assert!(foo.v1 == 42); +} + +#[test] +fn test_get_and_set_field_name_from_model() { + let world = deploy_world(); + world.register_model("dojo", foo::TEST_CLASS_HASH.try_into().unwrap()); + + let mut world = WorldStorageTrait::new(world, "dojo"); + + let foo = Foo { k1: 1, k2: 2, v1: 3, v2: 4 }; + world.write_model(@foo); + + // Currently we don't have automatic field id computation. To be done. + // @remy/@ben. + + let v1 = world.read_member((foo.k1, foo.k2), selector!("v1")); + assert!(v1 == 3); + + world.write_member((foo.k1, foo.k2), selector!("v1"), 42); + assert!(v1 == 42); +} diff --git a/crates/dojo-core/src/tests/storage/database.cairo b/crates/dojo/core-cairo-test/src/tests/storage/database.cairo similarity index 86% rename from crates/dojo-core/src/tests/storage/database.cairo rename to crates/dojo/core-cairo-test/src/tests/storage/database.cairo index c92dbd61e3..ead165696f 100644 --- a/crates/dojo-core/src/tests/storage/database.cairo +++ b/crates/dojo/core-cairo-test/src/tests/storage/database.cairo @@ -1,15 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; -use core::option::OptionTrait; -use core::result::ResultTrait; -use core::serde::Serde; -use core::traits::{Into, TryInto}; -use starknet::class_hash::ClassHash; -use starknet::syscalls::deploy_syscall; - -use dojo::storage::database::{get, set, MAX_ARRAY_LENGTH}; -use dojo::utils::test::assert_array; -use dojo::world::{IWorldDispatcher}; +use dojo::storage::database::{get, set}; #[test] #[available_gas(1000000)] diff --git a/crates/dojo-core/src/tests/storage/packing.cairo b/crates/dojo/core-cairo-test/src/tests/storage/packing.cairo similarity index 99% rename from crates/dojo-core/src/tests/storage/packing.cairo rename to crates/dojo/core-cairo-test/src/tests/storage/packing.cairo index 35b788dc1d..1d2d32c315 100644 --- a/crates/dojo-core/src/tests/storage/packing.cairo +++ b/crates/dojo/core-cairo-test/src/tests/storage/packing.cairo @@ -1,7 +1,6 @@ -use core::array::{ArrayTrait, SpanTrait}; +use core::array::ArrayTrait; use core::option::OptionTrait; use core::traits::{Into, TryInto}; -use starknet::{ClassHash, ContractAddress}; use dojo::storage::packing::{ shl, shr, fpow, pack, unpack, pack_inner, unpack_inner, calculate_packed_size, pow2_const diff --git a/crates/dojo-core/src/tests/storage/storage.cairo b/crates/dojo/core-cairo-test/src/tests/storage/storage.cairo similarity index 99% rename from crates/dojo-core/src/tests/storage/storage.cairo rename to crates/dojo/core-cairo-test/src/tests/storage/storage.cairo index 649a0ddc06..5b6c1bfdac 100644 --- a/crates/dojo-core/src/tests/storage/storage.cairo +++ b/crates/dojo/core-cairo-test/src/tests/storage/storage.cairo @@ -1,6 +1,5 @@ use core::array::ArrayTrait; use core::array::SpanTrait; -use core::traits::Into; use dojo::storage::storage; diff --git a/crates/dojo/core-cairo-test/src/tests/utils/hash.cairo b/crates/dojo/core-cairo-test/src/tests/utils/hash.cairo new file mode 100644 index 0000000000..95c51f7e46 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/utils/hash.cairo @@ -0,0 +1,20 @@ +use dojo::model::Model; +use dojo::utils::{selector_from_names}; + +use crate::tests::helpers::DOJO_NSH; + +#[derive(Drop, Copy, Serde)] +#[dojo::model] +struct MyModel { + #[key] + x: u8, + y: u8 +} + +#[test] +fn test_selector_computation() { + let namespace = "dojo"; + let name = Model::::name(); + let selector = selector_from_names(@namespace, @name); + assert(selector == Model::::selector(DOJO_NSH), 'invalid computed selector'); +} diff --git a/crates/dojo/core-cairo-test/src/tests/utils/key.cairo b/crates/dojo/core-cairo-test/src/tests/utils/key.cairo new file mode 100644 index 0000000000..3ae2ee1f03 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/utils/key.cairo @@ -0,0 +1,14 @@ +use dojo::utils::{entity_id_from_keys, combine_key}; + +#[test] +fn test_entity_id_from_keys() { + let keys = [1, 2, 3].span(); + assert(entity_id_from_keys(keys) == core::poseidon::poseidon_hash_span(keys), 'bad entity ID'); +} + +#[test] +fn test_combine_key() { + assert( + combine_key(1, 2) == core::poseidon::poseidon_hash_span([1, 2].span()), 'combine key error' + ); +} diff --git a/crates/dojo/core-cairo-test/src/tests/utils/layout.cairo b/crates/dojo/core-cairo-test/src/tests/utils/layout.cairo new file mode 100644 index 0000000000..93ee8c4a4e --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/utils/layout.cairo @@ -0,0 +1,64 @@ +use dojo::meta::{FieldLayout, Layout}; +use dojo::utils::{find_field_layout, find_model_field_layout}; + +#[test] +fn test_find_layout_when_exists() { + let layouts = [ + FieldLayout { selector: 'one', layout: Layout::Fixed([1].span()) }, + FieldLayout { selector: 'two', layout: Layout::Fixed([2].span()) }, + FieldLayout { selector: 'three', layout: Layout::Fixed([3].span()) }, + ].span(); + + let res = find_field_layout('two', layouts); + assert(res.is_some(), 'layout not found'); + let res = res.unwrap(); + assert(res == Layout::Fixed([2].span()), 'bad layout'); +} + +#[test] +fn test_find_layout_fails_when_not_exists() { + let layouts = [ + FieldLayout { selector: 'one', layout: Layout::Fixed([1].span()) }, + FieldLayout { selector: 'two', layout: Layout::Fixed([2].span()) }, + FieldLayout { selector: 'three', layout: Layout::Fixed([3].span()) }, + ].span(); + + let res = find_field_layout('four', layouts); + assert(res.is_none(), 'layout found'); +} + +#[test] +fn test_find_model_layout_when_exists() { + let model_layout = Layout::Struct( + [ + FieldLayout { selector: 'one', layout: Layout::Fixed([1].span()) }, + FieldLayout { selector: 'two', layout: Layout::Fixed([2].span()) }, + FieldLayout { selector: 'three', layout: Layout::Fixed([3].span()) }, + ].span() + ); + + let res = find_model_field_layout(model_layout, 'two'); + assert(res.is_some(), 'layout not found'); + let res = res.unwrap(); + assert(res == Layout::Fixed([2].span()), 'bad layout'); +} + +#[test] +fn test_find_model_layout_fails_when_not_exists() { + let model_layout = Layout::Struct( + [ + FieldLayout { selector: 'one', layout: Layout::Fixed([1].span()) }, + FieldLayout { selector: 'two', layout: Layout::Fixed([2].span()) }, + FieldLayout { selector: 'three', layout: Layout::Fixed([3].span()) }, + ].span() + ); + + let res = find_model_field_layout(model_layout, 'four'); + assert(res.is_none(), 'layout found'); +} + +#[test] +#[should_panic(expected: ('Unexpected model layout',))] +fn test_find_model_layout_fails_when_bad_model_layout() { + let _ = find_model_field_layout(Layout::Fixed([].span()), 'one'); +} diff --git a/crates/dojo/core-cairo-test/src/tests/utils/misc.cairo b/crates/dojo/core-cairo-test/src/tests/utils/misc.cairo new file mode 100644 index 0000000000..60973d4d58 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/utils/misc.cairo @@ -0,0 +1,30 @@ +use dojo::utils::{any_none, sum}; + +#[test] +fn test_any_none_when_one_none() { + assert( + any_none(@array![Option::Some(1_u8), Option::Some(2_u8), Option::None, Option::Some(3_u8)]), + 'None not found' + ) +} + +#[test] +fn test_any_none_when_no_none() { + assert( + any_none(@array![Option::Some(1_u8), Option::Some(2_u8), Option::Some(3_u8)]) == false, + 'None found' + ) +} + +#[test] +fn test_sum_when_empty_array() { + assert(sum::(array![]) == 0, 'bad sum'); +} + +#[test] +fn test_sum_when_some_none_and_values() { + assert( + sum::(array![Option::Some(1), Option::None, Option::Some(2), Option::Some(3)]) == 6, + 'bad sum' + ); +} diff --git a/crates/dojo/core-cairo-test/src/tests/utils/naming.cairo b/crates/dojo/core-cairo-test/src/tests/utils/naming.cairo new file mode 100644 index 0000000000..aa3fbab74f --- /dev/null +++ b/crates/dojo/core-cairo-test/src/tests/utils/naming.cairo @@ -0,0 +1,16 @@ +use dojo::utils::is_name_valid; + +#[test] +fn test_with_valid_names() { + assert!(is_name_valid(@"name")); + assert!(is_name_valid(@"NAME")); + assert!(is_name_valid(@"Name123")); + assert!(is_name_valid(@"Name123_")); +} + +#[test] +fn test_with_invalid_names() { + assert!(!is_name_valid(@"n@me")); + assert!(!is_name_valid(@"Name ")); + assert!(!is_name_valid(@"-name")); +} diff --git a/crates/dojo-core/src/tests/world/acl.cairo b/crates/dojo/core-cairo-test/src/tests/world/acl.cairo similarity index 59% rename from crates/dojo-core/src/tests/world/acl.cairo rename to crates/dojo/core-cairo-test/src/tests/world/acl.cairo index 9679f1e58b..62becfe90d 100644 --- a/crates/dojo-core/src/tests/world/acl.cairo +++ b/crates/dojo/core-cairo-test/src/tests/world/acl.cairo @@ -1,18 +1,14 @@ -use starknet::contract_address_const; +use dojo::utils::bytearray_hash; +use dojo::world::IWorldDispatcherTrait; -use dojo::model::Model; -use dojo::utils::{bytearray_hash, entity_id_from_keys}; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, world}; - -use dojo::tests::helpers::{ - deploy_world, Foo, foo, foo_setter, IFooSetterDispatcher, IFooSetterDispatcherTrait +use crate::tests::helpers::{ + deploy_world, foo_setter, IFooSetterDispatcher, IFooSetterDispatcherTrait, deploy_world_and_foo }; +use crate::tests::expanded::selector_attack::{attacker_model, attacker_contract}; #[test] fn test_owner() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -44,16 +40,9 @@ fn test_grant_owner_not_registered_resource() { } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", - 'ENTRYPOINT_FAILED' - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED'))] fn test_grant_owner_through_malicious_contract() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -70,14 +59,12 @@ fn test_grant_owner_through_malicious_contract() { #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", + "Account `659918` does NOT have OWNER role on model (or its namespace) `Foo`", 'ENTRYPOINT_FAILED' ) )] fn test_grant_owner_fails_for_non_owner() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -89,16 +76,9 @@ fn test_grant_owner_fails_for_non_owner() { } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", - 'ENTRYPOINT_FAILED' - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED'))] fn test_revoke_owner_through_malicious_contract() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -116,14 +96,12 @@ fn test_revoke_owner_through_malicious_contract() { #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", + "Account `659918` does NOT have OWNER role on model (or its namespace) `Foo`", 'ENTRYPOINT_FAILED' ) )] fn test_revoke_owner_fails_for_non_owner() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -139,9 +117,7 @@ fn test_revoke_owner_fails_for_non_owner() { #[test] #[available_gas(6000000)] fn test_writer() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); assert(!world.is_writer(foo_selector, 69.try_into().unwrap()), 'should not be writer'); @@ -161,16 +137,9 @@ fn test_writer_not_registered_resource() { } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", - 'ENTRYPOINT_FAILED' - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED'))] fn test_grant_writer_through_malicious_contract() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -187,14 +156,12 @@ fn test_grant_writer_through_malicious_contract() { #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", + "Account `659918` does NOT have OWNER role on model (or its namespace) `Foo`", 'ENTRYPOINT_FAILED' ) )] fn test_grant_writer_fails_for_non_owner() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -206,16 +173,9 @@ fn test_grant_writer_fails_for_non_owner() { } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", - 'ENTRYPOINT_FAILED' - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED'))] fn test_revoke_writer_through_malicious_contract() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); @@ -233,19 +193,17 @@ fn test_revoke_writer_through_malicious_contract() { #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", + "Account `659918` does NOT have OWNER role on model (or its namespace) `Foo`", 'ENTRYPOINT_FAILED' ) )] fn test_revoke_writer_fails_for_non_owner() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let foo_selector = Model::::selector(); + let (world, foo_selector) = deploy_world_and_foo(); let alice = starknet::contract_address_const::<0xa11ce>(); let bob = starknet::contract_address_const::<0xb0b>(); - world.grant_writer(foo_selector, bob); + world.grant_owner(foo_selector, bob); starknet::testing::set_account_contract_address(alice); starknet::testing::set_contract_address(alice); @@ -256,14 +214,13 @@ fn test_revoke_writer_fails_for_non_owner() { #[test] #[should_panic( expected: ( - "Caller `dojo-foo_setter` has no write access on model (or it's namespace) `dojo-Foo`", + "Contract `foo_setter` does NOT have WRITER role on model (or its namespace) `Foo`", 'ENTRYPOINT_FAILED', 'ENTRYPOINT_FAILED' ) )] fn test_not_writer_with_known_contract() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + let (world, _) = deploy_world_and_foo(); let account = starknet::contract_address_const::<0xb0b>(); world.grant_owner(bytearray_hash(@"dojo"), account); @@ -274,7 +231,75 @@ fn test_not_writer_with_known_contract() { starknet::testing::set_contract_address(account); let contract_address = world - .deploy_contract('salt1', foo_setter::TEST_CLASS_HASH.try_into().unwrap()); + .register_contract('salt1', "dojo", foo_setter::TEST_CLASS_HASH.try_into().unwrap()); + let d = IFooSetterDispatcher { contract_address }; d.set_foo(1, 2); + + core::panics::panic_with_byte_array( + @"Contract `dojo-foo_setter` does NOT have WRITER role on model (or its namespace) `Foo`" + ); +} + +/// Test that an attacker can't control the hashes of resources in other namespaces +/// by registering a model in an other namespace. +#[test] +#[should_panic( + expected: ( + "Account `7022365680606078322` does NOT have OWNER role on namespace `dojo`", + 'ENTRYPOINT_FAILED', + ) +)] +fn test_register_model_namespace_not_owner() { + let owner = starknet::contract_address_const::<'owner'>(); + let attacker = starknet::contract_address_const::<'attacker'>(); + + starknet::testing::set_account_contract_address(owner); + starknet::testing::set_contract_address(owner); + + // Owner deploys the world and register Foo model. + let (world, foo_selector) = deploy_world_and_foo(); + + assert(world.is_owner(foo_selector, owner), 'should be owner'); + + starknet::testing::set_contract_address(attacker); + starknet::testing::set_account_contract_address(attacker); + + // Attacker has control over the this namespace. + world.register_namespace("atk"); + + // Attacker can't take ownership of the Foo model in the dojo namespace. + world.register_model("dojo", attacker_model::TEST_CLASS_HASH.try_into().unwrap()); +} + +/// Test that an attacker can't control the hashes of resources in other namespaces +/// by deploying a contract in an other namespace. +#[test] +#[should_panic( + expected: ( + "Account `7022365680606078322` does NOT have OWNER role on namespace `dojo`", + 'ENTRYPOINT_FAILED', + ) +)] +fn test_register_contract_namespace_not_owner() { + let owner = starknet::contract_address_const::<'owner'>(); + let attacker = starknet::contract_address_const::<'attacker'>(); + + starknet::testing::set_account_contract_address(owner); + starknet::testing::set_contract_address(owner); + + // Owner deploys the world and register Foo model. + let (world, foo_selector) = deploy_world_and_foo(); + + assert(world.is_owner(foo_selector, owner), 'should be owner'); + + starknet::testing::set_contract_address(attacker); + starknet::testing::set_account_contract_address(attacker); + + // Attacker has control over the this namespace. + world.register_namespace("atk"); + + // Attacker can't take ownership of the Foo model. + world + .register_contract('salt1', "dojo", attacker_contract::TEST_CLASS_HASH.try_into().unwrap()); } diff --git a/crates/dojo-core/src/tests/world/entities.cairo b/crates/dojo/core-cairo-test/src/tests/world/entities.cairo similarity index 94% rename from crates/dojo-core/src/tests/world/entities.cairo rename to crates/dojo/core-cairo-test/src/tests/world/entities.cairo index 599ccb7631..c40bc84ecf 100644 --- a/crates/dojo-core/src/tests/world/entities.cairo +++ b/crates/dojo/core-cairo-test/src/tests/world/entities.cairo @@ -1,12 +1,13 @@ -use core::array::{ArrayTrait, SpanTrait}; +use core::array::SpanTrait; -use starknet::{contract_address_const, ContractAddress}; +use starknet::ContractAddress; -use dojo::model::{ModelIndex, Layout, FieldLayout, Model}; -use dojo::model::introspect::Introspect; +use dojo::meta::introspect::Introspect; +use dojo::meta::Layout; +use dojo::model::{ModelIndex, Model}; use dojo::storage::database::MAX_ARRAY_LENGTH; use dojo::utils::entity_id_from_keys; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, world}; +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; use dojo::tests::helpers::{ deploy_world, deploy_world_and_bar, IbarDispatcher, IbarDispatcherTrait, Foo, foo, bar @@ -455,7 +456,7 @@ fn test_delete_entity_by_id() { world.set_entity(selector, ModelIndex::Id(entity_id), values, layout); - world.delete_entity(selector, ModelIndex::Id(entity_id), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Id(entity_id), layout); let read_values = world.entity(selector, ModelIndex::Id(entity_id), layout); @@ -474,7 +475,7 @@ fn test_delete_entity_with_fixed_layout() { world.set_entity(selector, ModelIndex::Keys(get_key_test()), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -494,7 +495,7 @@ fn test_delete_entity_with_simple_struct_layout() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -514,7 +515,7 @@ fn test_delete_entity_with_struct_simple_array_layout() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -538,7 +539,7 @@ fn test_delete_entity_with_complex_array_struct_layout() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -561,7 +562,7 @@ fn test_delete_entity_with_struct_tuple_layout() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let expected_values = [0, 0].span(); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -583,7 +584,7 @@ fn test_delete_entity_with_struct_enum_layout() { // test with the first variant world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let expected_values = [0, 0, 0].span(); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -604,7 +605,7 @@ fn test_delete_entity_with_struct_layout_and_byte_array() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let expected_values = [0, 0, 0, 0].span(); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -625,7 +626,7 @@ fn test_delete_entity_with_nested_elements() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let expected_values = [0, 0, 0, 0, 0, 0, 0, 0, 0].span(); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -646,7 +647,7 @@ fn test_delete_entity_with_struct_generics_enum_layout() { world.set_entity(selector, ModelIndex::Keys(keys), values, layout); - world.delete_entity(selector, ModelIndex::Keys(keys), layout); + IWorldDispatcherTrait::delete_entity(world, selector, ModelIndex::Keys(keys), layout); let expected_values = [0, 0].span(); let read_values = world.entity(selector, ModelIndex::Keys(keys), layout); @@ -696,11 +697,9 @@ fn test_delete_entity_with_unexpected_array_model_layout() { world.register_model(struct_simple_array_model::TEST_CLASS_HASH.try_into().unwrap()); let layout = Layout::Array([Introspect::::layout()].span()); - - world - .delete_entity( - Model::::selector(), ModelIndex::Keys([].span()), layout - ); + IWorldDispatcherTrait::delete_entity( + world, Model::::selector(), ModelIndex::Keys([].span()), layout + ); } #[test] @@ -711,10 +710,9 @@ fn test_delete_entity_with_unexpected_tuple_model_layout() { let layout = Layout::Tuple([Introspect::::layout()].span()); - world - .delete_entity( - Model::::selector(), ModelIndex::Keys([].span()), layout - ); + IWorldDispatcherTrait::delete_entity( + world, Model::::selector(), ModelIndex::Keys([].span()), layout + ); } #[test] diff --git a/crates/dojo-core/src/tests/world/resources.cairo b/crates/dojo/core-cairo-test/src/tests/world/resources.cairo similarity index 70% rename from crates/dojo-core/src/tests/world/resources.cairo rename to crates/dojo/core-cairo-test/src/tests/world/resources.cairo index f553085026..e3f3a79097 100644 --- a/crates/dojo-core/src/tests/world/resources.cairo +++ b/crates/dojo/core-cairo-test/src/tests/world/resources.cairo @@ -1,16 +1,14 @@ -use starknet::{contract_address_const, ContractAddress, ClassHash}; +use starknet::ContractAddress; use dojo::model::{Model, ResourceMetadata}; -use dojo::utils::{bytearray_hash, entity_id_from_keys}; -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, world}; -use dojo::world::world::{ - NamespaceRegistered, ModelRegistered, ModelUpgraded, MetadataUpdate, ContractDeployed, - ContractUpgraded -}; +use dojo::utils::bytearray_hash; +use dojo::world::IWorldDispatcherTrait; +use dojo::world::world::{Event}; use dojo::contract::{IContractDispatcher, IContractDispatcherTrait}; use dojo::tests::helpers::{ - deploy_world, drop_all_events, Foo, foo, Buzz, buzz, test_contract, buzz_contract + deploy_world, drop_all_events, Foo, foo, foo_invalid_name, foo_invalid_namespace, buzz, + test_contract, buzz_contract }; use dojo::utils::test::spawn_test_world; @@ -49,16 +47,19 @@ fn test_set_metadata_resource_owner() { world.set_metadata(metadata.clone()); assert(world.metadata(Model::::selector()) == metadata, 'bad metadata'); - assert_eq!( - starknet::testing::pop_log(world.contract_address), - Option::Some(MetadataUpdate { resource: metadata.resource_id, uri: metadata.metadata_uri }) - ); + match starknet::testing::pop_log::(world.contract_address).unwrap() { + Event::MetadataUpdate(event) => { + assert(event.resource == metadata.resource_id, 'bad resource'); + assert(event.uri == metadata.metadata_uri, 'bad uri'); + }, + _ => panic!("no MetadataUpdate event"), + } } #[test] #[should_panic( expected: ( - "Caller `2827` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", + "Account `2827` does NOT have OWNER role on model (or its namespace) `dojo-Foo`", 'ENTRYPOINT_FAILED', ) )] @@ -81,7 +82,7 @@ fn test_set_metadata_not_possible_for_resource_writer() { #[test] #[should_panic( - expected: ("Caller `2827` is not the owner of the resource `0`", 'ENTRYPOINT_FAILED',) + expected: ("Account `2827` does NOT have OWNER role on world", 'ENTRYPOINT_FAILED',) )] fn test_set_metadata_not_possible_for_random_account() { let world = deploy_world(); @@ -100,12 +101,7 @@ fn test_set_metadata_not_possible_for_random_account() { } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883`", - 'ENTRYPOINT_FAILED', - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED',))] fn test_set_metadata_through_malicious_contract() { let world = spawn_test_world(["dojo"].span(), [foo::TEST_CLASS_HASH].span(),); @@ -137,22 +133,30 @@ fn test_register_model_for_namespace_owner() { starknet::testing::set_contract_address(bob); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let event = starknet::testing::pop_log::(world.contract_address); - - assert(event.is_some(), 'no ModelRegistered event'); - let event = event.unwrap(); - assert(event.name == Model::::name(), 'bad model name'); - assert(event.namespace == Model::::namespace(), 'bad model namespace'); - assert(event.class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'bad model class_hash'); - assert( - event.address != core::num::traits::Zero::::zero(), - 'bad model prev address' - ); + let event = starknet::testing::pop_log::(world.contract_address); + assert(event.is_some(), 'no event)'); + + if let Event::ModelRegistered(event) = event.unwrap() { + assert(event.name == Model::::name(), 'bad model name'); + assert(event.namespace == Model::::namespace(), 'bad model namespace'); + assert( + event.class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'bad model class_hash' + ); + assert( + event.address != core::num::traits::Zero::::zero(), + 'bad model prev address' + ); + } else { + core::panic_with_felt252('no ModelRegistered event'); + } assert(world.is_owner(Model::::selector(), bob), 'bob is not the owner'); } #[test] +#[should_panic( + expected: ("Account `2827` does NOT have OWNER role on namespace `dojo`", 'ENTRYPOINT_FAILED',) +)] fn test_register_model_for_namespace_writer() { let bob = starknet::contract_address_const::<0xb0b>(); @@ -164,20 +168,30 @@ fn test_register_model_for_namespace_writer() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); +} - let event = starknet::testing::pop_log::(world.contract_address); - - assert(event.is_some(), 'no ModelRegistered event'); - let event = event.unwrap(); - assert(event.name == Model::::name(), 'bad model name'); - assert(event.namespace == Model::::namespace(), 'bad model namespace'); - assert(event.class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'bad model class_hash'); - assert( - event.address != core::num::traits::Zero::::zero(), - 'bad model prev address' - ); +#[test] +#[should_panic( + expected: ( + "Name `foo-bis` is invalid according to Dojo naming rules: ^[a-zA-Z0-9_]+$", + 'ENTRYPOINT_FAILED', + ) +)] +fn test_register_model_with_invalid_name() { + let world = deploy_world(); + world.register_model(foo_invalid_name::TEST_CLASS_HASH.try_into().unwrap()); +} - assert(world.is_owner(Model::::selector(), bob), 'bob is not the owner'); +#[test] +#[should_panic( + expected: ( + "Namespace `inv@lid n@mesp@ce` is invalid according to Dojo naming rules: ^[a-zA-Z0-9_]+$", + 'ENTRYPOINT_FAILED', + ) +)] +fn test_register_model_with_invalid_namespace() { + let world = deploy_world(); + world.register_model(foo_invalid_namespace::TEST_CLASS_HASH.try_into().unwrap()); } #[test] @@ -195,17 +209,22 @@ fn test_upgrade_model_from_model_owner() { world.upgrade_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let event = starknet::testing::pop_log::(world.contract_address); + let event = starknet::testing::pop_log::(world.contract_address); + assert(event.is_some(), 'no event)'); - assert(event.is_some(), 'no ModelRegistered event'); - let event = event.unwrap(); - assert(event.name == Model::::name(), 'bad model name'); - assert(event.namespace == Model::::namespace(), 'bad model namespace'); - assert(event.class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'bad model class_hash'); - assert( - event.address != core::num::traits::Zero::::zero(), - 'bad model prev address' - ); + if let Event::ModelUpgraded(event) = event.unwrap() { + assert(event.selector == Model::::selector(), 'bad model selector'); + assert( + event.class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'bad model class_hash' + ); + + assert( + event.address != core::num::traits::Zero::::zero(), + 'bad model prev address' + ); + } else { + core::panic_with_felt252('no ModelRegistered event'); + } assert(world.is_owner(Model::::selector(), bob), 'bob is not the owner'); } @@ -213,8 +232,7 @@ fn test_upgrade_model_from_model_owner() { #[test] #[should_panic( expected: ( - "Caller `2827` cannot upgrade the resource `3123252206139358744730647958636922105676576163624049771737508399526017186883` (not owner)", - 'ENTRYPOINT_FAILED', + "Account `659918` does NOT have OWNER role on namespace `dojo`", 'ENTRYPOINT_FAILED', ) )] fn test_upgrade_model_from_model_writer() { @@ -243,8 +261,8 @@ fn test_upgrade_model_from_random_account() { let alice = starknet::contract_address_const::<0xa11ce>(); let world = deploy_world(); - world.grant_writer(Model::::namespace_hash(), bob); - world.grant_writer(Model::::namespace_hash(), alice); + world.grant_owner(Model::::namespace_hash(), bob); + world.grant_owner(Model::::namespace_hash(), alice); starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); @@ -291,14 +309,17 @@ fn test_register_namespace() { let namespace = "namespace"; let hash = bytearray_hash(@namespace); - world.register_namespace(namespace); + world.register_namespace(namespace.clone()); assert(world.is_owner(hash, bob), 'namespace not registered'); - assert_eq!( - starknet::testing::pop_log(world.contract_address), - Option::Some(NamespaceRegistered { namespace: "namespace", hash }) - ); + match starknet::testing::pop_log::(world.contract_address).unwrap() { + Event::NamespaceRegistered(event) => { + assert(event.namespace == namespace, 'bad namespace'); + assert(event.hash == hash, 'bad hash'); + }, + _ => panic!("no NamespaceRegistered event"), + } } #[test] @@ -346,22 +367,27 @@ fn test_deploy_contract_for_namespace_owner() { drop_all_events(world.contract_address); - let contract_address = world.deploy_contract('salt1', class_hash); + let contract_address = world.register_contract('salt1', class_hash); + + let event = match starknet::testing::pop_log::(world.contract_address).unwrap() { + Event::ContractRegistered(event) => event, + _ => panic!("no ContractRegistered event"), + }; + let dispatcher = IContractDispatcher { contract_address }; - let event = starknet::testing::pop_log::(world.contract_address); - assert(event.is_some(), 'no ContractDeployed event'); - let event = event.unwrap(); assert(event.salt == 'salt1', 'bad event salt'); assert(event.class_hash == class_hash, 'bad class_hash'); - assert(event.name == dispatcher.name(), 'bad contract name'); - assert(event.namespace == dispatcher.namespace(), 'bad namespace'); + assert(event.selector == dispatcher.selector(), 'bad contract selector'); assert( event.address != core::num::traits::Zero::::zero(), 'bad contract address' ); } #[test] +#[should_panic( + expected: ("Account `2827` does NOT have OWNER role on namespace `dojo`", 'ENTRYPOINT_FAILED',) +)] fn test_deploy_contract_for_namespace_writer() { let world = deploy_world(); @@ -373,29 +399,29 @@ fn test_deploy_contract_for_namespace_writer() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); - world.deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); + world.register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); } #[test] #[should_panic( - expected: ("Caller `2827` has no write access on namespace `dojo`", 'ENTRYPOINT_FAILED',) + expected: ("Account `2827` does NOT have OWNER role on namespace `dojo`", 'ENTRYPOINT_FAILED',) )] -fn test_deploy_contract_no_namespace_write_access() { +fn test_deploy_contract_no_namespace_owner_access() { let world = deploy_world(); let bob = starknet::contract_address_const::<0xb0b>(); starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); - world.deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); + world.register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); } #[test] #[should_panic(expected: ("Namespace `buzz_namespace` is not registered", 'ENTRYPOINT_FAILED',))] fn test_deploy_contract_with_unregistered_namespace() { let world = deploy_world(); - world.deploy_contract('salt1', buzz_contract::TEST_CLASS_HASH.try_into().unwrap(),); + world.register_contract('salt1', buzz_contract::TEST_CLASS_HASH.try_into().unwrap()); } // It's CONTRACT_NOT_DEPLOYED for now as in this example the contract is not a dojo contract @@ -414,7 +440,7 @@ fn test_deploy_contract_through_malicious_contract() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(malicious_contract); - world.deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); + world.register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); } #[test] @@ -429,27 +455,28 @@ fn test_upgrade_contract_from_resource_owner() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); - let contract_address = world.deploy_contract('salt1', class_hash); - + let contract_address = world.register_contract('salt1', class_hash); let dispatcher = IContractDispatcher { contract_address }; drop_all_events(world.contract_address); - world.upgrade_contract(dispatcher.selector(), class_hash); + world.upgrade_contract(class_hash); - let event = starknet::testing::pop_log::(world.contract_address); - assert(event.is_some(), 'no ContractUpgraded event'); - let event = event.unwrap(); - assert(event.class_hash == class_hash, 'bad class_hash'); - assert( - event.address != core::num::traits::Zero::::zero(), 'bad contract address' - ); + let event = starknet::testing::pop_log::(world.contract_address); + assert(event.is_some(), 'no event)'); + + if let Event::ContractUpgraded(event) = event.unwrap() { + assert(event.selector == dispatcher.selector(), 'bad contract selector'); + assert(event.class_hash == class_hash, 'bad class_hash'); + } else { + core::panic_with_felt252('no ContractUpgraded event'); + }; } #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `2368393732245529956313345237151518608283468650081902115301417183793437311044`", + "Account `659918` does NOT have OWNER role on contract (or its namespace) `dojo-test_contract`", 'ENTRYPOINT_FAILED', ) )] @@ -465,7 +492,7 @@ fn test_upgrade_contract_from_resource_writer() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); - let contract_address = world.deploy_contract('salt1', class_hash); + let contract_address = world.register_contract('salt1', class_hash); let dispatcher = IContractDispatcher { contract_address }; @@ -474,13 +501,13 @@ fn test_upgrade_contract_from_resource_writer() { starknet::testing::set_account_contract_address(alice); starknet::testing::set_contract_address(alice); - world.upgrade_contract(dispatcher.selector(), class_hash); + world.upgrade_contract(class_hash); } #[test] #[should_panic( expected: ( - "Caller `659918` is not the owner of the resource `2368393732245529956313345237151518608283468650081902115301417183793437311044`", + "Account `659918` does NOT have OWNER role on contract (or its namespace) `dojo-test_contract`", 'ENTRYPOINT_FAILED', ) )] @@ -488,24 +515,18 @@ fn test_upgrade_contract_from_random_account() { let world = deploy_world(); let class_hash = test_contract::TEST_CLASS_HASH.try_into().unwrap(); - let contract_address = world.deploy_contract('salt1', class_hash); + let _contract_address = world.register_contract('salt1', class_hash); let alice = starknet::contract_address_const::<0xa11ce>(); - let dispatcher = IContractDispatcher { contract_address }; starknet::testing::set_account_contract_address(alice); starknet::testing::set_contract_address(alice); - world.upgrade_contract(dispatcher.selector(), class_hash); + world.upgrade_contract(class_hash); } #[test] -#[should_panic( - expected: ( - "Caller `57005` is not the owner of the resource `2368393732245529956313345237151518608283468650081902115301417183793437311044`", - 'ENTRYPOINT_FAILED', - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED',))] fn test_upgrade_contract_through_malicious_contract() { let world = deploy_world(); let class_hash = test_contract::TEST_CLASS_HASH.try_into().unwrap(); @@ -518,11 +539,9 @@ fn test_upgrade_contract_through_malicious_contract() { starknet::testing::set_account_contract_address(bob); starknet::testing::set_contract_address(bob); - let contract_address = world.deploy_contract('salt1', class_hash); - - let dispatcher = IContractDispatcher { contract_address }; + let _contract_address = world.register_contract('salt1', class_hash); starknet::testing::set_contract_address(malicious_contract); - world.upgrade_contract(dispatcher.selector(), class_hash); + world.upgrade_contract(class_hash); } diff --git a/crates/dojo-core/src/tests/world/world.cairo b/crates/dojo/core-cairo-test/src/tests/world/world.cairo similarity index 62% rename from crates/dojo-core/src/tests/world/world.cairo rename to crates/dojo/core-cairo-test/src/tests/world/world.cairo index 5ee498982b..f8c80333cb 100644 --- a/crates/dojo-core/src/tests/world/world.cairo +++ b/crates/dojo/core-cairo-test/src/tests/world/world.cairo @@ -1,17 +1,15 @@ -use starknet::{contract_address_const, ContractAddress, get_caller_address}; - use dojo::world::Resource; -use dojo::world::config::Config::{DifferProgramHashUpdate, FactsRegistryUpdate}; -use dojo::world::config::{IConfigDispatcher, IConfigDispatcherTrait}; -use dojo::model::{Model, ResourceMetadata}; +use dojo::world::world::Event; +use dojo::model::Model; use dojo::utils::bytearray_hash; use dojo::world::{ - IWorldDispatcher, IWorldDispatcherTrait, world, IUpgradeableWorld, IUpgradeableWorldDispatcher, + IWorldDispatcher, IWorldDispatcherTrait, IUpgradeableWorldDispatcher, IUpgradeableWorldDispatcherTrait }; use dojo::tests::helpers::{ IbarDispatcher, IbarDispatcherTrait, drop_all_events, deploy_world_and_bar, Foo, foo, bar, - Character, character, test_contract, test_contract_with_dojo_init_args + Character, character, test_contract, test_contract_with_dojo_init_args, SimpleEvent, + simple_event, SimpleEventEmitter }; use dojo::utils::test::{spawn_test_world, deploy_with_world_address, GasCounterTrait}; @@ -25,7 +23,7 @@ trait IMetadataOnly { #[starknet::contract] mod resource_metadata_malicious { - use dojo::model::{Model, ResourceMetadata}; + use dojo::model::{ModelDefinition, ResourceMetadata}; use dojo::utils::bytearray_hash; #[storage] @@ -34,7 +32,7 @@ mod resource_metadata_malicious { #[abi(embed_v0)] impl InvalidModelName of super::IMetadataOnly { fn selector(self: @ContractState) -> felt252 { - Model::::selector() + ModelDefinition::::selector() } fn namespace(self: @ContractState) -> ByteArray { @@ -52,7 +50,7 @@ mod resource_metadata_malicious { } #[test] -#[available_gas(2000000)] +#[available_gas(20000000)] fn test_model() { let world = deploy_world(); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); @@ -64,7 +62,7 @@ fn test_system() { bar_contract.set_foo(1337, 1337); - let stored: Foo = get!(world, get_caller_address(), Foo); + let stored: Foo = get!(world, starknet::get_caller_address(), Foo); assert(stored.a == 1337, 'data not stored'); assert(stored.b == 1337, 'data not stored'); } @@ -75,14 +73,14 @@ fn test_delete() { // set model bar_contract.set_foo(1337, 1337); - let stored: Foo = get!(world, get_caller_address(), Foo); + let stored: Foo = get!(world, starknet::get_caller_address(), Foo); assert(stored.a == 1337, 'data not stored'); assert(stored.b == 1337, 'data not stored'); // delete model bar_contract.delete_foo_macro(stored); - let deleted: Foo = get!(world, get_caller_address(), Foo); + let deleted: Foo = get!(world, starknet::get_caller_address(), Foo); assert(deleted.a == 0, 'data not deleted'); assert(deleted.b == 0, 'data not deleted'); } @@ -92,55 +90,49 @@ fn test_delete() { fn test_contract_getter() { let world = deploy_world(); - let _ = world.deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(),); + let address = world + .register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); - if let Resource::Contract((class_hash, _)) = world + if let Resource::Contract((contract_address, namespace_hash)) = world .resource(selector_from_tag!("dojo-test_contract")) { - assert( - class_hash == test_contract::TEST_CLASS_HASH.try_into().unwrap(), - 'invalid contract class hash' - ); + assert(address == contract_address, 'invalid contract address'); + + assert(namespace_hash == bytearray_hash(@"dojo"), 'invalid namespace hash'); } } #[test] #[available_gas(6000000)] -fn test_model_class_hash_getter() { +fn test_emit() { + let bob = starknet::contract_address_const::<0xb0b>(); + let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + world.register_event(simple_event::TEST_CLASS_HASH.try_into().unwrap()); + world.grant_writer(dojo::event::Event::::selector(), bob); - if let Resource::Model((class_hash, _)) = world.resource(Model::::selector()) { - assert(class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'foo wrong class hash'); - } else { - panic!("Foo model not found"); - }; -} + drop_all_events(world.contract_address); -#[test] -#[ignore] -#[available_gas(6000000)] -fn test_legacy_model_class_hash_getter() { - let world = deploy_world(); - world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + starknet::testing::set_contract_address(bob); - if let Resource::Model((class_hash, _)) = world.resource('Foo') { - assert(class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'foo wrong class hash'); - } else { - panic!("Foo model not found"); - }; -} + let simple_event = SimpleEvent { id: 2, data: (3, 4) }; + simple_event.emit(world); -#[test] -#[available_gas(6000000)] -fn test_emit() { - let world = deploy_world(); + let event = starknet::testing::pop_log::(world.contract_address); + + assert(event.is_some(), 'no event'); - let mut keys = ArrayTrait::new(); - keys.append('MyEvent'); - let mut values = ArrayTrait::new(); - values.append(1); - values.append(2); - world.emit(keys, values.span()); + if let Event::EventEmitted(event) = event.unwrap() { + assert( + event.event_selector == dojo::event::Event::::selector(), + 'bad event selector' + ); + assert(event.system_address == bob, 'bad system address'); + assert(event.historical, 'bad historical value'); + assert(event.keys == [2].span(), 'bad keys'); + assert(event.values == [3, 4].span(), 'bad values'); + } else { + core::panic_with_felt252('no EventEmitted event'); + } } @@ -231,8 +223,7 @@ trait IWorldUpgrade { #[starknet::contract] mod worldupgrade { - use super::{IWorldUpgrade, IWorldDispatcher, ContractAddress}; - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + use super::IWorldDispatcher; #[storage] struct Storage { @@ -300,68 +291,48 @@ fn test_upgradeable_world_from_non_owner() { upgradeable_world_dispatcher.upgrade(worldupgrade::TEST_CLASS_HASH.try_into().unwrap()); } - #[test] #[available_gas(6000000)] -fn test_differ_program_hash_event_emit() { +fn test_constructor_default() { let world = deploy_world(); - drop_all_events(world.contract_address); - let config = IConfigDispatcher { contract_address: world.contract_address }; - - config.set_differ_program_hash(program_hash: 98758347158781475198374598718743); - - assert_eq!( - starknet::testing::pop_log(world.contract_address), - Option::Some(DifferProgramHashUpdate { program_hash: 98758347158781475198374598718743 }) - ); + let _address = world + .register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); } #[test] -#[available_gas(6000000)] -fn test_facts_registry_event_emit() { +fn test_can_call_init_only_world() { let world = deploy_world(); - drop_all_events(world.contract_address); - let config = IConfigDispatcher { contract_address: world.contract_address }; + let address = world + .register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); - config.set_facts_registry(contract_address_const::<0x12>()); + let expected_panic: ByteArray = + "Only the world can init contract `dojo-test_contract`, but caller is `0`"; - assert_eq!( - starknet::testing::pop_log(world.contract_address), - Option::Some(FactsRegistryUpdate { address: contract_address_const::<0x12>() }) - ); -} + match starknet::syscalls::call_contract_syscall( + address, dojo::world::world::DOJO_INIT_SELECTOR, [].span() + ) { + Result::Ok(_) => panic!("should panic"), + Result::Err(e) => { + let mut s = e.span(); + // Remove the out of range error. + s.pop_front().unwrap(); + // Remove the ENTRYPOINT_FAILED suffix. + s.pop_back().unwrap(); -use test_contract::IDojoInitDispatcherTrait; - -#[test] -#[available_gas(6000000)] -#[should_panic( - expected: ( - "Only the world can init contract `dojo-test_contract`, but caller is `0`", - 'ENTRYPOINT_FAILED' - ) -)] -fn test_can_call_init_only_world() { - let world = deploy_world(); - let address = world - .deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); + let e_str: ByteArray = Serde::deserialize(ref s).expect('failed deser'); - let d = test_contract::IDojoInitDispatcher { contract_address: address }; - d.dojo_init(); + assert_eq!(e_str, expected_panic); + } + } } #[test] #[available_gas(6000000)] -#[should_panic( - expected: ( - "Caller `4919` cannot initialize contract `dojo-test_contract` (not owner)", - 'ENTRYPOINT_FAILED' - ) -)] +#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', 'ENTRYPOINT_FAILED'))] fn test_can_call_init_only_owner() { let world = deploy_world(); let _address = world - .deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); + .register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); let bob = starknet::contract_address_const::<0x1337>(); starknet::testing::set_contract_address(bob); @@ -374,7 +345,7 @@ fn test_can_call_init_only_owner() { fn test_can_call_init_default() { let world = deploy_world(); let _address = world - .deploy_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); + .register_contract('salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap()); world.init_contract(selector_from_tag!("dojo-test_contract"), [].span()); } @@ -384,61 +355,38 @@ fn test_can_call_init_default() { fn test_can_call_init_args() { let world = deploy_world(); let _address = world - .deploy_contract( + .register_contract( 'salt1', test_contract_with_dojo_init_args::TEST_CLASS_HASH.try_into().unwrap() ); world.init_contract(selector_from_tag!("dojo-test_contract_with_dojo_init_args"), [1].span()); } -use test_contract_with_dojo_init_args::IDojoInitDispatcherTrait as IDojoInitArgs; - #[test] -#[available_gas(6000000)] -#[should_panic( - expected: ( - "Only the world can init contract `dojo-test_contract_with_dojo_init_args`, but caller is `0`", - 'ENTRYPOINT_FAILED' - ) -)] fn test_can_call_init_only_world_args() { let world = deploy_world(); let address = world - .deploy_contract( + .register_contract( 'salt1', test_contract_with_dojo_init_args::TEST_CLASS_HASH.try_into().unwrap() ); - let d = test_contract_with_dojo_init_args::IDojoInitDispatcher { contract_address: address }; - d.dojo_init(123); -} + let expected_panic: ByteArray = + "Only the world can init contract `dojo-test_contract_with_dojo_init_args`, but caller is `0`"; -use dojo::world::update::IUpgradeableStateDispatcherTrait; + match starknet::syscalls::call_contract_syscall( + address, dojo::world::world::DOJO_INIT_SELECTOR, [123].span() + ) { + Result::Ok(_) => panic!("should panic"), + Result::Err(e) => { + let mut s = e.span(); + // Remove the out of range error. + s.pop_front().unwrap(); + // Remove the ENTRYPOINT_FAILED suffix. + s.pop_back().unwrap(); -#[test] -#[available_gas(6000000)] -#[should_panic( - expected: ("Caller `4919` can't upgrade state (not world owner)", 'ENTRYPOINT_FAILED') -)] -fn test_upgrade_state_not_owner() { - let world = deploy_world(); + let e_str: ByteArray = Serde::deserialize(ref s).expect('failed deser'); - let not_owner = starknet::contract_address_const::<0x1337>(); - starknet::testing::set_contract_address(not_owner); - starknet::testing::set_account_contract_address(not_owner); - - let output = dojo::world::update::ProgramOutput { - prev_state_root: 0, - new_state_root: 0, - block_number: 0, - block_hash: 0, - config_hash: 0, - world_da_hash: 0, - message_to_starknet_segment: [].span(), - message_to_appchain_segment: [].span(), - }; - - let d = dojo::world::update::IUpgradeableStateDispatcher { - contract_address: world.contract_address - }; - d.upgrade_state([].span(), output, 0); + assert_eq!(e_str, expected_panic); + } + } } diff --git a/crates/dojo/core-cairo-test/src/utils.cairo b/crates/dojo/core-cairo-test/src/utils.cairo new file mode 100644 index 0000000000..051be84e2a --- /dev/null +++ b/crates/dojo/core-cairo-test/src/utils.cairo @@ -0,0 +1,57 @@ +#[derive(Drop)] +pub struct GasCounter { + pub start: u128, +} + +#[generate_trait] +pub impl GasCounterImpl of GasCounterTrait { + fn start() -> GasCounter { + let start = core::testing::get_available_gas(); + core::gas::withdraw_gas().unwrap(); + GasCounter { start } + } + + fn end(self: GasCounter, name: ByteArray) { + let end = core::testing::get_available_gas(); + let gas_used = self.start - end; + + println!("# GAS # {}: {}", Self::pad_start(name, 18), gas_used); + core::gas::withdraw_gas().unwrap(); + } + + fn pad_start(str: ByteArray, len: u32) -> ByteArray { + let mut missing: ByteArray = ""; + let missing_len = if str.len() >= len { + 0 + } else { + len - str.len() + }; + + while missing.len() < missing_len { + missing.append(@"."); + }; + missing + str + } +} + +// assert that `value` and `expected` have the same size and the same content +pub fn assert_array(value: Span, expected: Span) { + assert!(value.len() == expected.len(), "Bad array length"); + + let mut i = 0; + loop { + if i >= value.len() { + break; + } + + assert!( + *value.at(i) == *expected.at(i), + "Bad array value [{}] (expected: {} got: {})", + i, + *expected.at(i), + *value.at(i) + ); + + i += 1; + } +} diff --git a/crates/dojo/core-cairo-test/src/world.cairo b/crates/dojo/core-cairo-test/src/world.cairo new file mode 100644 index 0000000000..0b8449d959 --- /dev/null +++ b/crates/dojo/core-cairo-test/src/world.cairo @@ -0,0 +1,158 @@ +use core::option::OptionTrait; +use core::result::ResultTrait; +use core::traits::{Into, TryInto}; + +use starknet::{ContractAddress, ClassHash, syscalls::deploy_syscall}; + +use dojo::world::{world, IWorldDispatcher, IWorldDispatcherTrait, WorldStorageTrait, WorldStorage}; + +/// In Cairo test runner, all the classes are expected to be declared already. +/// If a contract belong to an other crate, it must be added to the `build-external-contract`, +/// event for testing, since Scarb does not do that automatically anymore. +#[derive(Drop)] +pub enum TestResource { + Event: ClassHash, + Model: ClassHash, + Contract: ContractDef, +} + +#[derive(Drop)] +pub struct NamespaceDef { + pub namespace: ByteArray, + pub resources: Span, +} + +#[derive(Drop)] +pub struct ContractDef { + /// Class hash, use `felt252` instead of `ClassHash` as TEST_CLASS_HASH is a `felt252`. + pub class_hash: felt252, + /// Name of the contract. + pub name: ByteArray, + /// Calldata for dojo_init. + pub init_calldata: Span, + /// Selectors of the resources that the contract is granted writer access to. + pub writer_of: Span, + /// Selector of the resource that the contract is the owner of. + pub owner_of: Span, +} + +#[generate_trait] +pub impl ContractDefImpl of ContractDefTrait { + fn new(class_hash: felt252, name: ByteArray) -> ContractDef { + ContractDef { + class_hash, name, init_calldata: [].span(), writer_of: [].span(), owner_of: [].span() + } + } + + fn with_init_calldata(mut self: ContractDef, init_calldata: Span) -> ContractDef { + self.init_calldata = init_calldata; + self + } + + fn with_writer_of(mut self: ContractDef, writer_of: Span) -> ContractDef { + self.writer_of = writer_of; + self + } + + fn with_owner_of(mut self: ContractDef, owner_of: Span) -> ContractDef { + self.owner_of = owner_of; + self + } +} + +/// Deploy classhash with calldata for constructor +/// +/// # Arguments +/// +/// * `class_hash` - Class to deploy +/// * `calldata` - calldata for constructor +/// +/// # Returns +/// * address of contract deployed +pub fn deploy_contract(class_hash: felt252, calldata: Span) -> ContractAddress { + let (contract, _) = starknet::syscalls::deploy_syscall( + class_hash.try_into().unwrap(), 0, calldata, false + ) + .unwrap(); + contract +} + +/// Deploy classhash and passes in world address to constructor +/// +/// # Arguments +/// +/// * `class_hash` - Class to deploy +/// * `world` - World dispatcher to pass as world address +/// +/// # Returns +/// * address of contract deployed +pub fn deploy_with_world_address(class_hash: felt252, world: IWorldDispatcher) -> ContractAddress { + deploy_contract(class_hash, [world.contract_address.into()].span()) +} + +/// Spawns a test world registering provided resources into namespaces. +/// +/// # Arguments +/// +/// * `namespaces_defs` - Definitions of namespaces to register. +/// +/// # Returns +/// +/// * World dispatcher +pub fn spawn_test_world(namespaces_defs: Span) -> WorldStorage { + let salt = core::testing::get_available_gas(); + + let (world_address, _) = deploy_syscall( + world::TEST_CLASS_HASH.try_into().unwrap(), + salt.into(), + [world::TEST_CLASS_HASH].span(), + false + ) + .unwrap(); + + let world = IWorldDispatcher { contract_address: world_address }; + + let mut first_namespace = Option::None; + + for ns in namespaces_defs { + let namespace = ns.namespace.clone(); + world.register_namespace(namespace.clone()); + + if first_namespace.is_none() { + first_namespace = Option::Some(namespace.clone()); + } + + let namespace_hash = dojo::utils::bytearray_hash(@namespace); + + for r in ns + .resources + .clone() { + match r { + TestResource::Event(ch) => { world.register_event(namespace.clone(), *ch); }, + TestResource::Model(ch) => { world.register_model(namespace.clone(), *ch); }, + TestResource::Contract(def) => { + let class_hash: ClassHash = (*def.class_hash).try_into().unwrap(); + let contract_address = world + .register_contract(*def.class_hash, namespace.clone(), class_hash); + + for target in *def + .writer_of { + world.grant_writer(*target, contract_address); + }; + + for target in *def + .owner_of { + world.grant_owner(*target, contract_address); + }; + + let selector = dojo::utils::selector_from_namespace_and_name( + namespace_hash, def.name + ); + world.init_contract(selector, *def.init_calldata); + }, + } + } + }; + + WorldStorageTrait::new(world, @first_namespace.unwrap()) +} diff --git a/crates/dojo/core/Cargo.lock b/crates/dojo/core/Cargo.lock new file mode 100644 index 0000000000..b150ef928d --- /dev/null +++ b/crates/dojo/core/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "dojo-core" +version = "1.0.0-rc.1" diff --git a/crates/dojo-core/Cargo.toml b/crates/dojo/core/Cargo.toml similarity index 89% rename from crates/dojo-core/Cargo.toml rename to crates/dojo/core/Cargo.toml index 23bee916de..98bcd76429 100644 --- a/crates/dojo-core/Cargo.toml +++ b/crates/dojo/core/Cargo.toml @@ -1,7 +1,7 @@ [package] +name = "dojo-contracts" edition.workspace = true -license-file.workspace = true -name = "dojo-core" +license.workspace = true repository.workspace = true version.workspace = true diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock b/crates/dojo/core/Scarb.lock similarity index 58% rename from crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock rename to crates/dojo/core/Scarb.lock index 16e168040a..4cd448d1e5 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock +++ b/crates/dojo/core/Scarb.lock @@ -2,12 +2,12 @@ version = 1 [[package]] -name = "compiler_cairo" -version = "0.1.0" +name = "dojo" +version = "1.0.0-rc.0" dependencies = [ - "dojo", + "dojo_plugin", ] [[package]] -name = "dojo" -version = "1.0.0-alpha.4" +name = "dojo_plugin" +version = "2.8.4" diff --git a/crates/dojo/core/Scarb.toml b/crates/dojo/core/Scarb.toml new file mode 100644 index 0000000000..b93e190c7c --- /dev/null +++ b/crates/dojo/core/Scarb.toml @@ -0,0 +1,19 @@ +[package] +cairo-version = "=2.8.4" +edition = "2024_07" +description = "The Dojo Core library for autonomous worlds." +name = "dojo" +version = "1.0.0-rc.0" + +[dependencies] +starknet = "=2.8.4" +dojo_plugin = { path = "../lang" } +#dojo_macros = { path = "../macros" } + +[dev-dependencies] +cairo_test = "=2.8.4" + +[lib] + +[[target.starknet-contract]] +sierra = true diff --git a/crates/dojo-core/dojo_dev.toml b/crates/dojo/core/dojo_dev.toml similarity index 100% rename from crates/dojo-core/dojo_dev.toml rename to crates/dojo/core/dojo_dev.toml diff --git a/crates/dojo-core/src/contract/upgradeable.cairo b/crates/dojo/core/src/contract/components/upgradeable.cairo similarity index 76% rename from crates/dojo-core/src/contract/upgradeable.cairo rename to crates/dojo/core/src/contract/components/upgradeable.cairo index c8922f44e7..2ae357a3b7 100644 --- a/crates/dojo-core/src/contract/upgradeable.cairo +++ b/crates/dojo/core/src/contract/components/upgradeable.cairo @@ -6,14 +6,13 @@ pub trait IUpgradeable { } #[starknet::component] -pub mod upgradeable { +pub mod upgradeable_cpt { use core::num::traits::Zero; - use core::starknet::SyscallResultTrait; - use starknet::{ClassHash, ContractAddress, get_caller_address}; + use starknet::{ClassHash, get_caller_address}; use starknet::syscalls::replace_class_syscall; - use dojo::world::{IWorldProvider, IWorldProviderDispatcher, IWorldDispatcher}; + use dojo::contract::components::world_provider::IWorldProvider; #[storage] pub struct Storage {} @@ -31,28 +30,30 @@ pub mod upgradeable { pub mod Errors { pub const INVALID_CLASS: felt252 = 'class_hash cannot be zero'; - pub const INVALID_CLASS_CONTENT: felt252 = 'class_hash not world provider'; + pub const INVALID_CLASS_CONTENT: felt252 = 'class_hash not Dojo IContract'; pub const INVALID_CALLER: felt252 = 'must be called by world'; pub const INVALID_WORLD_ADDRESS: felt252 = 'invalid world address'; } - #[embeddable_as(UpgradableImpl)] - impl Upgradable< + #[embeddable_as(UpgradeableImpl)] + impl Upgradeable< TContractState, +HasComponent, +IWorldProvider > of super::IUpgradeable> { fn upgrade(ref self: ComponentState, new_class_hash: ClassHash) { assert( - self.get_contract().world().contract_address.is_non_zero(), + self.get_contract().world_dispatcher().contract_address.is_non_zero(), Errors::INVALID_WORLD_ADDRESS ); assert( - get_caller_address() == self.get_contract().world().contract_address, + get_caller_address() == self.get_contract().world_dispatcher().contract_address, Errors::INVALID_CALLER ); assert(new_class_hash.is_non_zero(), Errors::INVALID_CLASS); + // Seems like the match doesn't catch the error is the entrypoint is + // not found. match starknet::syscalls::library_call_syscall( - new_class_hash, selector!("world"), [].span(), + new_class_hash, selector!("dojo_name"), [].span(), ) { Result::Ok(_) => { replace_class_syscall(new_class_hash).unwrap(); diff --git a/crates/dojo/core/src/contract/components/world_provider.cairo b/crates/dojo/core/src/contract/components/world_provider.cairo new file mode 100644 index 0000000000..934947d844 --- /dev/null +++ b/crates/dojo/core/src/contract/components/world_provider.cairo @@ -0,0 +1,39 @@ +use dojo::world::IWorldDispatcher; + +#[starknet::interface] +pub trait IWorldProvider { + fn world_dispatcher(self: @T) -> IWorldDispatcher; +} + +#[starknet::component] +pub mod world_provider_cpt { + use starknet::get_caller_address; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + + use dojo::world::IWorldDispatcher; + + #[storage] + pub struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[embeddable_as(WorldProviderImpl)] + pub impl WorldProvider< + TContractState, +HasComponent + > of super::IWorldProvider> { + fn world_dispatcher(self: @ComponentState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[generate_trait] + pub impl InternalImpl< + TContractState, +HasComponent + > of InternalTrait { + fn initializer(ref self: ComponentState) { + self + .world_dispatcher + .write(IWorldDispatcher { contract_address: get_caller_address() }); + } + } +} diff --git a/crates/dojo/core/src/contract/interface.cairo b/crates/dojo/core/src/contract/interface.cairo new file mode 100644 index 0000000000..51a952e7e8 --- /dev/null +++ b/crates/dojo/core/src/contract/interface.cairo @@ -0,0 +1,4 @@ +#[starknet::interface] +pub trait IContract { + fn dojo_name(self: @T) -> ByteArray; +} diff --git a/crates/dojo/core/src/event/event.cairo b/crates/dojo/core/src/event/event.cairo new file mode 100644 index 0000000000..16b08256dc --- /dev/null +++ b/crates/dojo/core/src/event/event.cairo @@ -0,0 +1,23 @@ +use dojo::meta::Layout; +use dojo::meta::introspect::Ty; + +#[derive(Drop, Serde, Debug, PartialEq)] +pub struct EventDefinition { + pub name: ByteArray, + pub version: u8, + pub layout: Layout, + pub schema: Ty +} + +pub trait Event { + fn name() -> ByteArray; + fn version() -> u8; + fn definition() -> EventDefinition; + fn layout() -> Layout; + fn schema() -> Ty; + fn historical() -> bool; + fn keys(self: @T) -> Span; + fn values(self: @T) -> Span; + /// Returns the selector of the model computed for the given namespace hash. + fn selector(namespace_hash: felt252) -> felt252; +} diff --git a/crates/dojo/core/src/event/interface.cairo b/crates/dojo/core/src/event/interface.cairo new file mode 100644 index 0000000000..0003657113 --- /dev/null +++ b/crates/dojo/core/src/event/interface.cairo @@ -0,0 +1,13 @@ +use dojo::meta::Layout; +use dojo::meta::introspect::Ty; + +use super::EventDefinition; + +#[starknet::interface] +pub trait IEvent { + fn dojo_name(self: @T) -> ByteArray; + fn version(self: @T) -> u8; + fn definition(self: @T) -> EventDefinition; + fn layout(self: @T) -> Layout; + fn schema(self: @T) -> Ty; +} diff --git a/crates/dojo/core/src/event/storage.cairo b/crates/dojo/core/src/event/storage.cairo new file mode 100644 index 0000000000..d399fd3d1f --- /dev/null +++ b/crates/dojo/core/src/event/storage.cairo @@ -0,0 +1,8 @@ +/// A `EventStorage` trait that abstracts where the storage is and how events are emitted. +pub trait EventStorage { + fn emit_event(ref self: S, event: @E); +} + +pub trait EventStorageTest { + fn emit_event_test(ref self: S, event: @E); +} diff --git a/crates/dojo/core/src/lib.cairo b/crates/dojo/core/src/lib.cairo new file mode 100644 index 0000000000..37a82eca06 --- /dev/null +++ b/crates/dojo/core/src/lib.cairo @@ -0,0 +1,108 @@ +pub mod contract { + pub mod interface; + pub use interface::{IContract, IContractDispatcher, IContractDispatcherTrait}; + + pub mod components { + pub mod upgradeable; + pub mod world_provider; + } +} + +pub mod event { + pub mod event; + pub use event::{Event, EventDefinition}; + + pub mod interface; + pub use interface::{IEvent, IEventDispatcher, IEventDispatcherTrait}; + + pub mod storage; + pub use storage::{EventStorage, EventStorageTest}; +} + +pub mod meta { + pub mod introspect; + pub use introspect::{Introspect, Ty}; + + pub mod layout; + pub use layout::{Layout, FieldLayout}; +} + +pub mod model { + pub mod component; + + pub mod definition; + pub use definition::{ModelIndex, ModelDefinition, ModelDef}; + + pub mod model; + pub use model::{Model, KeyParser}; + + pub mod model_value; + pub use model_value::{ModelValue, ModelValueKey}; + + pub mod interface; + pub use interface::{IModel, IModelDispatcher, IModelDispatcherTrait}; + + pub mod metadata; + pub use metadata::ResourceMetadata; + + pub mod storage; + pub use storage::{ + ModelStorage, ModelStorageTest, ModelValueStorage, ModelValueStorageTest, ModelPtr, + }; + + #[cfg(target: "test")] + pub use model::{ModelTest}; + + #[cfg(target: "test")] + pub use model_value::{ModelValueTest}; +} + +pub mod storage { + pub mod database; + pub mod packing; + pub mod layout; + pub mod storage; + pub mod entity_model; +} + +pub mod utils { + pub mod hash; + pub use hash::{bytearray_hash, selector_from_names, selector_from_namespace_and_name}; + + pub mod key; + pub use key::{entity_id_from_keys, combine_key, entity_id_from_key}; + + pub mod layout; + pub use layout::{find_field_layout, find_model_field_layout}; + + pub mod misc; + pub use misc::{any_none, sum}; + + pub mod naming; + pub use naming::is_name_valid; + + pub mod serde; + pub use serde::{serialize_inline, deserialize_unwrap}; +} + +pub mod world { + pub(crate) mod errors; + + mod resource; + pub use resource::{Resource, ResourceIsNoneTrait}; + + mod iworld; + pub use iworld::{ + IWorld, IWorldDispatcher, IWorldDispatcherTrait, IUpgradeableWorld, + IUpgradeableWorldDispatcher, IUpgradeableWorldDispatcherTrait + }; + + #[cfg(target: "test")] + pub use iworld::{IWorldTest, IWorldTestDispatcher, IWorldTestDispatcherTrait}; + + mod world_contract; + pub use world_contract::world; + + pub mod storage; + pub use storage::{WorldStorage, WorldStorageTrait}; +} diff --git a/crates/dojo-core/src/lib.rs b/crates/dojo/core/src/lib.rs similarity index 100% rename from crates/dojo-core/src/lib.rs rename to crates/dojo/core/src/lib.rs diff --git a/crates/dojo-core/src/model/introspect.cairo b/crates/dojo/core/src/meta/introspect.cairo similarity index 87% rename from crates/dojo-core/src/model/introspect.cairo rename to crates/dojo/core/src/meta/introspect.cairo index 7138f4fe67..145fab198e 100644 --- a/crates/dojo-core/src/model/introspect.cairo +++ b/crates/dojo/core/src/meta/introspect.cairo @@ -1,6 +1,7 @@ -use dojo::model::{Layout, FieldLayout}; +use dojo::meta::Layout; +use dojo::storage::packing; -#[derive(Copy, Drop, Serde)] +#[derive(Copy, Drop, Serde, Debug, PartialEq)] pub enum Ty { Primitive: felt252, Struct: Struct, @@ -13,21 +14,21 @@ pub enum Ty { ByteArray, } -#[derive(Copy, Drop, Serde)] +#[derive(Copy, Drop, Serde, Debug, PartialEq)] pub struct Struct { pub name: felt252, pub attrs: Span, pub children: Span } -#[derive(Copy, Drop, Serde)] +#[derive(Copy, Drop, Serde, Debug, PartialEq)] pub struct Enum { pub name: felt252, pub attrs: Span, pub children: Span<(felt252, Ty)> } -#[derive(Copy, Drop, Serde)] +#[derive(Copy, Drop, Serde, Debug, PartialEq)] pub struct Member { pub name: felt252, pub attrs: Span, @@ -45,7 +46,7 @@ pub impl Introspect_felt252 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('felt252') @@ -141,7 +142,7 @@ pub impl Introspect_i8 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('i8') @@ -153,7 +154,7 @@ pub impl Introspect_i16 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('i16') @@ -165,7 +166,7 @@ pub impl Introspect_i32 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('i32') @@ -177,7 +178,7 @@ pub impl Introspect_i64 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('i64') @@ -189,7 +190,7 @@ pub impl Introspect_i128 of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('i128') @@ -201,7 +202,7 @@ pub impl Introspect_address of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('starknet::ContractAddress') @@ -213,7 +214,7 @@ pub impl Introspect_classhash of Introspect { Option::Some(1) } fn layout() -> Layout { - Layout::Fixed([251].span()) + Layout::Fixed([packing::PACKING_MAX_BITS].span()) } fn ty() -> Ty { Ty::Primitive('starknet::ClassHash') @@ -240,9 +241,9 @@ pub impl Introspect_option> of Introspect> { fn layout() -> Layout { Layout::Enum( [ - dojo::model::FieldLayout { // Some + dojo::meta::FieldLayout { // Some selector: 0, layout: Introspect::::layout() }, - dojo::model::FieldLayout { // None + dojo::meta::FieldLayout { // None selector: 1, layout: Layout::Fixed([].span()) }, ].span() ) diff --git a/crates/dojo-core/src/model/layout.cairo b/crates/dojo/core/src/meta/layout.cairo similarity index 100% rename from crates/dojo-core/src/model/layout.cairo rename to crates/dojo/core/src/meta/layout.cairo diff --git a/crates/dojo/core/src/model/component.cairo b/crates/dojo/core/src/model/component.cairo new file mode 100644 index 0000000000..1a2556d007 --- /dev/null +++ b/crates/dojo/core/src/model/component.cairo @@ -0,0 +1,32 @@ +use dojo::{model::{Model, IModel, ModelDef}, meta::{Layout, Ty}}; + +#[starknet::embeddable] +pub impl IModelImpl> of IModel { + fn dojo_name(self: @TContractState) -> ByteArray { + Model::::name() + } + + fn version(self: @TContractState) -> u8 { + Model::::version() + } + + fn schema(self: @TContractState) -> Ty { + Model::::schema() + } + + fn layout(self: @TContractState) -> Layout { + Model::::layout() + } + + fn unpacked_size(self: @TContractState) -> Option { + Model::::unpacked_size() + } + + fn packed_size(self: @TContractState) -> Option { + Model::::packed_size() + } + + fn definition(self: @TContractState) -> ModelDef { + Model::::definition() + } +} diff --git a/crates/dojo/core/src/model/definition.cairo b/crates/dojo/core/src/model/definition.cairo new file mode 100644 index 0000000000..a7b5cc7299 --- /dev/null +++ b/crates/dojo/core/src/model/definition.cairo @@ -0,0 +1,37 @@ +use dojo::meta::{Layout, introspect::Ty}; + +/// The `ModelIndex` provides encapsulation for different ways to access +/// a model's data. +/// +/// - `Keys`: Access by keys, where each individual key is known, and can be hashed. +/// - `Id`: Access by id, where only the id of the entity is known (keys already hashed). +/// - `MemberId`: Access by member id, where the member id and entity id are known. +#[derive(Copy, Drop, Serde, Debug, PartialEq)] +pub enum ModelIndex { + Keys: Span, + Id: felt252, + // (entity_id, member_id) + MemberId: (felt252, felt252) +} + +/// The `ModelDefinition` trait. +/// +/// Definition of the model containing all the fields that makes up a model. +pub trait ModelDefinition { + fn name() -> ByteArray; + fn version() -> u8; + fn layout() -> Layout; + fn schema() -> Ty; + fn size() -> Option; +} + +/// A plain struct with all the fields of a model definition. +#[derive(Drop, Serde, Debug, PartialEq)] +pub struct ModelDef { + pub name: ByteArray, + pub version: u8, + pub layout: Layout, + pub schema: Ty, + pub packed_size: Option, + pub unpacked_size: Option, +} diff --git a/crates/dojo/core/src/model/interface.cairo b/crates/dojo/core/src/model/interface.cairo new file mode 100644 index 0000000000..df330644ac --- /dev/null +++ b/crates/dojo/core/src/model/interface.cairo @@ -0,0 +1,17 @@ +use dojo::meta::{Layout, Ty}; +use dojo::model::ModelDef; + +/// The `IModel` starknet interface. +/// +/// This is the interface used by offchain components and other contracts +/// to interact with deployed models. +#[starknet::interface] +pub trait IModel { + fn dojo_name(self: @T) -> ByteArray; + fn version(self: @T) -> u8; + fn layout(self: @T) -> Layout; + fn schema(self: @T) -> Ty; + fn unpacked_size(self: @T) -> Option; + fn packed_size(self: @T) -> Option; + fn definition(self: @T) -> ModelDef; +} diff --git a/crates/dojo/core/src/model/metadata.cairo b/crates/dojo/core/src/model/metadata.cairo new file mode 100644 index 0000000000..512d4c14c0 --- /dev/null +++ b/crates/dojo/core/src/model/metadata.cairo @@ -0,0 +1,26 @@ +//! ResourceMetadata model. +//! +use dojo::model::model::Model; +use dojo::utils; + +#[derive(Introspect, Drop, Serde, PartialEq, Clone, Debug)] +#[dojo::model] +pub struct ResourceMetadata { + #[key] + pub resource_id: felt252, + pub metadata_uri: ByteArray, +} + +pub fn default_address() -> starknet::ContractAddress { + starknet::contract_address_const::<0>() +} + +pub fn default_class_hash() -> starknet::ClassHash { + starknet::class_hash::class_hash_const::<0>() +} + +pub fn resource_metadata_selector(default_namespace_hash: felt252) -> felt252 { + utils::selector_from_namespace_and_name( + default_namespace_hash, @Model::::name() + ) +} diff --git a/crates/dojo/core/src/model/model.cairo b/crates/dojo/core/src/model/model.cairo new file mode 100644 index 0000000000..9a6d941ea9 --- /dev/null +++ b/crates/dojo/core/src/model/model.cairo @@ -0,0 +1,143 @@ +use dojo::{meta::{Layout, introspect::Ty, layout::compute_packed_size}, utils::entity_id_from_keys}; + +use super::{ModelDefinition, ModelDef}; + +/// Trait `KeyParser` defines a trait for parsing keys from a given model. +pub trait KeyParser { + /// Parses the key from the given model. + fn parse_key(self: @M) -> K; +} + +/// Defines a trait for parsing models, providing methods to serialize keys and values. +pub trait ModelParser { + /// Serializes the keys of the model. + fn serialize_keys(self: @M) -> Span; + /// Serializes the values of the model. + fn serialize_values(self: @M) -> Span; +} + +/// The `Model` trait. +/// +/// It provides a standardized way to interact with models. +pub trait Model { + /// Parses the key from the given model, where `K` is a type containing the keys of the model. + fn key>(self: @M) -> K; + /// Returns the entity id of the model. + fn entity_id(self: @M) -> felt252; + /// Returns the keys of the model. + fn keys(self: @M) -> Span; + /// Returns the values of the model. + fn values(self: @M) -> Span; + /// Constructs a model from the given keys and values. + fn from_values(ref keys: Span, ref values: Span) -> Option; + /// Returns the name of the model. (TODO: internalizing the name_hash could reduce poseidon + /// costs). + fn name() -> ByteArray; + /// Returns the version of the model. + fn version() -> u8; + /// Returns the schema of the model. + fn schema() -> Ty; + /// Returns the memory layout of the model. + fn layout() -> Layout; + /// Returns the unpacked size of the model. Only applicable for fixed size models. + fn unpacked_size() -> Option; + /// Returns the packed size of the model. Only applicable for fixed size models. + fn packed_size() -> Option; + /// Returns the instance selector of the model. + fn instance_layout(self: @M) -> Layout; + /// Returns the definition of the model. + fn definition() -> ModelDef; + /// Returns the selector of the model computed for the given namespace hash. + fn selector(namespace_hash: felt252) -> felt252; +} + +pub impl ModelImpl, +ModelDefinition, +Serde> of Model { + fn key>(self: @M) -> K { + KeyParser::::parse_key(self) + } + + fn entity_id(self: @M) -> felt252 { + entity_id_from_keys(Self::keys(self)) + } + + fn keys(self: @M) -> Span { + ModelParser::::serialize_keys(self) + } + + fn values(self: @M) -> Span { + ModelParser::::serialize_values(self) + } + + fn from_values(ref keys: Span, ref values: Span) -> Option { + let mut serialized: Array = keys.into(); + serialized.append_span(values); + let mut span = serialized.span(); + + Serde::::deserialize(ref span) + } + + fn name() -> ByteArray { + ModelDefinition::::name() + } + + fn selector(namespace_hash: felt252) -> felt252 { + dojo::utils::selector_from_namespace_and_name(namespace_hash, @Self::name()) + } + + fn version() -> u8 { + ModelDefinition::::version() + } + + fn layout() -> Layout { + ModelDefinition::::layout() + } + + fn schema() -> Ty { + ModelDefinition::::schema() + } + + fn unpacked_size() -> Option { + ModelDefinition::::size() + } + + fn packed_size() -> Option { + compute_packed_size(ModelDefinition::::layout()) + } + + fn instance_layout(self: @M) -> Layout { + ModelDefinition::::layout() + } + + fn definition() -> ModelDef { + ModelDef { + name: Self::name(), + version: Self::version(), + layout: Self::layout(), + schema: Self::schema(), + packed_size: Self::packed_size(), + unpacked_size: Self::unpacked_size() + } + } +} + +/// The `ModelTest` trait. +/// +/// It provides a standardized way to interact with models for testing purposes, +/// bypassing the permission checks. +#[cfg(target: "test")] +pub trait ModelTest { + fn set_model_test(ref self: S, model: @M); + fn delete_model_test(ref self: S, model: @M); +} + +/// The `ModelTestImpl` implementation for testing purposes. +#[cfg(target: "test")] +pub impl ModelTestImpl, +Model> of ModelTest { + fn set_model_test(ref self: S, model: @M) { + dojo::model::ModelStorageTest::::write_model_test(ref self, model); + } + + fn delete_model_test(ref self: S, model: @M) { + dojo::model::ModelStorageTest::::erase_model_test(ref self, model); + } +} diff --git a/crates/dojo/core/src/model/model_value.cairo b/crates/dojo/core/src/model/model_value.cairo new file mode 100644 index 0000000000..ccb02d06e8 --- /dev/null +++ b/crates/dojo/core/src/model/model_value.cairo @@ -0,0 +1,86 @@ +use dojo::{meta::{Layout}, model::{ModelDefinition},}; + +pub trait ModelValueKey {} + +/// Trait `ModelValueParser` defines the interface for parsing and serializing entities of type `V`. +pub trait ModelValueParser { + /// Serializes the values of the model and returns them as a `Span`. + fn serialize_values(self: @V) -> Span; +} + +/// The `ModelValue` trait defines a set of methods that must be implemented by any model value type +/// `V`. +pub trait ModelValue { + /// Returns a span of values associated with the entity, every field of a model + /// that is not a key. + fn values(self: @V) -> Span; + /// Constructs a model value from its identifier and values. + fn from_values(entity_id: felt252, ref values: Span) -> Option; + /// Returns the name of the model value type. + fn name() -> ByteArray; + /// Returns the version of the model value type. + fn version() -> u8; + /// Returns the layout of the model value type. + fn layout() -> Layout; + /// Returns the layout of the model value. + fn instance_layout(self: @V) -> Layout; + /// Returns the selector of the model value type with the given namespace hash. + fn selector(namespace_hash: felt252) -> felt252; +} + +pub impl ModelValueImpl, +ModelDefinition, +ModelValueParser> of ModelValue { + fn values(self: @V) -> Span { + ModelValueParser::::serialize_values(self) + } + + fn from_values(entity_id: felt252, ref values: Span) -> Option { + let mut serialized: Array = array![]; + serialized.append_span(values); + let mut span = serialized.span(); + Serde::::deserialize(ref span) + } + + fn name() -> ByteArray { + ModelDefinition::::name() + } + + fn version() -> u8 { + ModelDefinition::::version() + } + + fn layout() -> Layout { + ModelDefinition::::layout() + } + + fn instance_layout(self: @V) -> Layout { + ModelDefinition::::layout() + } + + fn selector(namespace_hash: felt252) -> felt252 { + dojo::utils::selector_from_namespace_and_name(namespace_hash, @Self::name()) + } +} + + +/// Test implementation of the `ModelValueTest` trait to bypass permission checks. +#[cfg(target: "test")] +pub trait ModelValueTest { + fn update_test(ref self: S, entity_id: felt252, value: @V); + fn delete_test(ref self: S, entity_id: felt252); +} + +/// Implementation of the `ModelValueTest` trait for testing purposes, bypassing permission checks. +#[cfg(target: "test")] +pub impl ModelValueTestImpl< + S, V, +super::storage::ModelValueStorageTest, +ModelValue +> of ModelValueTest { + fn update_test(ref self: S, entity_id: felt252, value: @V) { + super::storage::ModelValueStorageTest::< + S, V + >::write_value_from_id_test(ref self, entity_id, value) + } + + fn delete_test(ref self: S, entity_id: felt252) { + super::storage::ModelValueStorageTest::::erase_value_from_id_test(ref self, entity_id) + } +} diff --git a/crates/dojo/core/src/model/storage.cairo b/crates/dojo/core/src/model/storage.cairo new file mode 100644 index 0000000000..1cf86528e0 --- /dev/null +++ b/crates/dojo/core/src/model/storage.cairo @@ -0,0 +1,76 @@ +use dojo::model::model_value::ModelValueKey; + +// TODO: define the right interface for member accesses. + +/// A pointer to a model, which can be expressed by an entity id. +/// It's different from `ModelIndex` which is used for low level accesses. +#[derive(Copy, Drop, Serde, Debug, PartialEq)] +pub enum ModelPtr { + // The id of the model. + Id: felt252, + // The keys of the model as span. + Keys: Span, +} + +/// A `ModelStorage` trait that abstracts where the storage is. +/// +/// Currently it's only world storage, but this will be useful when we have other +/// storage solutions (micro worlds). +pub trait ModelStorage { + /// Sets a model of type `M`. + fn write_model(ref self: S, model: @M); + + /// Retrieves a model of type `M` using the provided key of type `K`. + fn read_model, +Serde>(self: @S, key: K) -> M; + + /// Deletes a model of type `M`. + fn erase_model(ref self: S, model: @M); + + /// Deletes a model of type `M` using the provided entity id. + /// The ptr is mostly used for type inferrence. + fn erase_model_ptr(ref self: S, ptr: ModelPtr); + + /// Returns the current namespace hash. + fn namespace_hash(self: @S) -> felt252; +} + +/// A `ModelValueStorage` trait that abstracts where the storage is. +pub trait ModelValueStorage { + /// Retrieves a model value of type `V` using the provided key of type `K`. + fn read_value, +Serde, +ModelValueKey>(self: @S, key: K) -> V; + + /// Retrieves a model value of type `V` using the provided entity id. + fn read_value_from_id(self: @S, entity_id: felt252) -> V; + + /// Updates a model value of type `V`. + fn write_value, +Serde, +ModelValueKey>(ref self: S, key: K, value: @V); + + /// Updates a model value of type `V`. + fn write_value_from_id(ref self: S, entity_id: felt252, value: @V); +} + +/// A `ModelStorage` trait that abstracts where the storage is. +/// +/// Currently it's only world storage, but this will be useful when we have other +/// storage solutions (micro worlds). +pub trait ModelStorageTest { + /// Sets a model of type `M`. + fn write_model_test(ref self: S, model: @M); + /// Deletes a model of type `M`. + fn erase_model_test(ref self: S, model: @M); + /// Deletes a model of type `M` using the provided entity id. + fn erase_model_ptr_test(ref self: S, ptr: ModelPtr); +} + +/// A `ModelValueStorageTest` trait that abstracts where the storage is and bypass the permission +/// checks. +pub trait ModelValueStorageTest { + /// Updates a model value of type `V`. + fn write_value_test, +Serde, +ModelValueKey>( + ref self: S, key: K, value: @V + ); + /// Updates a model value of type `V`. + fn write_value_from_id_test(ref self: S, entity_id: felt252, value: @V); + /// Deletes a model value of type `V`. + fn erase_value_from_id_test(ref self: S, entity_id: felt252); +} diff --git a/crates/dojo-core/src/storage/database.cairo b/crates/dojo/core/src/storage/database.cairo similarity index 84% rename from crates/dojo-core/src/storage/database.cairo rename to crates/dojo/core/src/storage/database.cairo index db254efdde..461550dcb1 100644 --- a/crates/dojo-core/src/storage/database.cairo +++ b/crates/dojo/core/src/storage/database.cairo @@ -1,9 +1,4 @@ use core::array::{ArrayTrait, SpanTrait}; -use core::hash::LegacyHash; -use core::option::OptionTrait; -use core::poseidon::poseidon_hash_span; -use core::serde::Serde; -use core::traits::{Into, TryInto}; use starknet::SyscallResultTrait; @@ -52,7 +47,8 @@ fn get_storage_key(table: felt252, key: felt252) -> Span { /// # Returns /// A [`Span`] containing the raw unpacked data of the read record. pub fn get(table: felt252, key: felt252, layout: Span) -> Span { - storage::get_many(0, get_storage_key(table, key), layout).unwrap_syscall() + storage::get_many(storage::DEFAULT_ADDRESS_DOMAIN, get_storage_key(table, key), layout) + .unwrap_syscall() } /// Write a record with its ID, layout and new value. @@ -61,10 +57,12 @@ pub fn get(table: felt252, key: felt252, layout: Span) -> Span { /// * `table` - the table selector /// * `key` - key of the record to write /// * `value` - the new raw unpacked data value of the record +/// * `offset` - the offset in value to start writing from /// * `layout` - the layout of the record to write. pub fn set(table: felt252, key: felt252, value: Span, offset: u32, layout: Span) { let storage_key = get_storage_key(table, key); - storage::set_many(0, storage_key, value, offset, layout).unwrap_syscall(); + storage::set_many(storage::DEFAULT_ADDRESS_DOMAIN, storage_key, value, offset, layout) + .unwrap_syscall(); } /// delete a record from a table with its ID and layout. @@ -89,7 +87,10 @@ pub fn delete(table: felt252, key: felt252, layout: Span) { /// * `array_size` - the size of the nested array to write pub fn set_array(table: felt252, key: felt252, value: Span, offset: u32, array_size: u32) { let storage_key = get_storage_key(table, key); - storage::set_packed_array(0, storage_key, value, offset, array_size).unwrap_syscall(); + storage::set_packed_array( + storage::DEFAULT_ADDRESS_DOMAIN, storage_key, value, offset, array_size + ) + .unwrap_syscall(); } /// Read an array. @@ -102,5 +103,6 @@ pub fn set_array(table: felt252, key: felt252, value: Span, offset: u32 /// # Returns pub fn get_array(table: felt252, key: felt252, array_size: u32) -> Span { let storage_key = get_storage_key(table, key); - storage::get_packed_array(0, storage_key, array_size).unwrap_syscall() + storage::get_packed_array(storage::DEFAULT_ADDRESS_DOMAIN, storage_key, array_size) + .unwrap_syscall() } diff --git a/crates/dojo/core/src/storage/entity_model.cairo b/crates/dojo/core/src/storage/entity_model.cairo new file mode 100644 index 0000000000..7834e117fb --- /dev/null +++ b/crates/dojo/core/src/storage/entity_model.cairo @@ -0,0 +1,111 @@ +//! Storage operations for models and entities. + +use dojo::meta::Layout; + +/// Write a new entity. +/// +/// # Arguments +/// * `model_selector` - the model selector +/// * `entity_id` - the id used to identify the record +/// * `values` - the field values of the record +/// * `layout` - the model layout +pub fn write_model_entity( + model_selector: felt252, entity_id: felt252, values: Span, layout: Layout +) { + let mut offset = 0; + + match layout { + Layout::Fixed(layout) => { + super::layout::write_fixed_layout( + model_selector, entity_id, values, ref offset, layout + ); + }, + Layout::Struct(layout) => { + super::layout::write_struct_layout( + model_selector, entity_id, values, ref offset, layout + ); + }, + _ => { panic!("Unexpected layout type for a model."); } + }; +} + +/// Delete an entity. +/// +/// # Arguments +/// * `model_selector` - the model selector +/// * `entity_id` - the ID of the entity to remove. +/// * `layout` - the model layout +pub fn delete_model_entity(model_selector: felt252, entity_id: felt252, layout: Layout) { + match layout { + Layout::Fixed(layout) => { + super::layout::delete_fixed_layout(model_selector, entity_id, layout); + }, + Layout::Struct(layout) => { + super::layout::delete_struct_layout(model_selector, entity_id, layout); + }, + _ => { panic!("Unexpected layout type for a model."); } + }; +} + +/// Read an entity. +/// +/// # Arguments +/// * `model_selector` - the model selector +/// * `entity_id` - the ID of the entity to read. +/// * `layout` - the model layout +pub fn read_model_entity( + model_selector: felt252, entity_id: felt252, layout: Layout +) -> Span { + let mut read_data = ArrayTrait::::new(); + + match layout { + Layout::Fixed(layout) => { + super::layout::read_fixed_layout(model_selector, entity_id, ref read_data, layout); + }, + Layout::Struct(layout) => { + super::layout::read_struct_layout(model_selector, entity_id, ref read_data, layout); + }, + _ => { panic!("Unexpected layout type for a model."); } + }; + + read_data.span() +} + +/// Read a model member value. +/// +/// # Arguments +/// * `model_selector` - the model selector +/// * `entity_id` - the ID of the entity for which to read a member. +/// * `member_id` - the selector of the model member to read. +/// * `layout` - the model layout +pub fn read_model_member( + model_selector: felt252, entity_id: felt252, member_id: felt252, layout: Layout +) -> Span { + let mut read_data = ArrayTrait::::new(); + super::layout::read_layout( + model_selector, dojo::utils::combine_key(entity_id, member_id), ref read_data, layout + ); + + read_data.span() +} + +/// Write a model member value. +/// +/// # Arguments +/// * `model_selector` - the model selector +/// * `entity_id` - the ID of the entity for which to write a member. +/// * `member_id` - the selector of the model member to write. +/// * `values` - the new member value. +/// * `layout` - the model layout +pub fn write_model_member( + model_selector: felt252, + entity_id: felt252, + member_id: felt252, + values: Span, + layout: Layout +) { + let mut offset = 0; + super::layout::write_layout( + model_selector, dojo::utils::combine_key(entity_id, member_id), values, ref offset, layout + ) +} diff --git a/crates/dojo-core/src/storage/layout.cairo b/crates/dojo/core/src/storage/layout.cairo similarity index 89% rename from crates/dojo-core/src/storage/layout.cairo rename to crates/dojo/core/src/storage/layout.cairo index f0b8e7a6b5..d29ca3235e 100644 --- a/crates/dojo-core/src/storage/layout.cairo +++ b/crates/dojo/core/src/storage/layout.cairo @@ -1,7 +1,8 @@ -use dojo::model::{Layout, FieldLayout}; +use dojo::meta::{Layout, FieldLayout}; use dojo::utils::{combine_key, find_field_layout}; use super::database; +use super::packing; // the minimum internal size of an empty ByteArray const MIN_BYTE_ARRAY_SIZE: u32 = 3; @@ -61,7 +62,7 @@ pub fn write_array_layout( let array_len: u32 = array_len.try_into().unwrap(); // then, write the array size - database::set(model, key, values, offset, [251].span()); + database::set(model, key, values, offset, [packing::PACKING_MAX_BITS].span()); offset += 1; // and then, write array items @@ -167,21 +168,28 @@ pub fn write_enum_layout( ref offset: u32, variant_layouts: Span ) { - // first, get the variant value from `values`` - let variant = *values.at(offset); - assert(variant.into() < 256_u256, 'invalid variant value'); - - // and write it - database::set(model, key, values, offset, [251].span()); - offset += 1; - - // find the corresponding layout and then write the full variant - let variant_data_key = combine_key(key, variant); - - match find_field_layout(variant, variant_layouts) { - Option::Some(layout) => write_layout(model, variant_data_key, values, ref offset, layout), - Option::None => panic!("Unable to find the variant layout") - }; + if let Option::Some(variant) = values.get(offset) { + // TODO: when Cairo 2.8 support is added, unboxing should be implicit. + let variant: felt252 = *variant.unbox(); + // first, get the variant value from `values` + assert(variant.into() < 256_u256, 'invalid variant value'); + + // and write it + database::set(model, key, values, offset, [packing::PACKING_MAX_BITS].span()); + offset += 1; + + // find the corresponding layout and then write the full variant + let variant_data_key = combine_key(key, variant); + + match find_field_layout(variant, variant_layouts) { + Option::Some(layout) => write_layout( + model, variant_data_key, values, ref offset, layout + ), + Option::None => panic!("Unable to find the variant layout") + }; + } else { + panic!("offset is out of bounds for enum layout variant"); + } } /// Delete a fixed layout model record from the world storage. @@ -201,7 +209,7 @@ pub fn delete_fixed_layout(model: felt252, key: felt252, layout: Span) { /// * `key` - the model record key. pub fn delete_array_layout(model: felt252, key: felt252) { // just set the array length to 0 - database::delete(model, key, [251].span()); + database::delete(model, key, [packing::PACKING_MAX_BITS].span()); } /// @@ -215,7 +223,11 @@ pub fn delete_byte_array_layout(model: felt252, key: felt252) { // // So, just set the 3 first values to 0 (len(data), pending_world and pending_word_len) - database::delete(model, key, [251, 251, 251].span()); + database::delete( + model, + key, + [packing::PACKING_MAX_BITS, packing::PACKING_MAX_BITS, packing::PACKING_MAX_BITS].span() + ); } /// Delete a model record from the world storage. @@ -281,14 +293,14 @@ pub fn delete_tuple_layout(model: felt252, key: felt252, layout: Span) { pub fn delete_enum_layout(model: felt252, key: felt252, variant_layouts: Span) { // read the variant value - let res = database::get(model, key, [251].span()); + let res = database::get(model, key, [packing::PACKING_MAX_BITS].span()); assert(res.len() == 1, 'internal database error'); let variant = *res.at(0); assert(variant.into() < 256_u256, 'invalid variant value'); // reset the variant value - database::delete(model, key, [251].span()); + database::delete(model, key, [packing::PACKING_MAX_BITS].span()); // find the corresponding layout and the delete the full variant let variant_data_key = combine_key(key, variant); @@ -342,7 +354,7 @@ pub fn read_array_layout( model: felt252, key: felt252, ref read_data: Array, layout: Span ) { // read number of array items - let res = database::get(model, key, [251].span()); + let res = database::get(model, key, [packing::PACKING_MAX_BITS].span()); assert(res.len() == 1, 'internal database error'); let array_len = *res.at(0); @@ -377,7 +389,7 @@ pub fn read_byte_array_layout(model: felt252, key: felt252, ref read_data: Array // // So, read the length of data and compute the full size to read - let res = database::get(model, key, [251].span()); + let res = database::get(model, key, [packing::PACKING_MAX_BITS].span()); assert(res.len() == 1, 'internal database error'); let data_len = *res.at(0); diff --git a/crates/dojo-core/src/storage/packing.cairo b/crates/dojo/core/src/storage/packing.cairo similarity index 98% rename from crates/dojo-core/src/storage/packing.cairo rename to crates/dojo/core/src/storage/packing.cairo index 9f0853b1ac..5adbdb7682 100644 --- a/crates/dojo-core/src/storage/packing.cairo +++ b/crates/dojo/core/src/storage/packing.cairo @@ -2,9 +2,7 @@ use core::array::{ArrayTrait, SpanTrait}; use core::option::OptionTrait; use core::traits::{Into, TryInto}; -use starknet::{ClassHash, ContractAddress}; - -const PACKING_MAX_BITS: u8 = 251; +pub const PACKING_MAX_BITS: u8 = 251; pub fn pack( ref packed: Array, ref unpacked: Span, offset: u32, ref layout: Span @@ -58,7 +56,7 @@ pub fn unpack(ref unpacked: Array, ref packed: Span, ref layou match unpack_inner(*s, ref packed, ref unpacking, ref offset) { Option::Some(u) => { unpacked.append(u); }, Option::None(_) => { - // Layout value was successfully poped, + // Layout value was successfully popped, // we are then expecting an unpacked value. core::panic_with_felt252('Unpack inner failed'); } @@ -83,12 +81,12 @@ pub fn pack_inner( // Cannot use all 252 bits because some bit arrangements (eg. 11111...11111) are not valid // felt252 values. // Thus only 251 bits are used. ^-252 times-^ - // One could optimize by some conditional alligment mechanism, but it would be an at most 1/252 + // One could optimize by some conditional alignment mechanism, but it would be an at most 1/252 // space-wise improvement. let remaining_bits: u8 = (PACKING_MAX_BITS - packing_offset).into(); // If we have less remaining bits than the current item size, - // Finalize the current `packing`felt and move to the next felt. + // Finalize the current `packing` felt and move to the next felt. if remaining_bits < size { packed.append(packing); packing = *self; diff --git a/crates/dojo-core/src/storage/storage.cairo b/crates/dojo/core/src/storage/storage.cairo similarity index 99% rename from crates/dojo-core/src/storage/storage.cairo rename to crates/dojo/core/src/storage/storage.cairo index 902786ac1d..4a89c5c2e2 100644 --- a/crates/dojo-core/src/storage/storage.cairo +++ b/crates/dojo/core/src/storage/storage.cairo @@ -1,7 +1,5 @@ use core::array::{ArrayTrait, SpanTrait}; -use core::option::OptionTrait; use core::poseidon::poseidon_hash_span; -use core::serde::Serde; use core::traits::Into; use starknet::{SyscallResultTrait, SyscallResult}; @@ -13,6 +11,8 @@ use starknet::syscalls::{storage_read_syscall, storage_write_syscall}; use super::packing::{pack, unpack, calculate_packed_size}; +pub const DEFAULT_ADDRESS_DOMAIN: u32 = 0; + pub fn get(address_domain: u32, keys: Span) -> felt252 { let base = storage_base_address_from_felt252(poseidon_hash_span(keys)); storage_read_syscall(address_domain, storage_address_from_base(base)).unwrap_syscall() diff --git a/crates/dojo/core/src/utils/hash.cairo b/crates/dojo/core/src/utils/hash.cairo new file mode 100644 index 0000000000..d356c6f88c --- /dev/null +++ b/crates/dojo/core/src/utils/hash.cairo @@ -0,0 +1,19 @@ +use core::poseidon::poseidon_hash_span; +use core::serde::Serde; + +/// Compute the poseidon hash of a serialized ByteArray +pub fn bytearray_hash(data: @ByteArray) -> felt252 { + let mut serialized = ArrayTrait::new(); + Serde::serialize(data, ref serialized); + poseidon_hash_span(serialized.span()) +} + +/// Computes the selector of a resource from the namespace and the name. +pub fn selector_from_names(namespace: @ByteArray, name: @ByteArray) -> felt252 { + poseidon_hash_span([bytearray_hash(namespace), bytearray_hash(name)].span()) +} + +/// Computes the selector namespace hash and the name of the resource. +pub fn selector_from_namespace_and_name(namespace_hash: felt252, name: @ByteArray) -> felt252 { + poseidon_hash_span([namespace_hash, bytearray_hash(name)].span()) +} diff --git a/crates/dojo/core/src/utils/key.cairo b/crates/dojo/core/src/utils/key.cairo new file mode 100644 index 0000000000..89bb24f73e --- /dev/null +++ b/crates/dojo/core/src/utils/key.cairo @@ -0,0 +1,24 @@ +use dojo::utils::serialize_inline; + +/// Computes the entity id from the keys. +/// +/// # Arguments +/// +/// * `keys` - The keys of the entity. +/// +/// # Returns +/// +/// The entity id. +pub fn entity_id_from_keys(keys: Span) -> felt252 { + core::poseidon::poseidon_hash_span(keys) +} + +/// Combine parent and child keys to build one full key. +pub fn combine_key(parent_key: felt252, child_key: felt252) -> felt252 { + core::poseidon::poseidon_hash_span([parent_key, child_key].span()) +} + +/// Computes the entity id from the key. +pub fn entity_id_from_key>(key: @K) -> felt252 { + entity_id_from_keys(serialize_inline::(key)) +} diff --git a/crates/dojo/core/src/utils/layout.cairo b/crates/dojo/core/src/utils/layout.cairo new file mode 100644 index 0000000000..3e09d47b93 --- /dev/null +++ b/crates/dojo/core/src/utils/layout.cairo @@ -0,0 +1,42 @@ +use dojo::meta::{Layout, FieldLayout}; + +/// find a field with its selector in a list of layouts +pub fn find_field_layout( + field_selector: felt252, field_layouts: Span +) -> Option { + let mut i = 0; + let layout = loop { + if i >= field_layouts.len() { + break Option::None; + } + + let field_layout = *field_layouts.at(i); + if field_selector == field_layout.selector { + break Option::Some(field_layout.layout); + } + + i += 1; + }; + + layout +} + +/// Find the layout of a model field based on its selector. +/// +/// # Arguments +/// +/// * `model_layout` - The full model layout (must be a Layout::Struct). +/// * `member_selector` - The model field selector. +/// +/// # Returns +/// Some(Layout) if the field layout has been found, None otherwise. +pub fn find_model_field_layout(model_layout: Layout, member_selector: felt252) -> Option { + match model_layout { + Layout::Struct(field_layouts) => { find_field_layout(member_selector, field_layouts) }, + _ => { + // should never happen as model layouts are always struct layouts. + core::panic_with_felt252('Unexpected model layout'); + Option::None + } + } +} diff --git a/crates/dojo/core/src/utils/misc.cairo b/crates/dojo/core/src/utils/misc.cairo new file mode 100644 index 0000000000..177c7ee9a7 --- /dev/null +++ b/crates/dojo/core/src/utils/misc.cairo @@ -0,0 +1,43 @@ +use core::num::traits::Zero; +use core::ops::AddAssign; +use core::option::Option; + + +/// Indicates if at least one array item is None. +pub fn any_none(arr: @Array>) -> bool { + let mut i = 0; + let mut res = false; + loop { + if i >= arr.len() { + break; + } + + if arr.at(i).is_none() { + res = true; + break; + } + i += 1; + }; + res +} + +/// Compute the sum of array items. +/// Note that there is no overflow check as we expect small array items. +pub fn sum, +Copy, +AddAssign, +Zero>(arr: Array>) -> T { + let mut i = 0; + let mut res = Zero::::zero(); + + loop { + if i >= arr.len() { + break res; + } + + match *arr.at(i) { + Option::Some(x) => res += x, + Option::None => {} + } + + i += 1; + } +} + diff --git a/crates/dojo/core/src/utils/naming.cairo b/crates/dojo/core/src/utils/naming.cairo new file mode 100644 index 0000000000..27275f808a --- /dev/null +++ b/crates/dojo/core/src/utils/naming.cairo @@ -0,0 +1,32 @@ +#[inline(always)] +fn is_letter(c: u8) -> bool { + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') +} + + +#[inline(always)] +fn is_numeric(c: u8) -> bool { + c >= '0' && c <= '9' +} + +/// Verifies that the provided name is valid according to the following RegEx: ^[a-zA-Z0-9_]+$ +pub fn is_name_valid(name: @ByteArray) -> bool { + let mut i = 0; + loop { + if i >= name.len() { + if i > 0 { + break true; + } else { + break false; + } + } + + let c = name.at(i).unwrap(); + + if !is_letter(c) && !is_numeric(c) && c != '_' { + break false; + } + + i += 1; + } +} diff --git a/crates/dojo/core/src/utils/serde.cairo b/crates/dojo/core/src/utils/serde.cairo new file mode 100644 index 0000000000..5040ff226f --- /dev/null +++ b/crates/dojo/core/src/utils/serde.cairo @@ -0,0 +1,12 @@ +pub fn serialize_inline>(value: @T) -> Span { + let mut serialized = ArrayTrait::new(); + Serde::serialize(value, ref serialized); + serialized.span() +} + +pub fn deserialize_unwrap>(mut span: Span) -> T { + match Serde::deserialize(ref span) { + Option::Some(value) => value, + Option::None => core::panic_with_felt252('Could not deserialize') + } +} diff --git a/crates/dojo/core/src/utils/snf_test.cairo b/crates/dojo/core/src/utils/snf_test.cairo new file mode 100644 index 0000000000..520e491c2e --- /dev/null +++ b/crates/dojo/core/src/utils/snf_test.cairo @@ -0,0 +1,109 @@ +use starknet::{ClassHash, ContractAddress}; +use snforge_std::{declare, ContractClassTrait, DeclareResultTrait}; +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, Resource}; +use core::panics::panic_with_byte_array; + +#[derive(Drop)] +pub enum TestResource { + Event: ByteArray, + Model: ByteArray, + Contract: ByteArray, +} + +#[derive(Drop)] +pub struct NamespaceDef { + pub namespace: ByteArray, + pub resources: Span, +} + +/// Spawns a test world registering namespaces and resources. +/// +/// # Arguments +/// +/// * `namespaces` - Namespaces to register. +/// * `resources` - Resources to register. +/// +/// # Returns +/// +/// * World dispatcher +pub fn spawn_test_world(namespaces_defs: Span) -> IWorldDispatcher { + let world_contract = declare("world").unwrap().contract_class(); + let class_hash_felt: felt252 = (*world_contract.class_hash).into(); + let (world_address, _) = world_contract.deploy(@array![class_hash_felt]).unwrap(); + + let world = IWorldDispatcher { contract_address: world_address }; + + for ns in namespaces_defs { + let namespace = ns.namespace.clone(); + world.register_namespace(namespace.clone()); + + for r in ns + .resources + .clone() { + match r { + TestResource::Event(name) => { + let ch: ClassHash = *declare(name.clone()) + .unwrap() + .contract_class() + .class_hash; + world.register_event(namespace.clone(), ch); + }, + TestResource::Model(name) => { + let ch: ClassHash = *declare(name.clone()) + .unwrap() + .contract_class() + .class_hash; + world.register_model(namespace.clone(), ch); + }, + TestResource::Contract(name) => { + let ch: ClassHash = *declare(name.clone()) + .unwrap() + .contract_class() + .class_hash; + let salt = dojo::utils::bytearray_hash(name); + world.register_contract(salt, namespace.clone(), ch); + }, + } + } + }; + + world +} + +/// Extension trait for world dispatcher to test resources. +pub trait WorldTestExt { + fn resource_contract_address( + self: IWorldDispatcher, namespace: ByteArray, name: ByteArray + ) -> ContractAddress; + fn resource_class_hash( + self: IWorldDispatcher, namespace: ByteArray, name: ByteArray + ) -> ClassHash; +} + +impl WorldTestExtImpl of WorldTestExt { + fn resource_contract_address( + self: IWorldDispatcher, namespace: ByteArray, name: ByteArray + ) -> ContractAddress { + match self.resource(dojo::utils::selector_from_names(@namespace, @name)) { + Resource::Contract((ca, _)) => ca, + Resource::Event((ca, _)) => ca, + Resource::Model((ca, _)) => ca, + _ => panic_with_byte_array( + @format!("Resource is not registered: {}-{}", namespace, name) + ) + } + } + + fn resource_class_hash( + self: IWorldDispatcher, namespace: ByteArray, name: ByteArray + ) -> ClassHash { + match self.resource(dojo::utils::selector_from_names(@namespace, @name)) { + Resource::Contract((_, ch)) => ch.try_into().unwrap(), + Resource::Event((_, ch)) => ch.try_into().unwrap(), + Resource::Model((_, ch)) => ch.try_into().unwrap(), + _ => panic_with_byte_array( + @format!("Resource is not registered: {}-{}", namespace, name) + ), + } + } +} diff --git a/crates/dojo-core/src/world/errors.cairo b/crates/dojo/core/src/world/errors.cairo similarity index 71% rename from crates/dojo-core/src/world/errors.cairo rename to crates/dojo/core/src/world/errors.cairo index a11359cf2b..9f71452d92 100644 --- a/crates/dojo-core/src/world/errors.cairo +++ b/crates/dojo/core/src/world/errors.cairo @@ -2,16 +2,10 @@ use starknet::ContractAddress; pub const DELETE_ENTITY_MEMBER: felt252 = 'Cannot delete entity member'; -pub fn no_write_access_with_tags( - contract_tag: @ByteArray, on_type: @ByteArray, on_tag: @ByteArray -) -> ByteArray { +pub fn not_writer(contract_tag: @ByteArray, on_type: @ByteArray, on_tag: @ByteArray) -> ByteArray { format!("Caller `{}` has no write access on {} `{}`", contract_tag, on_type, on_tag) } -pub fn not_owner_init(contract_tag: @ByteArray, caller: ContractAddress) -> ByteArray { - format!("Caller `{:?}` cannot initialize contract `{}` (not owner)", caller, contract_tag) -} - pub fn contract_already_initialized(contract_tag: @ByteArray) -> ByteArray { format!("Contract `{}` has already been initialized", contract_tag) } @@ -28,11 +22,23 @@ pub fn no_namespace_write_access(caller: ContractAddress, namespace: @ByteArray) format!("Caller `{:?}` has no write access on namespace `{}`", caller, namespace) } +pub fn event_already_registered(namespace: @ByteArray, name: @ByteArray) -> ByteArray { + format!("Resource `{}-{}` is already registered", namespace, name) +} + +pub fn event_not_registered(namespace: @ByteArray, name: @ByteArray) -> ByteArray { + format!("Resource `{}-{}` is not registered", namespace, name) +} + pub fn model_already_registered(namespace: @ByteArray, name: @ByteArray) -> ByteArray { format!("Resource `{}-{}` is already registered", namespace, name) } -pub fn model_not_registered(namespace: @ByteArray, name: @ByteArray) -> ByteArray { +pub fn contract_already_registered(namespace: @ByteArray, name: @ByteArray) -> ByteArray { + format!("Resource `{}-{}` is already registered", namespace, name) +} + +pub fn resource_not_registered_details(namespace: @ByteArray, name: @ByteArray) -> ByteArray { format!("Resource `{}-{}` is not registered", namespace, name) } @@ -40,10 +46,6 @@ pub fn resource_not_registered(resource: felt252) -> ByteArray { format!("Resource `{}` is not registered", resource) } -pub fn resource_already_registered(resource: felt252) -> ByteArray { - format!("Resource `{}` is already registered", resource) -} - pub fn not_owner(caller: ContractAddress, resource: felt252) -> ByteArray { format!("Caller `{:?}` is not the owner of the resource `{}`", caller, resource) } @@ -61,7 +63,7 @@ pub fn invalid_resource_selector(selector: felt252) -> ByteArray { } pub fn resource_conflict(name: @ByteArray, expected_type: @ByteArray) -> ByteArray { - format!("Resource `{}` is registered but not as a {}", name, expected_type) + format!("Resource `{}` is registered but not as {}", name, expected_type) } pub fn no_model_write_access(tag: @ByteArray, caller: ContractAddress) -> ByteArray { @@ -71,3 +73,7 @@ pub fn no_model_write_access(tag: @ByteArray, caller: ContractAddress) -> ByteAr pub fn no_world_owner(caller: ContractAddress, target: @ByteArray) -> ByteArray { format!("Caller `{:?}` can't {} (not world owner)", caller, target) } + +pub fn invalid_naming(kind: ByteArray, what: @ByteArray) -> ByteArray { + format!("{kind} `{what}` is invalid according to Dojo naming rules: ^[a-zA-Z0-9_]+$") +} diff --git a/crates/dojo/core/src/world/iworld.cairo b/crates/dojo/core/src/world/iworld.cairo new file mode 100644 index 0000000000..7cdf54af0d --- /dev/null +++ b/crates/dojo/core/src/world/iworld.cairo @@ -0,0 +1,270 @@ +//! World interface. + +use dojo::meta::Layout; +use dojo::model::{ModelIndex, ResourceMetadata}; +use starknet::{ClassHash, ContractAddress}; + +use super::resource::Resource; + +#[starknet::interface] +pub trait IUpgradeableWorld { + /// Upgrades the world with new_class_hash. + /// + /// # Arguments + /// + /// * `new_class_hash` - The new world class hash. + fn upgrade(ref self: T, new_class_hash: ClassHash); +} + +#[starknet::interface] +pub trait IWorld { + /// Returns the resource from its selector. + /// + /// # Arguments + /// * `selector` - the resource selector + /// + /// # Returns + /// * `Resource` - the resource data associated with the selector. + fn resource(self: @T, selector: felt252) -> Resource; + + /// Issues an autoincremented id to the caller. + /// This functionalities is useful to generate unique, but sequential ids. + /// + /// Note: This functionalities may impact performances since transaction paralellisation can't + /// be achieved since the same storage slot is being written. + fn uuid(ref self: T) -> usize; + + /// Returns the metadata of the resource. + /// + /// # Arguments + /// + /// `resource_selector` - The resource selector. + fn metadata(self: @T, resource_selector: felt252) -> ResourceMetadata; + + /// Sets the metadata of the resource. + /// + /// # Arguments + /// + /// `metadata` - The metadata content for the resource. + fn set_metadata(ref self: T, metadata: ResourceMetadata); + + /// Registers a namespace in the world. + /// + /// # Arguments + /// + /// * `namespace` - The name of the namespace to be registered. + fn register_namespace(ref self: T, namespace: ByteArray); + + /// Registers an event in the world. + /// + /// # Arguments + /// + /// * `namespace` - The namespace of the event to be registered. + /// * `class_hash` - The class hash of the event to be registered. + fn register_event(ref self: T, namespace: ByteArray, class_hash: ClassHash); + + /// Registers a model in the world. + /// + /// # Arguments + /// + /// * `namespace` - The namespace of the model to be registered. + /// * `class_hash` - The class hash of the model to be registered. + fn register_model(ref self: T, namespace: ByteArray, class_hash: ClassHash); + + /// Registers and deploys a contract associated with the world and returns the address of newly + /// deployed contract. + /// + /// # Arguments + /// + /// * `salt` - The salt use for contract deployment. + /// * `namespace` - The namespace of the contract to be registered. + /// * `class_hash` - The class hash of the contract. + fn register_contract( + ref self: T, salt: felt252, namespace: ByteArray, class_hash: ClassHash + ) -> ContractAddress; + + /// Initializes a contract associated registered in the world. + /// + /// As a constructor call, the initialization function can be called only once, and only + /// callable by the world itself. + /// + /// Also, the caller of this function must have the writer owner permission for the contract + /// resource. + fn init_contract(ref self: T, selector: felt252, init_calldata: Span); + + /// Upgrades an event in the world. + /// + /// # Arguments + /// + /// * `namespace` - The namespace of the event to be upgraded. + /// * `class_hash` - The class hash of the event to be upgraded. + fn upgrade_event(ref self: T, namespace: ByteArray, class_hash: ClassHash); + + /// Upgrades a model in the world. + /// + /// # Arguments + /// + /// * `namespace` - The namespace of the model to be upgraded. + /// * `class_hash` - The class hash of the model to be upgraded. + fn upgrade_model(ref self: T, namespace: ByteArray, class_hash: ClassHash); + + /// Upgrades an already deployed contract associated with the world and returns the new class + /// hash. + /// + /// # Arguments + /// + /// * `namespace` - The namespace of the contract to be upgraded. + /// * `class_hash` - The class hash of the contract. + fn upgrade_contract(ref self: T, namespace: ByteArray, class_hash: ClassHash) -> ClassHash; + + /// Emits a custom event that was previously registered in the world. + /// The dojo event emission is permissioned, since data are collected by + /// Torii and served to clients. + /// + /// # Arguments + /// + /// * `event_selector` - The selector of the event. + /// * `keys` - The keys of the event. + /// * `values` - The data to be logged by the event. + /// * `historical` - Whether the event should be logged in historical mode. + fn emit_event( + ref self: T, + event_selector: felt252, + keys: Span, + values: Span, + historical: bool + ); + + /// Gets the values of a model entity/member. + /// Returns a zero initialized model value if the entity/member has not been set. + /// + /// # Arguments + /// + /// * `model_selector` - The selector of the model to be retrieved. + /// * `index` - The index of the entity/member to read. + /// * `layout` - The memory layout of the model. + /// + /// # Returns + /// + /// * `Span` - The serialized value of the model, zero initialized if not set. + fn entity( + self: @T, model_selector: felt252, index: ModelIndex, layout: Layout + ) -> Span; + + /// Sets the model value for the given entity/member. + /// + /// # Arguments + /// + /// * `model_selector` - The selector of the model to be set. + /// * `index` - The index of the entity/member to write. + /// * `values` - The value to be set, serialized using the model layout format. + /// * `layout` - The memory layout of the model. + fn set_entity( + ref self: T, + model_selector: felt252, + index: ModelIndex, + values: Span, + layout: Layout + ); + + /// Deletes a model value for the given entity/member. + /// Deleting is setting all the values to 0 in the given layout. + /// + /// # Arguments + /// + /// * `model_selector` - The selector of the model to be deleted. + /// * `index` - The index of the entity/member to delete. + /// * `layout` - The memory layout of the model. + fn delete_entity(ref self: T, model_selector: felt252, index: ModelIndex, layout: Layout); + + /// Returns true if the provided account has owner permission for the resource, false otherwise. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `address` - The address of the contract. + fn is_owner(self: @T, resource: felt252, address: ContractAddress) -> bool; + + /// Grants owner permission to the address. + /// Can only be called by an existing owner or the world admin. + /// + /// Note that this resource must have been registered to the world first. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `address` - The address of the contract to grant owner permission to. + fn grant_owner(ref self: T, resource: felt252, address: ContractAddress); + + /// Revokes owner permission to the contract for the resource. + /// Can only be called by an existing owner or the world admin. + /// + /// Note that this resource must have been registered to the world first. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `address` - The address of the contract to revoke owner permission from. + fn revoke_owner(ref self: T, resource: felt252, address: ContractAddress); + + + /// Returns true if the provided contract has writer permission for the resource, false + /// otherwise. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `contract` - The address of the contract. + fn is_writer(self: @T, resource: felt252, contract: ContractAddress) -> bool; + + /// Grants writer permission to the contract for the resource. + /// Can only be called by an existing resource owner or the world admin. + /// + /// Note that this resource must have been registered to the world first. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `contract` - The address of the contract to grant writer permission to. + fn grant_writer(ref self: T, resource: felt252, contract: ContractAddress); + + /// Revokes writer permission to the contract for the resource. + /// Can only be called by an existing resource owner or the world admin. + /// + /// Note that this resource must have been registered to the world first. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource. + /// * `contract` - The address of the contract to revoke writer permission from. + fn revoke_writer(ref self: T, resource: felt252, contract: ContractAddress); +} + +#[starknet::interface] +#[cfg(target: "test")] +pub trait IWorldTest { + /// Sets the model value for the given entity/member without checking for resource permissions. + fn set_entity_test( + ref self: T, + model_selector: felt252, + index: ModelIndex, + values: Span, + layout: Layout + ); + + /// Deletes a model value for the given entity/member without checking for resource permissions. + fn delete_entity_test(ref self: T, model_selector: felt252, index: ModelIndex, layout: Layout); + + /// Emits a custom event that was previously registered in the world without checking for + /// resource permissions. + fn emit_event_test( + ref self: T, + event_selector: felt252, + keys: Span, + values: Span, + historical: bool + ); + + /// Returns the address of a registered contract, panics otherwise. + fn dojo_contract_address(self: @T, contract_selector: felt252) -> ContractAddress; +} diff --git a/crates/dojo/core/src/world/resource.cairo b/crates/dojo/core/src/world/resource.cairo new file mode 100644 index 0000000000..0917f6bb26 --- /dev/null +++ b/crates/dojo/core/src/world/resource.cairo @@ -0,0 +1,35 @@ +//! World's resources. + +use starknet::ContractAddress; + +/// Resource is the type of the resource that can be registered in the world. +/// +/// Caching the namespace hash of a contract and model in the world saves gas, instead +/// of re-computing the descriptor each time, which involves several poseidon hash +/// operations. +/// +/// - Model: (ContractAddress, NamespaceHash) +/// - Contract: (ContractAddress, NamespaceHash) +/// - Namespace: ByteArray +/// - World: The world itself, identified by the selector 0. +/// - Unregistered: The unregistered state. +#[derive(Drop, starknet::Store, Serde, Default, Debug)] +pub enum Resource { + Model: (ContractAddress, felt252), + Event: (ContractAddress, felt252), + Contract: (ContractAddress, felt252), + Namespace: ByteArray, + World, + #[default] + Unregistered, +} + +#[generate_trait] +pub impl ResourceIsNoneImpl of ResourceIsNoneTrait { + fn is_unregistered(self: @Resource) -> bool { + match self { + Resource::Unregistered => true, + _ => false + } + } +} diff --git a/crates/dojo/core/src/world/storage.cairo b/crates/dojo/core/src/world/storage.cairo new file mode 100644 index 0000000000..3956742ea4 --- /dev/null +++ b/crates/dojo/core/src/world/storage.cairo @@ -0,0 +1,310 @@ +//! A simple storage abstraction for the world's storage. + +use core::panic_with_felt252; +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait, Resource}; +use dojo::model::{Model, ModelIndex, ModelValueKey, ModelValue, ModelStorage, ModelPtr}; +use dojo::event::{Event, EventStorage}; +use dojo::meta::Layout; +use dojo::utils::{ + entity_id_from_key, entity_id_from_keys, serialize_inline, find_model_field_layout +}; +use starknet::{ContractAddress, ClassHash}; + +#[derive(Drop, Copy)] +pub struct WorldStorage { + pub dispatcher: IWorldDispatcher, + pub namespace_hash: felt252, +} + +#[generate_trait] +pub impl WorldStorageInternalImpl of WorldStorageTrait { + fn new(world: IWorldDispatcher, namespace: @ByteArray) -> WorldStorage { + let namespace_hash = dojo::utils::bytearray_hash(namespace); + + WorldStorage { dispatcher: world, namespace_hash } + } + + fn set_namespace(ref self: WorldStorage, namespace: @ByteArray) { + self.namespace_hash = dojo::utils::bytearray_hash(namespace); + } + + fn dns(self: @WorldStorage, contract_name: @ByteArray) -> Option<(ContractAddress, ClassHash)> { + match (*self.dispatcher) + .resource( + dojo::utils::selector_from_namespace_and_name(*self.namespace_hash, contract_name) + ) { + Resource::Contract(( + contract_address, class_hash + )) => Option::Some((contract_address, class_hash.try_into().unwrap())), + _ => Option::None + } + } + + fn contract_selector(self: @WorldStorage, contract_name: @ByteArray) -> felt252 { + dojo::utils::selector_from_namespace_and_name(*self.namespace_hash, contract_name) + } +} + +pub impl EventStorageWorldStorageImpl> of EventStorage { + fn emit_event(ref self: WorldStorage, event: @E) { + dojo::world::IWorldDispatcherTrait::emit_event( + self.dispatcher, + Event::::selector(self.namespace_hash), + Event::::keys(event), + Event::::values(event), + Event::::historical() + ); + } +} + +pub impl ModelStorageWorldStorageImpl, +Drop> of ModelStorage { + fn read_model, +Serde>(self: @WorldStorage, key: K) -> M { + let mut keys = serialize_inline::(@key); + let mut values = IWorldDispatcherTrait::entity( + *self.dispatcher, + Model::::selector(*self.namespace_hash), + ModelIndex::Keys(keys), + Model::::layout() + ); + match Model::::from_values(ref keys, ref values) { + Option::Some(model) => model, + Option::None => { + panic!( + "Model: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + ) + } + } + } + + fn write_model(ref self: WorldStorage, model: @M) { + IWorldDispatcherTrait::set_entity( + self.dispatcher, + Model::::selector(self.namespace_hash), + ModelIndex::Keys(Model::::keys(model)), + Model::::values(model), + Model::::layout() + ); + } + + fn erase_model(ref self: WorldStorage, model: @M) { + IWorldDispatcherTrait::delete_entity( + self.dispatcher, + Model::::selector(self.namespace_hash), + ModelIndex::Keys(Model::::keys(model)), + Model::::layout() + ); + } + + fn erase_model_ptr(ref self: WorldStorage, ptr: ModelPtr) { + let entity_id = match ptr { + ModelPtr::Id(id) => id, + ModelPtr::Keys(keys) => entity_id_from_keys(keys), + }; + + IWorldDispatcherTrait::delete_entity( + self.dispatcher, + Model::::selector(self.namespace_hash), + ModelIndex::Id(entity_id), + Model::::layout() + ); + } + + fn namespace_hash(self: @WorldStorage) -> felt252 { + *self.namespace_hash + } +} + +impl ModelValueStorageWorldStorageImpl< + V, +ModelValue +> of dojo::model::ModelValueStorage { + fn read_value, +Serde, +ModelValueKey>(self: @WorldStorage, key: K) -> V { + Self::read_value_from_id(self, entity_id_from_key(@key)) + } + + fn read_value_from_id(self: @WorldStorage, entity_id: felt252) -> V { + let mut values = IWorldDispatcherTrait::entity( + *self.dispatcher, + ModelValue::::selector(*self.namespace_hash), + ModelIndex::Id(entity_id), + ModelValue::::layout() + ); + match ModelValue::::from_values(entity_id, ref values) { + Option::Some(entity) => entity, + Option::None => { + panic!( + "Value: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + ) + } + } + } + + fn write_value, +Serde, +ModelValueKey>( + ref self: WorldStorage, key: K, value: @V + ) { + IWorldDispatcherTrait::set_entity( + self.dispatcher, + ModelValue::::selector(self.namespace_hash), + // We need Id here to trigger the store update event. + ModelIndex::Id(entity_id_from_keys(serialize_inline::(@key))), + ModelValue::::values(value), + ModelValue::::layout() + ); + } + + fn write_value_from_id(ref self: WorldStorage, entity_id: felt252, value: @V) { + IWorldDispatcherTrait::set_entity( + self.dispatcher, + ModelValue::::selector(self.namespace_hash), + ModelIndex::Id(entity_id), + ModelValue::::values(value), + ModelValue::::layout() + ); + } +} + +#[cfg(target: "test")] +pub impl EventStorageTestWorldStorageImpl< + E, +Event +> of dojo::event::EventStorageTest { + fn emit_event_test(ref self: WorldStorage, event: @E) { + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + dojo::world::IWorldTestDispatcherTrait::emit_event_test( + world_test, + Event::::selector(self.namespace_hash), + Event::::keys(event), + Event::::values(event), + Event::::historical() + ); + } +} + +/// Implementation of the `ModelStorageTest` trait for testing purposes, bypassing permission +/// checks. +#[cfg(target: "test")] +pub impl ModelStorageTestWorldStorageImpl< + M, +Model +> of dojo::model::ModelStorageTest { + fn write_model_test(ref self: WorldStorage, model: @M) { + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + dojo::world::IWorldTestDispatcherTrait::set_entity_test( + world_test, + Model::::selector(self.namespace_hash), + ModelIndex::Keys(Model::keys(model)), + Model::::values(model), + Model::::layout() + ); + } + + fn erase_model_test(ref self: WorldStorage, model: @M) { + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + + dojo::world::IWorldTestDispatcherTrait::delete_entity_test( + world_test, + Model::::selector(self.namespace_hash), + ModelIndex::Keys(Model::keys(model)), + Model::::layout() + ); + } + + fn erase_model_ptr_test(ref self: WorldStorage, ptr: ModelPtr) { + let entity_id = match ptr { + ModelPtr::Id(id) => id, + ModelPtr::Keys(keys) => entity_id_from_keys(keys), + }; + + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + + dojo::world::IWorldTestDispatcherTrait::delete_entity_test( + world_test, + Model::::selector(self.namespace_hash), + ModelIndex::Id(entity_id), + Model::::layout() + ); + } +} + +/// Implementation of the `ModelValueStorageTest` trait for testing purposes, bypassing permission +/// checks. +#[cfg(target: "test")] +pub impl ModelValueStorageTestWorldStorageImpl< + V, +ModelValue +> of dojo::model::ModelValueStorageTest { + fn write_value_test, +Serde, +ModelValueKey>( + ref self: WorldStorage, key: K, value: @V + ) { + let keys = serialize_inline::(@key); + Self::write_value_from_id_test(ref self, dojo::utils::entity_id_from_keys(keys), value); + } + + fn write_value_from_id_test(ref self: WorldStorage, entity_id: felt252, value: @V) { + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + + dojo::world::IWorldTestDispatcherTrait::set_entity_test( + world_test, + ModelValue::::selector(self.namespace_hash), + ModelIndex::Id(entity_id), + ModelValue::::values(value), + ModelValue::::layout() + ); + } + + fn erase_value_from_id_test(ref self: WorldStorage, entity_id: felt252) { + let world_test = dojo::world::IWorldTestDispatcher { + contract_address: self.dispatcher.contract_address + }; + + dojo::world::IWorldTestDispatcherTrait::delete_entity_test( + world_test, + ModelValue::::selector(self.namespace_hash), + ModelIndex::Id(entity_id), + ModelValue::::layout() + ); + } +} + +/// Updates a serialized member of a model. +fn update_serialized_member( + world: IWorldDispatcher, + model_id: felt252, + layout: Layout, + entity_id: felt252, + member_id: felt252, + values: Span, +) { + match find_model_field_layout(layout, member_id) { + Option::Some(field_layout) => { + IWorldDispatcherTrait::set_entity( + world, model_id, ModelIndex::MemberId((entity_id, member_id)), values, field_layout, + ) + }, + Option::None => panic_with_felt252('bad member id') + } +} + +/// Retrieves a serialized member of a model. +fn get_serialized_member( + world: IWorldDispatcher, + model_id: felt252, + layout: Layout, + entity_id: felt252, + member_id: felt252, +) -> Span { + match find_model_field_layout(layout, member_id) { + Option::Some(field_layout) => { + IWorldDispatcherTrait::entity( + world, model_id, ModelIndex::MemberId((entity_id, member_id)), field_layout + ) + }, + Option::None => panic_with_felt252('bad member id') + } +} diff --git a/crates/dojo/core/src/world/world_contract.cairo b/crates/dojo/core/src/world/world_contract.cairo new file mode 100644 index 0000000000..25b9c59346 --- /dev/null +++ b/crates/dojo/core/src/world/world_contract.cairo @@ -0,0 +1,1104 @@ +use core::fmt::{Display, Formatter, Error}; + +#[derive(Copy, Drop, PartialEq)] +pub enum Permission { + Writer, + Owner, +} + +impl PermissionDisplay of Display { + fn fmt(self: @Permission, ref f: Formatter) -> Result<(), Error> { + let str = match self { + Permission::Writer => @"WRITER", + Permission::Owner => @"OWNER", + }; + f.buffer.append(str); + Result::Ok(()) + } +} + +#[starknet::contract] +pub mod world { + use core::array::ArrayTrait; + use core::box::BoxTrait; + use core::num::traits::Zero; + use core::traits::Into; + use core::panic_with_felt252; + use core::panics::panic_with_byte_array; + + use starknet::{ + get_caller_address, get_tx_info, ClassHash, ContractAddress, + syscalls::{deploy_syscall, replace_class_syscall}, SyscallResultTrait, storage::Map, + }; + pub use starknet::storage::{ + StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess + }; + + use dojo::world::errors; + use dojo::contract::components::upgradeable::{ + IUpgradeableDispatcher, IUpgradeableDispatcherTrait + }; + use dojo::contract::{IContractDispatcher, IContractDispatcherTrait}; + use dojo::meta::Layout; + use dojo::model::{ + Model, ResourceMetadata, metadata, ModelIndex, IModelDispatcher, IModelDispatcherTrait + }; + use dojo::event::{IEventDispatcher, IEventDispatcherTrait}; + use dojo::storage; + use dojo::utils::{entity_id_from_keys, bytearray_hash, selector_from_namespace_and_name}; + use dojo::world::{IWorld, IUpgradeableWorld, Resource, ResourceIsNoneTrait}; + use super::Permission; + + pub const WORLD: felt252 = 0; + pub const DOJO_INIT_SELECTOR: felt252 = selector!("dojo_init"); + + #[event] + #[derive(Drop, starknet::Event)] + pub enum Event { + WorldSpawned: WorldSpawned, + WorldUpgraded: WorldUpgraded, + NamespaceRegistered: NamespaceRegistered, + ModelRegistered: ModelRegistered, + EventRegistered: EventRegistered, + ContractRegistered: ContractRegistered, + ModelUpgraded: ModelUpgraded, + EventUpgraded: EventUpgraded, + ContractUpgraded: ContractUpgraded, + ContractInitialized: ContractInitialized, + EventEmitted: EventEmitted, + MetadataUpdate: MetadataUpdate, + StoreSetRecord: StoreSetRecord, + StoreUpdateRecord: StoreUpdateRecord, + StoreUpdateMember: StoreUpdateMember, + StoreDelRecord: StoreDelRecord, + WriterUpdated: WriterUpdated, + OwnerUpdated: OwnerUpdated, + } + + #[derive(Drop, starknet::Event)] + pub struct WorldSpawned { + pub creator: ContractAddress, + pub class_hash: ClassHash, + } + + #[derive(Drop, starknet::Event)] + pub struct WorldUpgraded { + pub class_hash: ClassHash, + } + + #[derive(Drop, starknet::Event)] + pub struct ContractRegistered { + #[key] + pub name: ByteArray, + #[key] + pub namespace: ByteArray, + pub address: ContractAddress, + pub class_hash: ClassHash, + pub salt: felt252, + } + + #[derive(Drop, starknet::Event)] + pub struct ContractUpgraded { + #[key] + pub selector: felt252, + pub class_hash: ClassHash, + } + + #[derive(Drop, starknet::Event)] + pub struct MetadataUpdate { + #[key] + pub resource: felt252, + pub uri: ByteArray + } + + #[derive(Drop, starknet::Event)] + pub struct NamespaceRegistered { + #[key] + pub namespace: ByteArray, + pub hash: felt252 + } + + #[derive(Drop, starknet::Event)] + pub struct ModelRegistered { + #[key] + pub name: ByteArray, + #[key] + pub namespace: ByteArray, + pub class_hash: ClassHash, + pub address: ContractAddress, + } + + #[derive(Drop, starknet::Event)] + pub struct ModelUpgraded { + #[key] + pub selector: felt252, + pub class_hash: ClassHash, + pub address: ContractAddress, + pub prev_address: ContractAddress, + } + + #[derive(Drop, starknet::Event)] + pub struct EventRegistered { + #[key] + pub name: ByteArray, + #[key] + pub namespace: ByteArray, + pub class_hash: ClassHash, + pub address: ContractAddress, + } + + #[derive(Drop, starknet::Event)] + pub struct EventUpgraded { + #[key] + pub selector: felt252, + pub class_hash: ClassHash, + pub address: ContractAddress, + pub prev_address: ContractAddress, + } + + #[derive(Drop, starknet::Event)] + pub struct StoreSetRecord { + #[key] + pub selector: felt252, + #[key] + pub entity_id: felt252, + pub keys: Span, + pub values: Span, + } + + #[derive(Drop, starknet::Event)] + pub struct StoreUpdateRecord { + #[key] + pub selector: felt252, + #[key] + pub entity_id: felt252, + pub values: Span, + } + + #[derive(Drop, starknet::Event)] + pub struct StoreUpdateMember { + #[key] + pub selector: felt252, + #[key] + pub entity_id: felt252, + #[key] + pub member_selector: felt252, + pub values: Span, + } + + #[derive(Drop, starknet::Event)] + pub struct StoreDelRecord { + #[key] + pub selector: felt252, + #[key] + pub entity_id: felt252, + } + + #[derive(Drop, starknet::Event)] + pub struct WriterUpdated { + #[key] + pub resource: felt252, + #[key] + pub contract: ContractAddress, + pub value: bool + } + + #[derive(Drop, starknet::Event)] + pub struct OwnerUpdated { + #[key] + pub resource: felt252, + #[key] + pub contract: ContractAddress, + pub value: bool, + } + + #[derive(Drop, starknet::Event)] + pub struct ContractInitialized { + #[key] + pub selector: felt252, + pub init_calldata: Span, + } + + #[derive(Drop, starknet::Event)] + pub struct EventEmitted { + #[key] + pub selector: felt252, + #[key] + pub system_address: ContractAddress, + #[key] + pub historical: bool, + pub keys: Span, + pub values: Span, + } + + #[storage] + struct Storage { + nonce: usize, + models_salt: usize, + events_salt: usize, + resources: Map::, + owners: Map::<(felt252, ContractAddress), bool>, + writers: Map::<(felt252, ContractAddress), bool>, + initialized_contracts: Map::, + } + + /// Constructor for the world contract. + /// + /// # Arguments + /// + /// * `world_class_hash` - The class hash of the world contract that is being deployed. + /// As currently Starknet doesn't support a syscall to get the class hash of the + /// deploying contract, the hash of the world contract has to be provided at spawn time + /// This also ensures the world's address is always deterministic since the world class + /// hash can change when the world contract is upgraded. + #[constructor] + fn constructor(ref self: ContractState, world_class_hash: ClassHash) { + let creator = starknet::get_tx_info().unbox().account_contract_address; + + let (internal_ns, internal_ns_hash) = self.world_internal_namespace(); + + self.resources.write(internal_ns_hash, Resource::Namespace(internal_ns)); + self.owners.write((internal_ns_hash, creator), true); + + self.resources.write(WORLD, Resource::World); + self.owners.write((WORLD, creator), true); + + // This model doesn't need to have the class hash or the contract address + // set since they are manually controlled by the world contract. + self + .resources + .write( + metadata::resource_metadata_selector(internal_ns_hash), + Resource::Model( + (metadata::default_address(), metadata::default_class_hash().into()) + ) + ); + + self.emit(WorldSpawned { creator, class_hash: world_class_hash }); + } + + #[cfg(target: "test")] + #[abi(embed_v0)] + impl WorldTestImpl of dojo::world::IWorldTest { + fn set_entity_test( + ref self: ContractState, + model_selector: felt252, + index: ModelIndex, + values: Span, + layout: Layout + ) { + self.set_entity_internal(model_selector, index, values, layout); + } + + fn delete_entity_test( + ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout + ) { + self.delete_entity_internal(model_selector, index, layout); + } + + fn emit_event_test( + ref self: ContractState, + event_selector: felt252, + keys: Span, + values: Span, + historical: bool + ) { + self + .emit( + EventEmitted { + selector: event_selector, + system_address: get_caller_address(), + historical, + keys, + values + } + ); + } + + fn dojo_contract_address( + self: @ContractState, contract_selector: felt252 + ) -> ContractAddress { + match self.resources.read(contract_selector) { + Resource::Contract((a, _)) => a, + _ => core::panics::panic_with_byte_array( + @format!("Contract not registered: {}", contract_selector) + ) + } + } + } + + #[abi(embed_v0)] + impl World of IWorld { + fn metadata(self: @ContractState, resource_selector: felt252) -> ResourceMetadata { + let (_, internal_ns_hash) = self.world_internal_namespace(); + + let mut values = storage::entity_model::read_model_entity( + metadata::resource_metadata_selector(internal_ns_hash), + entity_id_from_keys([resource_selector].span()), + Model::::layout() + ); + + let mut keys = [resource_selector].span(); + + match Model::::from_values(ref keys, ref values) { + Option::Some(x) => x, + Option::None => panic!("Model `ResourceMetadata`: deserialization failed.") + } + } + + fn set_metadata(ref self: ContractState, metadata: ResourceMetadata) { + self.assert_caller_permissions(metadata.resource_id, Permission::Owner); + + let (_, internal_ns_hash) = self.world_internal_namespace(); + + storage::entity_model::write_model_entity( + metadata::resource_metadata_selector(internal_ns_hash), + metadata.resource_id, + metadata.values(), + Model::::layout() + ); + + self + .emit( + MetadataUpdate { resource: metadata.resource_id, uri: metadata.metadata_uri } + ); + } + + fn is_owner(self: @ContractState, resource: felt252, address: ContractAddress) -> bool { + self.owners.read((resource, address)) + } + + fn grant_owner(ref self: ContractState, resource: felt252, address: ContractAddress) { + if self.resources.read(resource).is_unregistered() { + panic_with_byte_array(@errors::resource_not_registered(resource)); + } + + self.assert_caller_permissions(resource, Permission::Owner); + + self.owners.write((resource, address), true); + + self.emit(OwnerUpdated { contract: address, resource, value: true }); + } + + fn revoke_owner(ref self: ContractState, resource: felt252, address: ContractAddress) { + if self.resources.read(resource).is_unregistered() { + panic_with_byte_array(@errors::resource_not_registered(resource)); + } + + self.assert_caller_permissions(resource, Permission::Owner); + + self.owners.write((resource, address), false); + + self.emit(OwnerUpdated { contract: address, resource, value: false }); + } + + fn is_writer(self: @ContractState, resource: felt252, contract: ContractAddress) -> bool { + self.writers.read((resource, contract)) + } + + fn grant_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { + if self.resources.read(resource).is_unregistered() { + panic_with_byte_array(@errors::resource_not_registered(resource)); + } + + self.assert_caller_permissions(resource, Permission::Owner); + + self.writers.write((resource, contract), true); + + self.emit(WriterUpdated { resource, contract, value: true }); + } + + fn revoke_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { + if self.resources.read(resource).is_unregistered() { + panic_with_byte_array(@errors::resource_not_registered(resource)); + } + + self.assert_caller_permissions(resource, Permission::Owner); + + self.writers.write((resource, contract), false); + + self.emit(WriterUpdated { resource, contract, value: false }); + } + + fn register_event(ref self: ContractState, namespace: ByteArray, class_hash: ClassHash) { + let caller = get_caller_address(); + let salt = self.events_salt.read(); + + let namespace_hash = bytearray_hash(@namespace); + + let (contract_address, _) = starknet::syscalls::deploy_syscall( + class_hash, salt.into(), [].span(), false, + ) + .unwrap_syscall(); + self.events_salt.write(salt + 1); + + let event = IEventDispatcher { contract_address }; + let event_name = event.dojo_name(); + + self.assert_name(@event_name); + + let event_selector = selector_from_namespace_and_name(namespace_hash, @event_name); + + if !self.is_namespace_registered(namespace_hash) { + panic_with_byte_array(@errors::namespace_not_registered(@namespace)); + } + + self.assert_caller_permissions(namespace_hash, Permission::Owner); + + let maybe_existing_event = self.resources.read(event_selector); + if !maybe_existing_event.is_unregistered() { + panic_with_byte_array(@errors::event_already_registered(@namespace, @event_name)); + } + + self + .resources + .write(event_selector, Resource::Event((contract_address, namespace_hash))); + self.owners.write((event_selector, caller), true); + + self + .emit( + EventRegistered { + name: event_name.clone(), + namespace: namespace.clone(), + address: contract_address, + class_hash + } + ); + } + + fn upgrade_event(ref self: ContractState, namespace: ByteArray, class_hash: ClassHash) { + let salt = self.events_salt.read(); + + let (new_contract_address, _) = starknet::syscalls::deploy_syscall( + class_hash, salt.into(), [].span(), false, + ) + .unwrap_syscall(); + + self.events_salt.write(salt + 1); + + let namespace_hash = bytearray_hash(@namespace); + + let event = IEventDispatcher { contract_address: new_contract_address }; + let event_name = event.dojo_name(); + let event_selector = selector_from_namespace_and_name(namespace_hash, @event_name); + + if !self.is_namespace_registered(namespace_hash) { + panic_with_byte_array(@errors::namespace_not_registered(@namespace)); + } + + self.assert_caller_permissions(event_selector, Permission::Owner); + + let mut prev_address = core::num::traits::Zero::::zero(); + + // If the namespace or name of the event have been changed, the selector + // will be different, hence not upgradeable. + match self.resources.read(event_selector) { + Resource::Event((model_address, _)) => { prev_address = model_address; }, + Resource::Unregistered => { + panic_with_byte_array( + @errors::resource_not_registered_details(@namespace, @event_name) + ) + }, + _ => panic_with_byte_array( + @errors::resource_conflict(@format!("{}-{}", @namespace, @event_name), @"event") + ) + }; + + self + .resources + .write(event_selector, Resource::Event((new_contract_address, namespace_hash))); + + self + .emit( + EventUpgraded { + selector: event_selector, + prev_address, + address: new_contract_address, + class_hash, + } + ); + } + + fn register_model(ref self: ContractState, namespace: ByteArray, class_hash: ClassHash) { + let caller = get_caller_address(); + let salt = self.models_salt.read(); + + let namespace_hash = bytearray_hash(@namespace); + + let (contract_address, _) = starknet::syscalls::deploy_syscall( + class_hash, salt.into(), [].span(), false, + ) + .unwrap_syscall(); + self.models_salt.write(salt + 1); + + let model = IModelDispatcher { contract_address }; + let model_name = model.dojo_name(); + + self.assert_name(@model_name); + + let model_selector = selector_from_namespace_and_name(namespace_hash, @model_name); + + if !self.is_namespace_registered(namespace_hash) { + panic_with_byte_array(@errors::namespace_not_registered(@namespace)); + } + + self.assert_caller_permissions(namespace_hash, Permission::Owner); + + let maybe_existing_model = self.resources.read(model_selector); + if !maybe_existing_model.is_unregistered() { + panic_with_byte_array(@errors::model_already_registered(@namespace, @model_name)); + } + + self + .resources + .write(model_selector, Resource::Model((contract_address, namespace_hash))); + self.owners.write((model_selector, caller), true); + + self + .emit( + ModelRegistered { + name: model_name.clone(), + namespace: namespace.clone(), + address: contract_address, + class_hash + } + ); + } + + fn upgrade_model(ref self: ContractState, namespace: ByteArray, class_hash: ClassHash) { + let salt = self.models_salt.read(); + + let (new_contract_address, _) = starknet::syscalls::deploy_syscall( + class_hash, salt.into(), [].span(), false, + ) + .unwrap_syscall(); + + self.models_salt.write(salt + 1); + + let namespace_hash = bytearray_hash(@namespace); + + let model = IModelDispatcher { contract_address: new_contract_address }; + let model_name = model.dojo_name(); + let model_selector = selector_from_namespace_and_name(namespace_hash, @model_name); + + if !self.is_namespace_registered(namespace_hash) { + panic_with_byte_array(@errors::namespace_not_registered(@namespace)); + } + + self.assert_caller_permissions(model_selector, Permission::Owner); + + let mut prev_address = core::num::traits::Zero::::zero(); + + // If the namespace or name of the model have been changed, the selector + // will be different, hence detected as not registered as model. + match self.resources.read(model_selector) { + Resource::Model((model_address, _)) => { prev_address = model_address; }, + Resource::Unregistered => { + panic_with_byte_array( + @errors::resource_not_registered_details(@namespace, @model_name) + ) + }, + _ => panic_with_byte_array( + @errors::resource_conflict(@format!("{}-{}", @namespace, @model_name), @"model") + ) + }; + + // TODO(@remy): check upgradeability with the actual content of the model. + // Use `prev_address` to get the previous model address and get `Ty` from it. + + self + .resources + .write(model_selector, Resource::Model((new_contract_address, namespace_hash))); + + self + .emit( + ModelUpgraded { + selector: model_selector, + prev_address, + address: new_contract_address, + class_hash, + } + ); + } + + fn register_namespace(ref self: ContractState, namespace: ByteArray) { + self.assert_namespace(@namespace); + + let caller = get_caller_address(); + + let hash = bytearray_hash(@namespace); + + match self.resources.read(hash) { + Resource::Namespace => panic_with_byte_array( + @errors::namespace_already_registered(@namespace) + ), + Resource::Unregistered => { + self.resources.write(hash, Resource::Namespace(namespace.clone())); + self.owners.write((hash, caller), true); + + self.emit(NamespaceRegistered { namespace, hash }); + }, + _ => { + panic_with_byte_array(@errors::resource_conflict(@namespace, @"namespace")); + } + }; + } + + fn register_contract( + ref self: ContractState, salt: felt252, namespace: ByteArray, class_hash: ClassHash, + ) -> ContractAddress { + let caller = get_caller_address(); + + let (contract_address, _) = deploy_syscall(class_hash, salt, [].span(), false) + .unwrap_syscall(); + + let namespace_hash = bytearray_hash(@namespace); + + let contract = IContractDispatcher { contract_address }; + let contract_name = contract.dojo_name(); + let contract_selector = selector_from_namespace_and_name( + namespace_hash, @contract_name + ); + + self.assert_name(@contract_name); + + let maybe_existing_contract = self.resources.read(contract_selector); + if !maybe_existing_contract.is_unregistered() { + panic_with_byte_array( + @errors::contract_already_registered(@namespace, @contract_name) + ); + } + + if !self.is_namespace_registered(namespace_hash) { + panic_with_byte_array(@errors::namespace_not_registered(@namespace)); + } + + self.assert_caller_permissions(namespace_hash, Permission::Owner); + + self.owners.write((contract_selector, caller), true); + self + .resources + .write(contract_selector, Resource::Contract((contract_address, namespace_hash))); + + self + .emit( + ContractRegistered { + salt, class_hash, address: contract_address, namespace, name: contract_name, + } + ); + + contract_address + } + + fn upgrade_contract( + ref self: ContractState, namespace: ByteArray, class_hash: ClassHash + ) -> ClassHash { + let (new_contract_address, _) = deploy_syscall( + class_hash, starknet::get_tx_info().unbox().transaction_hash, [].span(), false + ) + .unwrap_syscall(); + + let namespace_hash = bytearray_hash(@namespace); + + let contract = IContractDispatcher { contract_address: new_contract_address }; + let contract_name = contract.dojo_name(); + let contract_selector = selector_from_namespace_and_name( + namespace_hash, @contract_name + ); + + // If namespace and name are the same, the contract is already registered and we + // can upgrade it. + match self.resources.read(contract_selector) { + Resource::Contract(( + contract_address, _ + )) => { + self.assert_caller_permissions(contract_selector, Permission::Owner); + + IUpgradeableDispatcher { contract_address }.upgrade(class_hash); + self.emit(ContractUpgraded { class_hash, selector: contract_selector }); + + class_hash + }, + Resource::Unregistered => { + panic_with_byte_array( + @errors::resource_not_registered_details(@namespace, @contract_name) + ) + }, + _ => panic_with_byte_array( + @errors::resource_conflict( + @format!("{}-{}", @namespace, @contract_name), @"contract" + ) + ) + } + } + + fn init_contract(ref self: ContractState, selector: felt252, init_calldata: Span) { + if let Resource::Contract((contract_address, _)) = self.resources.read(selector) { + if self.initialized_contracts.read(selector) { + let dispatcher = IContractDispatcher { contract_address }; + panic_with_byte_array( + @errors::contract_already_initialized(@dispatcher.dojo_name()) + ); + } else { + self.assert_caller_permissions(selector, Permission::Owner); + + // For the init, to ensure only the world can call the init function, + // the verification is done in the init function of the contract that is + // injected by the plugin. + // + + starknet::syscalls::call_contract_syscall( + contract_address, DOJO_INIT_SELECTOR, init_calldata + ) + .unwrap_syscall(); + + self.initialized_contracts.write(selector, true); + + self.emit(ContractInitialized { selector, init_calldata }); + } + } else { + panic_with_byte_array( + @errors::resource_conflict(@format!("{selector}"), @"contract") + ); + } + } + + fn uuid(ref self: ContractState) -> usize { + let current = self.nonce.read(); + self.nonce.write(current + 1); + current + } + + fn emit_event( + ref self: ContractState, + event_selector: felt252, + keys: Span, + values: Span, + historical: bool + ) { + if let Resource::Event((_, _)) = self.resources.read(event_selector) { + self.assert_caller_permissions(event_selector, Permission::Writer); + + self + .emit( + EventEmitted { + selector: event_selector, + system_address: get_caller_address(), + historical, + keys, + values, + } + ); + } else { + panic_with_byte_array( + @errors::resource_conflict(@format!("{event_selector}"), @"event") + ); + } + } + + fn entity( + self: @ContractState, model_selector: felt252, index: ModelIndex, layout: Layout + ) -> Span { + match index { + ModelIndex::Keys(keys) => { + let entity_id = entity_id_from_keys(keys); + storage::entity_model::read_model_entity(model_selector, entity_id, layout) + }, + ModelIndex::Id(entity_id) => { + storage::entity_model::read_model_entity(model_selector, entity_id, layout) + }, + ModelIndex::MemberId(( + entity_id, member_id + )) => { + storage::entity_model::read_model_member( + model_selector, entity_id, member_id, layout + ) + } + } + } + + // set_entities_batch. (check acl once, set batch). + + fn set_entity( + ref self: ContractState, + model_selector: felt252, + index: ModelIndex, + values: Span, + layout: Layout + ) { + if let Resource::Model((_, _)) = self.resources.read(model_selector) { + self.assert_caller_permissions(model_selector, Permission::Writer); + self.set_entity_internal(model_selector, index, values, layout); + } else { + panic_with_byte_array( + @errors::resource_conflict(@format!("{model_selector}"), @"model") + ); + } + } + + fn delete_entity( + ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout + ) { + if let Resource::Model((_, _)) = self.resources.read(model_selector) { + self.assert_caller_permissions(model_selector, Permission::Writer); + self.delete_entity_internal(model_selector, index, layout); + } else { + panic_with_byte_array( + @errors::resource_conflict(@format!("{model_selector}"), @"model") + ); + } + } + + fn resource(self: @ContractState, selector: felt252) -> Resource { + self.resources.read(selector) + } + } + + #[abi(embed_v0)] + impl UpgradeableWorld of IUpgradeableWorld { + fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { + assert(new_class_hash.is_non_zero(), 'invalid class_hash'); + + if !self.is_caller_world_owner() { + panic_with_byte_array(@errors::not_owner_upgrade(get_caller_address(), WORLD)); + } + + replace_class_syscall(new_class_hash).unwrap(); + + self.emit(WorldUpgraded { class_hash: new_class_hash }); + } + } + + #[generate_trait] + impl SelfImpl of SelfTrait { + #[inline(always)] + /// Indicates if the caller is the owner of the world. + fn is_caller_world_owner(self: @ContractState) -> bool { + self.is_owner(WORLD, get_caller_address()) + } + + /// Asserts the caller has the required permissions for a resource, following the + /// permissions hierarchy: + /// 1. World Owner + /// 2. Namespace Owner + /// 3. Resource Owner + /// [if writer] + /// 4. Namespace Writer + /// 5. Resource Writer + /// + /// This function is expected to be called very often as it's used to check permissions + /// for all the resource access in the system. + /// For this reason, here are the following optimizations: + /// * Use several single `if` because it seems more efficient than a big one with + /// several conditions based on how cairo is lowered to sierra. + /// * Sort conditions by order of probability so once a condition is met, the function + /// returns. + /// + /// # Arguments + /// * `resource_selector` - the selector of the resource. + /// * `permission` - the required permission. + fn assert_caller_permissions( + self: @ContractState, resource_selector: felt252, permission: Permission + ) { + let caller = get_caller_address(); + + if permission == Permission::Writer { + if self.is_writer(resource_selector, caller) { + return; + } + } + + if self.is_owner(resource_selector, caller) { + return; + } + + if self.is_caller_world_owner() { + return; + } + + // At this point, [`Resource::Contract`] and [`Resource::Model`] requires extra checks + // by switching to the namespace hash being the resource selector. + let namespace_hash = match self.resources.read(resource_selector) { + Resource::Contract((_, namespace_hash)) => { namespace_hash }, + Resource::Model((_, namespace_hash)) => { namespace_hash }, + Resource::Event((_, namespace_hash)) => { namespace_hash }, + Resource::Unregistered => { + panic_with_byte_array(@errors::resource_not_registered(resource_selector)) + }, + _ => self.panic_with_details(caller, resource_selector, permission) + }; + + if permission == Permission::Writer { + if self.is_writer(namespace_hash, caller) { + return; + } + } + + if self.is_owner(namespace_hash, caller) { + return; + } + + self.panic_with_details(caller, resource_selector, permission) + } + + /// Asserts the name is valid according to the naming convention. + fn assert_name(self: @ContractState, name: @ByteArray) { + if !dojo::utils::is_name_valid(name) { + panic_with_byte_array(@errors::invalid_naming("Name", name)) + } + } + + /// Asserts the namespace is valid according to the naming convention. + fn assert_namespace(self: @ContractState, namespace: @ByteArray) { + if !dojo::utils::is_name_valid(namespace) { + panic_with_byte_array(@errors::invalid_naming("Namespace", namespace)) + } + } + + /// Panics with the caller details. + /// + /// # Arguments + /// * `caller` - the address of the caller. + /// * `resource_selector` - the selector of the resource. + /// * `permission` - the required permission. + fn panic_with_details( + self: @ContractState, + caller: ContractAddress, + resource_selector: felt252, + permission: Permission + ) -> core::never { + let resource_name = match self.resources.read(resource_selector) { + Resource::Contract(( + contract_address, _ + )) => { + let d = IContractDispatcher { contract_address }; + format!("contract (or its namespace) `{}`", d.dojo_name()) + }, + Resource::Event(( + contract_address, _ + )) => { + let d = IEventDispatcher { contract_address }; + format!("event (or its namespace) `{}`", d.dojo_name()) + }, + Resource::Model(( + contract_address, _ + )) => { + let d = IModelDispatcher { contract_address }; + format!("model (or its namespace) `{}`", d.dojo_name()) + }, + Resource::Namespace(ns) => { format!("namespace `{}`", ns) }, + Resource::World => { format!("world") }, + Resource::Unregistered => { panic!("Unreachable") } + }; + + let caller_name = if caller == get_tx_info().account_contract_address { + format!("Account `{:?}`", caller) + } else { + // If the caller is not a dojo contract, the `d.selector()` will fail. In the + // future we should use the SRC5 to first query the contract to see if + // it implements the `IDescriptor` interface. + // For now, we just assume that the caller is a dojo contract as it's 100% of + // the dojo use cases at the moment. + // If the contract is not an account or a dojo contract, tests will display + // "CONTRACT_NOT_DEPLOYED" as the error message. In production, the error message + // will display "ENTRYPOINT_NOT_FOUND". + let d = IContractDispatcher { contract_address: caller }; + format!("Contract `{}`", d.dojo_name()) + }; + + panic_with_byte_array( + @format!("{} does NOT have {} role on {}", caller_name, permission, resource_name) + ) + } + + /// Indicates if the provided namespace is already registered + /// + /// # Arguments + /// * `namespace_hash` - the hash of the namespace. + #[inline(always)] + fn is_namespace_registered(self: @ContractState, namespace_hash: felt252) -> bool { + match self.resources.read(namespace_hash) { + Resource::Namespace => true, + _ => false + } + } + + /// Sets the model value for a model record/entity/member. + /// + /// # Arguments + /// + /// * `model_selector` - The selector of the model to be set. + /// * `index` - The index of the record/entity/member to write. + /// * `values` - The value to be set, serialized using the model layout format. + /// * `layout` - The memory layout of the model. + fn set_entity_internal( + ref self: ContractState, + model_selector: felt252, + index: ModelIndex, + values: Span, + layout: Layout + ) { + match index { + ModelIndex::Keys(keys) => { + let entity_id = entity_id_from_keys(keys); + storage::entity_model::write_model_entity( + model_selector, entity_id, values, layout + ); + self.emit(StoreSetRecord { selector: model_selector, keys, values, entity_id }); + }, + ModelIndex::Id(entity_id) => { + storage::entity_model::write_model_entity( + model_selector, entity_id, values, layout + ); + self.emit(StoreUpdateRecord { selector: model_selector, entity_id, values }); + }, + ModelIndex::MemberId(( + entity_id, member_selector + )) => { + storage::entity_model::write_model_member( + model_selector, entity_id, member_selector, values, layout + ); + self + .emit( + StoreUpdateMember { + selector: model_selector, entity_id, member_selector, values + } + ); + } + } + } + + /// Deletes an entity for the given model, setting all the values to 0 in the given layout. + /// + /// # Arguments + /// + /// * `model_selector` - The selector of the model to be deleted. + /// * `index` - The index of the record/entity to delete. + /// * `layout` - The memory layout of the model. + fn delete_entity_internal( + ref self: ContractState, model_selector: felt252, index: ModelIndex, layout: Layout + ) { + match index { + ModelIndex::Keys(keys) => { + let entity_id = entity_id_from_keys(keys); + storage::entity_model::delete_model_entity(model_selector, entity_id, layout); + self.emit(StoreDelRecord { selector: model_selector, entity_id }); + }, + ModelIndex::Id(entity_id) => { + storage::entity_model::delete_model_entity(model_selector, entity_id, layout); + self.emit(StoreDelRecord { selector: model_selector, entity_id }); + }, + ModelIndex::MemberId(_) => { panic_with_felt252(errors::DELETE_ENTITY_MEMBER); } + } + } + + /// Returns the hash of the internal namespace for a dojo world. + fn world_internal_namespace(self: @ContractState) -> (ByteArray, felt252) { + let name = "__DOJO__"; + let hash = bytearray_hash(@name); + + (name, hash) + } + } +} diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo/lang/Cargo.toml similarity index 83% rename from crates/dojo-lang/Cargo.toml rename to crates/dojo/lang/Cargo.toml index 54856968ca..d65f3e18ba 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo/lang/Cargo.toml @@ -1,5 +1,5 @@ [package] -description = "Dojo capabilities and utilities on top of Starknet." +description = "Cairo compiler plugin for Dojo." edition.workspace = true license-file.workspace = true name = "dojo-lang" @@ -15,7 +15,6 @@ cairo-lang-compiler.workspace = true cairo-lang-defs.workspace = true cairo-lang-diagnostics.workspace = true cairo-lang-filesystem.workspace = true -cairo-lang-formatter.workspace = true cairo-lang-plugins.workspace = true cairo-lang-project.workspace = true cairo-lang-semantic.workspace = true @@ -28,27 +27,26 @@ cairo-lang-utils.workspace = true camino.workspace = true convert_case.workspace = true dojo-types.workspace = true -dojo-world = { workspace = true, features = [ "manifest", "metadata" ] } indoc.workspace = true itertools.workspace = true regex.workspace = true -scarb.workspace = true -scarb-ui.workspace = true semver.workspace = true serde.workspace = true serde_json.workspace = true +serde_with.workspace = true smol_str.workspace = true starknet.workspace = true +tempfile.workspace = true toml.workspace = true tracing.workspace = true url.workspace = true [dev-dependencies] +assert_fs.workspace = true cairo-lang-debug.workspace = true cairo-lang-parser.workspace = true cairo-lang-semantic.workspace = true cairo-lang-test-utils.workspace = true -dojo-test-utils.workspace = true once_cell.workspace = true salsa.workspace = true test-log.workspace = true diff --git a/crates/dojo/lang/README.md b/crates/dojo/lang/README.md new file mode 100644 index 0000000000..6c2608868d --- /dev/null +++ b/crates/dojo/lang/README.md @@ -0,0 +1,11 @@ +# Cairo compiler plugin for Dojo + +Cairo compiler plugin to compile Dojo specific macros. + +## Testing + +To regenerate the test data, set `CAIRO_FIX_TESTS=1`: + +``` +CAIRO_FIX_TESTS=1 cargo test -p dojo-compiler +``` diff --git a/crates/dojo-core/Scarb.lock b/crates/dojo/lang/Scarb.lock similarity index 61% rename from crates/dojo-core/Scarb.lock rename to crates/dojo/lang/Scarb.lock index a3f7615a66..2f26886db2 100644 --- a/crates/dojo-core/Scarb.lock +++ b/crates/dojo/lang/Scarb.lock @@ -2,5 +2,5 @@ version = 1 [[package]] -name = "dojo" -version = "1.0.0-alpha.4" +name = "dojo_plugin" +version = "2.8.4" diff --git a/crates/dojo-lang/Scarb.toml b/crates/dojo/lang/Scarb.toml similarity index 58% rename from crates/dojo-lang/Scarb.toml rename to crates/dojo/lang/Scarb.toml index 11db8dff61..6371a4614c 100644 --- a/crates/dojo-lang/Scarb.toml +++ b/crates/dojo/lang/Scarb.toml @@ -1,5 +1,6 @@ [package] name = "dojo_plugin" -version = "1.0.0-alpha.4" +version = "2.8.4" [cairo-plugin] +builtin = true diff --git a/crates/dojo/lang/src/attribute_macros/contract.rs b/crates/dojo/lang/src/attribute_macros/contract.rs new file mode 100644 index 0000000000..2f9c94c9b7 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/contract.rs @@ -0,0 +1,373 @@ +use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; +use cairo_lang_defs::plugin::{ + DynGeneratedFileAuxData, MacroPluginMetadata, PluginDiagnostic, PluginGeneratedFile, + PluginResult, +}; +use cairo_lang_diagnostics::Severity; +use cairo_lang_plugins::plugins::HasItemsInCfgEx; +use cairo_lang_syntax::node::ast::{MaybeModuleBody, OptionReturnTypeClause}; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::{ast, Terminal, TypedStablePtr, TypedSyntaxNode}; +use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; +use dojo_types::naming; + +use crate::aux_data::ContractAuxData; + +const CONTRACT_PATCH: &str = include_str!("./patches/contract.patch.cairo"); +const DEFAULT_INIT_PATCH: &str = include_str!("./patches/default_init.patch.cairo"); +const CONSTRUCTOR_FN: &str = "constructor"; +const DOJO_INIT_FN: &str = "dojo_init"; + +#[derive(Debug, Clone, Default)] +pub struct ContractParameters { + pub namespace: Option, +} + +#[derive(Debug)] +pub struct DojoContract { + diagnostics: Vec, + systems: Vec, +} + +impl DojoContract { + pub fn from_module( + db: &dyn SyntaxGroup, + module_ast: &ast::ItemModule, + metadata: &MacroPluginMetadata<'_>, + ) -> PluginResult { + let name = module_ast.name(db).text(db); + + let mut contract = DojoContract { diagnostics: vec![], systems: vec![] }; + + for (id, value) in [("name", &name.to_string())] { + if !naming::is_name_valid(value) { + return PluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: module_ast.stable_ptr().0, + message: format!( + "The contract {id} '{value}' can only contain characters (a-z/A-Z), \ + digits (0-9) and underscore (_)." + ), + severity: Severity::Error, + }], + remove_original_item: false, + }; + } + } + + let mut has_event = false; + let mut has_storage = false; + let mut has_init = false; + let mut has_constructor = false; + + if let MaybeModuleBody::Some(body) = module_ast.body(db) { + let mut body_nodes: Vec<_> = body + .iter_items_in_cfg(db, metadata.cfg_set) + .flat_map(|el| { + if let ast::ModuleItem::Enum(ref enum_ast) = el { + if enum_ast.name(db).text(db).to_string() == "Event" { + has_event = true; + return contract.merge_event(db, enum_ast.clone()); + } + } else if let ast::ModuleItem::Struct(ref struct_ast) = el { + if struct_ast.name(db).text(db).to_string() == "Storage" { + has_storage = true; + return contract.merge_storage(db, struct_ast.clone()); + } + } else if let ast::ModuleItem::FreeFunction(ref fn_ast) = el { + let fn_decl = fn_ast.declaration(db); + let fn_name = fn_decl.name(db).text(db); + + if fn_name == CONSTRUCTOR_FN { + has_constructor = true; + return contract.handle_constructor_fn(db, fn_ast); + } + + if fn_name == DOJO_INIT_FN { + has_init = true; + return contract.handle_init_fn(db, fn_ast); + } + } + + vec![RewriteNode::Copied(el.as_syntax_node())] + }) + .collect(); + + if !has_constructor { + let node = RewriteNode::Text( + " + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + " + .to_string(), + ); + + body_nodes.append(&mut vec![node]); + } + + if !has_init { + let node = RewriteNode::interpolate_patched( + DEFAULT_INIT_PATCH, + &UnorderedHashMap::from([( + "init_name".to_string(), + RewriteNode::Text(DOJO_INIT_FN.to_string()), + )]), + ); + body_nodes.append(&mut vec![node]); + } + + if !has_event { + body_nodes.append(&mut contract.create_event()) + } + + if !has_storage { + body_nodes.append(&mut contract.create_storage()) + } + + let mut builder = PatchBuilder::new(db, module_ast); + builder.add_modified(RewriteNode::Mapped { + node: Box::new(RewriteNode::interpolate_patched( + CONTRACT_PATCH, + &UnorderedHashMap::from([ + ("name".to_string(), RewriteNode::Text(name.to_string())), + ("body".to_string(), RewriteNode::new_modified(body_nodes)), + ]), + )), + origin: module_ast.as_syntax_node().span_without_trivia(db), + }); + + let (code, code_mappings) = builder.build(); + + crate::debug_expand(&format!("CONTRACT PATCH: {name}"), &code); + + return PluginResult { + code: Some(PluginGeneratedFile { + name: name.clone(), + content: code, + aux_data: Some(DynGeneratedFileAuxData::new(ContractAuxData { + name: name.to_string(), + systems: contract.systems.clone(), + })), + code_mappings, + }), + diagnostics: contract.diagnostics, + remove_original_item: true, + }; + } + + PluginResult::default() + } + + /// If a constructor is provided, we should keep the user statements. + /// We only inject the world provider initializer. + fn handle_constructor_fn( + &mut self, + db: &dyn SyntaxGroup, + fn_ast: &ast::FunctionWithBody, + ) -> Vec { + let fn_decl = fn_ast.declaration(db); + + let params_str = self.params_to_str(db, fn_decl.signature(db).parameters(db)); + + let declaration_node = RewriteNode::Mapped { + node: Box::new(RewriteNode::Text(format!( + " + #[constructor] + fn constructor({}) {{ + self.world_provider.initializer(); + ", + params_str + ))), + origin: fn_ast.declaration(db).as_syntax_node().span_without_trivia(db), + }; + + let func_nodes = fn_ast + .body(db) + .statements(db) + .elements(db) + .iter() + .map(|e| RewriteNode::Mapped { + node: Box::new(RewriteNode::from(e.as_syntax_node())), + origin: e.as_syntax_node().span_without_trivia(db), + }) + .collect::>(); + + let mut nodes = vec![declaration_node]; + + nodes.extend(func_nodes); + + // Close the constructor with users statements included. + nodes.push(RewriteNode::Text("}\n".to_string())); + + nodes + } + + fn handle_init_fn( + &mut self, + db: &dyn SyntaxGroup, + fn_ast: &ast::FunctionWithBody, + ) -> Vec { + let fn_decl = fn_ast.declaration(db); + + if let OptionReturnTypeClause::ReturnTypeClause(_) = fn_decl.signature(db).ret_ty(db) { + self.diagnostics.push(PluginDiagnostic { + stable_ptr: fn_ast.stable_ptr().untyped(), + message: format!("The {} function cannot have a return type.", DOJO_INIT_FN) + .to_string(), + severity: Severity::Error, + }); + } + + let params: Vec = fn_decl + .signature(db) + .parameters(db) + .elements(db) + .iter() + .map(|p| p.as_syntax_node().get_text(db)) + .collect::>(); + + let params_str = params.join(", "); + + // Since the dojo init is meant to be called by the world, we don't need an + // interface to be generated (which adds a considerable amount of code). + let impl_node = RewriteNode::Text( + " + #[abi(per_item)] + #[generate_trait] + pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + " + .to_string(), + ); + + let declaration_node = RewriteNode::Mapped { + node: Box::new(RewriteNode::Text(format!("fn {}({}) {{", DOJO_INIT_FN, params_str))), + origin: fn_ast.declaration(db).as_syntax_node().span_without_trivia(db), + }; + + // Asserts the caller is the world, and close the init function. + let assert_world_caller_node = RewriteNode::Text( + "if starknet::get_caller_address() != \ + self.world_provider.world_dispatcher().contract_address { \ + core::panics::panic_with_byte_array(@format!(\"Only the world can init contract \ + `{}`, but caller is `{:?}`\", self.dojo_name(), starknet::get_caller_address())); }" + .to_string(), + ); + + let func_nodes = fn_ast + .body(db) + .statements(db) + .elements(db) + .iter() + .map(|e| RewriteNode::Mapped { + node: Box::new(RewriteNode::from(e.as_syntax_node())), + origin: e.as_syntax_node().span_without_trivia(db), + }) + .collect::>(); + + let mut nodes = vec![impl_node, declaration_node, assert_world_caller_node]; + nodes.extend(func_nodes); + // Close the init function + close the impl block. + nodes.push(RewriteNode::Text("}\n}".to_string())); + + nodes + } + + pub fn merge_event( + &mut self, + db: &dyn SyntaxGroup, + enum_ast: ast::ItemEnum, + ) -> Vec { + let mut rewrite_nodes = vec![]; + + let elements = enum_ast.variants(db).elements(db); + + let variants = elements.iter().map(|e| e.as_syntax_node().get_text(db)).collect::>(); + let variants = variants.join(",\n"); + + rewrite_nodes.push(RewriteNode::interpolate_patched( + " + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + $variants$ + } + ", + &UnorderedHashMap::from([("variants".to_string(), RewriteNode::Text(variants))]), + )); + rewrite_nodes + } + + pub fn create_event(&mut self) -> Vec { + vec![RewriteNode::Text( + " + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + " + .to_string(), + )] + } + + pub fn merge_storage( + &mut self, + db: &dyn SyntaxGroup, + struct_ast: ast::ItemStruct, + ) -> Vec { + let mut rewrite_nodes = vec![]; + + let elements = struct_ast.members(db).elements(db); + + let members = elements.iter().map(|e| e.as_syntax_node().get_text(db)).collect::>(); + let members = members.join(",\n"); + + rewrite_nodes.push(RewriteNode::interpolate_patched( + " + #[storage] + struct Storage { + #[substorage(v0)] + upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + world_provider: world_provider_cpt::Storage, + $members$ + } + ", + &UnorderedHashMap::from([("members".to_string(), RewriteNode::Text(members))]), + )); + rewrite_nodes + } + + pub fn create_storage(&mut self) -> Vec { + vec![RewriteNode::Text( + " + #[storage] + struct Storage { + #[substorage(v0)] + upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + world_provider: world_provider_cpt::Storage, + } + " + .to_string(), + )] + } + + /// Converts parameter list to it's string representation. + pub fn params_to_str(&mut self, db: &dyn SyntaxGroup, param_list: ast::ParamList) -> String { + let params = param_list + .elements(db) + .iter() + .map(|param| param.as_syntax_node().get_text(db)) + .collect::>(); + + params.join(", ") + } +} diff --git a/crates/dojo/lang/src/attribute_macros/element.rs b/crates/dojo/lang/src/attribute_macros/element.rs new file mode 100644 index 0000000000..9a75bc1e73 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/element.rs @@ -0,0 +1,256 @@ +use std::collections::HashMap; + +use cairo_lang_defs::patcher::RewriteNode; +use cairo_lang_defs::plugin::PluginDiagnostic; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::node::ast::{ + ArgClause, ArgClauseNamed, Expr, ItemStruct, Member as MemberAst, OptionArgListParenthesized, +}; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::helpers::QueryAttrs; +use cairo_lang_syntax::node::{Terminal, TypedStablePtr, TypedSyntaxNode}; + +use crate::aux_data::Member; + +pub const DEFAULT_VERSION: u8 = 1; + +pub const PARAMETER_VERSION_NAME: &str = "version"; + +/// `StructParameterParser` provides a general `from_struct` function to parse +/// the parameters of a struct attribute like dojo::model or dojo::event. +/// +/// Processing of specific parameters can then be implemented through the `process_named_parameters` +/// function. +pub trait StructParameterParser { + fn load_from_struct( + &mut self, + db: &dyn SyntaxGroup, + attribute_name: &String, + struct_ast: ItemStruct, + diagnostics: &mut Vec, + ) { + let mut processed_args: HashMap = HashMap::new(); + + if let OptionArgListParenthesized::ArgListParenthesized(arguments) = + struct_ast.attributes(db).query_attr(db, attribute_name).first().unwrap().arguments(db) + { + arguments.arguments(db).elements(db).iter().for_each(|a| match a.arg_clause(db) { + ArgClause::Named(x) => { + let arg_name = x.name(db).text(db).to_string(); + + if processed_args.contains_key(&arg_name) { + diagnostics.push(PluginDiagnostic { + message: format!( + "Too many '{}' attributes for {attribute_name}", + arg_name + ), + stable_ptr: struct_ast.stable_ptr().untyped(), + severity: Severity::Error, + }); + } else { + processed_args.insert(arg_name.clone(), true); + self.process_named_parameters(db, attribute_name, x, diagnostics); + } + } + ArgClause::Unnamed(x) => { + diagnostics.push(PluginDiagnostic { + message: format!( + "Unexpected argument '{}' for {attribute_name}", + x.as_syntax_node().get_text(db) + ), + stable_ptr: x.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + ArgClause::FieldInitShorthand(x) => { + diagnostics.push(PluginDiagnostic { + message: format!( + "Unexpected argument '{}' for {attribute_name}", + x.name(db).name(db).text(db).to_string() + ), + stable_ptr: x.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + }) + } + } + + fn process_named_parameters( + &mut self, + db: &dyn SyntaxGroup, + attribute_name: &str, + arg: ArgClauseNamed, + diagnostics: &mut Vec, + ); +} + +#[derive(Debug)] +pub struct CommonStructParameters { + pub version: u8, +} + +impl Default for CommonStructParameters { + fn default() -> CommonStructParameters { + CommonStructParameters { version: DEFAULT_VERSION } + } +} + +impl StructParameterParser for CommonStructParameters { + fn process_named_parameters( + &mut self, + db: &dyn SyntaxGroup, + attribute_name: &str, + arg: ArgClauseNamed, + diagnostics: &mut Vec, + ) { + let arg_name = arg.name(db).text(db).to_string(); + let arg_value = arg.value(db); + + match arg_name.as_str() { + PARAMETER_VERSION_NAME => { + self.version = get_version(db, attribute_name, arg_value, diagnostics); + } + _ => { + diagnostics.push(PluginDiagnostic { + message: format!("Unexpected argument '{}' for {attribute_name}", arg_name), + stable_ptr: arg.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + } + } +} + +pub fn parse_members( + db: &dyn SyntaxGroup, + members: &[MemberAst], + diagnostics: &mut Vec, +) -> Vec { + members + .iter() + .filter_map(|member_ast| { + let member = Member { + name: member_ast.name(db).text(db).to_string(), + ty: member_ast + .type_clause(db) + .ty(db) + .as_syntax_node() + .get_text(db) + .trim() + .to_string(), + key: member_ast.has_attr(db, "key"), + }; + + // validate key member + if member.key && member.ty == "u256" { + diagnostics.push(PluginDiagnostic { + message: "Key is only supported for core types that are 1 felt long once \ + serialized. `u256` is a struct of 2 u128, hence not supported." + .into(), + stable_ptr: member_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + None + } else { + Some(member) + } + }) + .collect::>() +} + +pub fn serialize_keys_and_values( + members: &[Member], + serialized_keys: &mut Vec, + serialized_values: &mut Vec, +) { + members.iter().for_each(|member| { + if member.key { + serialized_keys.push(serialize_member_ty(member, true)); + } else { + serialized_values.push(serialize_member_ty(member, true)); + } + }); +} + +pub fn deserialize_keys_and_values( + members: &[Member], + keys_input_name: &str, + deserialized_keys: &mut Vec, + values_input_name: &str, + deserialized_values: &mut Vec, +) { + members.iter().for_each(|member| { + if member.key { + deserialized_keys.push(deserialize_member_ty(member, keys_input_name)); + } else { + deserialized_values.push(deserialize_member_ty(member, values_input_name)); + } + }); +} + +/// Creates a [`RewriteNode`] for the member type serialization. +/// +/// # Arguments +/// +/// * member: The member to serialize. +pub fn serialize_member_ty(member: &Member, with_self: bool) -> RewriteNode { + RewriteNode::Text(format!( + "core::serde::Serde::serialize({}{}, ref serialized);\n", + if with_self { "self." } else { "@" }, + member.name + )) +} + +pub fn deserialize_member_ty(member: &Member, input_name: &str) -> RewriteNode { + RewriteNode::Text(format!( + "let {} = core::serde::Serde::<{}>::deserialize(ref {input_name})?;\n", + member.name, member.ty + )) +} + +/// Get the version from the `Expr` parameter. +fn get_version( + db: &dyn SyntaxGroup, + attribute_name: &str, + arg_value: Expr, + diagnostics: &mut Vec, +) -> u8 { + match arg_value { + Expr::Literal(ref value) => { + if let Ok(value) = value.text(db).parse::() { + if value <= DEFAULT_VERSION { + value + } else { + diagnostics.push(PluginDiagnostic { + message: format!("{attribute_name} version {} not supported", value), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + DEFAULT_VERSION + } + } else { + diagnostics.push(PluginDiagnostic { + message: format!( + "The argument '{}' of {attribute_name} must be an integer", + PARAMETER_VERSION_NAME + ), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + DEFAULT_VERSION + } + } + _ => { + diagnostics.push(PluginDiagnostic { + message: format!( + "The argument '{}' of {attribute_name} must be an integer", + PARAMETER_VERSION_NAME + ), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + DEFAULT_VERSION + } + } +} diff --git a/crates/dojo/lang/src/attribute_macros/event.rs b/crates/dojo/lang/src/attribute_macros/event.rs new file mode 100644 index 0000000000..faef8ee2e0 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/event.rs @@ -0,0 +1,226 @@ +//! A custom implementation of the starknet::Event derivation path. +//! +//! We append the event selector directly within the append_keys_and_data function. +//! Without the need of the enum for all event variants. +//! +//! + +use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; +use cairo_lang_defs::plugin::{ + DynGeneratedFileAuxData, PluginDiagnostic, PluginGeneratedFile, PluginResult, +}; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::node::ast::{ArgClauseNamed, Expr, ModuleItem}; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::helpers::QueryAttrs; +use cairo_lang_syntax::node::{ast, Terminal, TypedStablePtr, TypedSyntaxNode}; +use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; +use dojo_types::naming; + +use super::element::{ + parse_members, serialize_keys_and_values, CommonStructParameters, StructParameterParser, +}; +use crate::aux_data::EventAuxData; +use crate::derive_macros::{ + extract_derive_attr_names, handle_derive_attrs, DOJO_INTROSPECT_DERIVE, DOJO_PACKED_DERIVE, +}; + +const EVENT_PATCH: &str = include_str!("./patches/event.patch.cairo"); +use super::DOJO_EVENT_ATTR; + +pub const PARAMETER_HISTORICAL: &str = "historical"; +pub const DEFAULT_HISTORICAL_VALUE: bool = false; + +#[derive(Debug)] +struct EventParameters { + common: CommonStructParameters, + historical: bool, +} + +impl Default for EventParameters { + fn default() -> EventParameters { + EventParameters { + common: CommonStructParameters::default(), + historical: DEFAULT_HISTORICAL_VALUE, + } + } +} + +impl StructParameterParser for EventParameters { + fn process_named_parameters( + &mut self, + db: &dyn SyntaxGroup, + attribute_name: &str, + arg: ArgClauseNamed, + diagnostics: &mut Vec, + ) { + match arg.name(db).text(db).as_str() { + PARAMETER_HISTORICAL => { + self.historical = get_historical(attribute_name, arg.value(db), diagnostics); + } + _ => { + self.common.process_named_parameters(db, attribute_name, arg, diagnostics); + } + } + } +} + +#[derive(Debug, Clone, Default)] +pub struct DojoEvent {} + +impl DojoEvent { + /// A handler for Dojo code that modifies an event struct. + /// Parameters: + /// * db: The semantic database. + /// * struct_ast: The AST of the event struct. + /// + /// Returns: + /// * A RewriteNode containing the generated code. + pub fn from_struct(db: &dyn SyntaxGroup, struct_ast: ast::ItemStruct) -> PluginResult { + let mut diagnostics = vec![]; + let mut parameters = EventParameters::default(); + + parameters.load_from_struct( + db, + &DOJO_EVENT_ATTR.to_string(), + struct_ast.clone(), + &mut diagnostics, + ); + + let event_name = struct_ast.name(db).as_syntax_node().get_text(db).trim().to_string(); + + for (id, value) in [("name", &event_name)] { + if !naming::is_name_valid(value) { + return PluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: struct_ast.stable_ptr().0, + message: format!( + "The event {id} '{value}' can only contain characters (a-z/A-Z), \ + digits (0-9) and underscore (_)." + ), + severity: Severity::Error, + }], + remove_original_item: false, + }; + } + } + + let event_version = parameters.common.version.to_string(); + let event_historical = parameters.historical.to_string(); + + let members = parse_members(db, &struct_ast.members(db).elements(db), &mut diagnostics); + + let mut serialized_keys: Vec = vec![]; + let mut serialized_values: Vec = vec![]; + + serialize_keys_and_values(&members, &mut serialized_keys, &mut serialized_values); + + if serialized_keys.is_empty() { + diagnostics.push(PluginDiagnostic { + message: "Event must define at least one #[key] attribute".into(), + stable_ptr: struct_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + } + + if serialized_values.is_empty() { + diagnostics.push(PluginDiagnostic { + message: "Event must define at least one member that is not a key".into(), + stable_ptr: struct_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + } + + let member_names = members + .iter() + .map(|member| RewriteNode::Text(format!("{},\n", member.name.clone()))) + .collect::>(); + + let mut derive_attr_names = extract_derive_attr_names( + db, + &mut diagnostics, + struct_ast.attributes(db).query_attr(db, "derive"), + ); + + // Ensures events always derive Introspect if not already derived, + // and do not derive IntrospectPacked. + if derive_attr_names.contains(&DOJO_PACKED_DERIVE.to_string()) { + diagnostics.push(PluginDiagnostic { + message: format!( + "Event should derive {DOJO_INTROSPECT_DERIVE} instead of {DOJO_PACKED_DERIVE}." + ), + stable_ptr: struct_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + } + + if !derive_attr_names.contains(&DOJO_INTROSPECT_DERIVE.to_string()) { + derive_attr_names.push(DOJO_INTROSPECT_DERIVE.to_string()); + } + + let (derive_nodes, derive_diagnostics) = + handle_derive_attrs(db, &derive_attr_names, &ModuleItem::Struct(struct_ast.clone())); + + diagnostics.extend(derive_diagnostics); + + let node = RewriteNode::interpolate_patched( + EVENT_PATCH, + &UnorderedHashMap::from([ + ("type_name".to_string(), RewriteNode::Text(event_name.clone())), + ("member_names".to_string(), RewriteNode::new_modified(member_names)), + ("serialized_keys".to_string(), RewriteNode::new_modified(serialized_keys)), + ("serialized_values".to_string(), RewriteNode::new_modified(serialized_values)), + ("event_version".to_string(), RewriteNode::Text(event_version)), + ("event_historical".to_string(), RewriteNode::Text(event_historical)), + ]), + ); + + let mut builder = PatchBuilder::new(db, &struct_ast); + + for node in derive_nodes { + builder.add_modified(node); + } + + builder.add_modified(node); + + let (code, code_mappings) = builder.build(); + + crate::debug_expand(&format!("EVENT PATCH: {event_name}"), &code); + + let aux_data = EventAuxData { name: event_name.clone(), members }; + + PluginResult { + code: Some(PluginGeneratedFile { + name: event_name.into(), + content: code, + aux_data: Some(DynGeneratedFileAuxData::new(aux_data)), + code_mappings, + }), + diagnostics, + remove_original_item: false, + } + } +} + +/// Get the historical boolean parameter from the `Expr` parameter. +fn get_historical( + attribute_name: &str, + arg_value: Expr, + diagnostics: &mut Vec, +) -> bool { + match arg_value { + Expr::True(_) => true, + Expr::False(_) => false, + _ => { + diagnostics.push(PluginDiagnostic { + message: format!( + "The argument '{PARAMETER_HISTORICAL}' of {attribute_name} must be a boolean", + ), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + DEFAULT_HISTORICAL_VALUE + } + } +} diff --git a/crates/dojo-lang/src/interface.rs b/crates/dojo/lang/src/attribute_macros/interface.rs similarity index 93% rename from crates/dojo-lang/src/interface.rs rename to crates/dojo/lang/src/attribute_macros/interface.rs index 68bdee54bb..7e257095c4 100644 --- a/crates/dojo-lang/src/interface.rs +++ b/crates/dojo/lang/src/attribute_macros/interface.rs @@ -19,12 +19,12 @@ pub struct DojoInterface { impl DojoInterface { pub fn from_trait( db: &dyn SyntaxGroup, - trait_ast: ast::ItemTrait, + trait_ast: &ast::ItemTrait, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { let name = trait_ast.name(db).text(db); let mut interface = DojoInterface { diagnostics: vec![] }; - let mut builder = PatchBuilder::new(db, &trait_ast); + let mut builder = PatchBuilder::new(db, trait_ast); if let ast::MaybeTraitBody::Some(body) = trait_ast.body(db) { let body_nodes: Vec<_> = body @@ -50,7 +50,7 @@ impl DojoInterface { node: Box::new(RewriteNode::interpolate_patched( " #[starknet::interface] - pub trait $name$ { + pub trait $name$ { $body$ } ", @@ -67,7 +67,7 @@ impl DojoInterface { node: Box::new(RewriteNode::interpolate_patched( " #[starknet::interface] - pub trait $name$ {} + pub trait $name$ {} ", &UnorderedHashMap::from([( "name".to_string(), @@ -125,16 +125,16 @@ impl DojoInterface { match world_injection { WorldParamInjectionKind::None => { if !is_self_used { - params.insert(0, "self: @TContractState".to_string()); + params.insert(0, "self: @T".to_string()); } } WorldParamInjectionKind::View => { params.remove(0); - params.insert(0, "self: @TContractState".to_string()); + params.insert(0, "self: @T".to_string()); } WorldParamInjectionKind::External => { params.remove(0); - params.insert(0, "ref self: TContractState".to_string()); + params.insert(0, "ref self: T".to_string()); } }; diff --git a/crates/dojo/lang/src/attribute_macros/mod.rs b/crates/dojo/lang/src/attribute_macros/mod.rs new file mode 100644 index 0000000000..aa04576732 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/mod.rs @@ -0,0 +1,20 @@ +//! Attribute macros. +//! +//! An attribute macros is a macro that is used to generate code generally for a struct, enum, +//! module or trait. + +pub mod contract; +pub mod element; +pub mod event; +pub mod interface; +pub mod model; + +pub use contract::DojoContract; +pub use event::DojoEvent; +pub use interface::DojoInterface; +pub use model::DojoModel; + +pub const DOJO_CONTRACT_ATTR: &str = "dojo::contract"; +pub const DOJO_INTERFACE_ATTR: &str = "dojo::interface"; +pub const DOJO_MODEL_ATTR: &str = "dojo::model"; +pub const DOJO_EVENT_ATTR: &str = "dojo::event"; diff --git a/crates/dojo/lang/src/attribute_macros/model.rs b/crates/dojo/lang/src/attribute_macros/model.rs new file mode 100644 index 0000000000..c52a828d44 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/model.rs @@ -0,0 +1,246 @@ +//! Handle the `dojo::model` attribute macro. + +use std::collections::HashSet; + +use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; +use cairo_lang_defs::plugin::{ + DynGeneratedFileAuxData, PluginDiagnostic, PluginGeneratedFile, PluginResult, +}; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::node::ast::{ItemStruct, ModuleItem}; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::helpers::QueryAttrs; +use cairo_lang_syntax::node::{TypedStablePtr, TypedSyntaxNode}; +use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; +use dojo_types::naming; +use starknet::core::utils::get_selector_from_name; + +use super::element::{ + parse_members, serialize_member_ty, CommonStructParameters, StructParameterParser, +}; +use super::DOJO_MODEL_ATTR; +use crate::aux_data::{Member, ModelAuxData}; +use crate::derive_macros::{ + extract_derive_attr_names, handle_derive_attrs, DOJO_INTROSPECT_DERIVE, DOJO_PACKED_DERIVE, +}; + +const MODEL_CODE_PATCH: &str = include_str!("./patches/model.patch.cairo"); +const MODEL_FIELD_CODE_PATCH: &str = include_str!("./patches/model_field_store.patch.cairo"); +type ModelParameters = CommonStructParameters; + +#[derive(Debug, Clone, Default)] +pub struct DojoModel {} + +impl DojoModel { + /// A handler for Dojo code that modifies a model struct. + /// Parameters: + /// * db: The semantic database. + /// * struct_ast: The AST of the model struct. + /// + /// Returns: + /// * A RewriteNode containing the generated code. + pub fn from_struct(db: &dyn SyntaxGroup, struct_ast: ItemStruct) -> PluginResult { + let mut diagnostics = vec![]; + let mut parameters = ModelParameters::default(); + + parameters.load_from_struct( + db, + &DOJO_MODEL_ATTR.to_string(), + struct_ast.clone(), + &mut diagnostics, + ); + + let model_type = struct_ast.name(db).as_syntax_node().get_text(db).trim().to_string(); + + let model_version = parameters.version.to_string(); + + for (id, value) in [("name", &model_type)] { + if !naming::is_name_valid(value) { + return PluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: struct_ast.stable_ptr().0, + message: format!( + "The model {id} '{value}' can only contain characters (a-z/A-Z), \ + digits (0-9) and underscore (_)." + ), + severity: Severity::Error, + }], + remove_original_item: false, + }; + } + } + + let mut values: Vec = vec![]; + let mut keys: Vec = vec![]; + let mut members_values: Vec = vec![]; + let mut key_types: Vec = vec![]; + let mut key_attrs: Vec = vec![]; + + let mut serialized_keys: Vec = vec![]; + let mut serialized_values: Vec = vec![]; + let mut field_accessors: Vec = vec![]; + + // The impl constraint for a model `MemberStore` must be defined for each member type. + // To avoid double, we keep track of the processed types to skip the double impls. + let mut model_member_store_impls_processed: HashSet = HashSet::new(); + let mut model_member_store_impls: Vec = vec![]; + + let members = parse_members(db, &struct_ast.members(db).elements(db), &mut diagnostics); + + members.iter().for_each(|member| { + if member.key { + keys.push(member.clone()); + key_types.push(member.ty.clone()); + key_attrs.push(format!("*self.{}", member.name.clone())); + serialized_keys.push(serialize_member_ty(member, true)); + } else { + values.push(member.clone()); + serialized_values.push(serialize_member_ty(member, true)); + members_values + .push(RewriteNode::Text(format!("pub {}: {},\n", member.name, member.ty))); + field_accessors.push(generate_field_accessors(model_type.clone(), member)); + + if !model_member_store_impls_processed.contains(&member.ty.to_string()) { + model_member_store_impls.extend(vec![ + format!( + "+dojo::model::storage::MemberModelStorage", + model_type, member.ty + ), + format!( + "+dojo::model::storage::MemberModelStorage", + model_type, member.ty + ), + format!( + "+dojo::model::members::MemberStore::", + model_type, member.ty + ), + ]); + + model_member_store_impls_processed.insert(member.ty.to_string()); + } + } + }); + if keys.is_empty() { + diagnostics.push(PluginDiagnostic { + message: "Model must define at least one #[key] attribute".into(), + stable_ptr: struct_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + } + + if values.is_empty() { + diagnostics.push(PluginDiagnostic { + message: "Model must define at least one member that is not a key".into(), + stable_ptr: struct_ast.name(db).stable_ptr().untyped(), + severity: Severity::Error, + }); + } + if !diagnostics.is_empty() { + return PluginResult { code: None, diagnostics, remove_original_item: false }; + } + let (keys_to_tuple, key_type) = if keys.len() > 1 { + (format!("({})", key_attrs.join(", ")), format!("({})", key_types.join(", "))) + } else { + (key_attrs.first().unwrap().to_string(), key_types.first().unwrap().to_string()) + }; + + let mut derive_attr_names = extract_derive_attr_names( + db, + &mut diagnostics, + struct_ast.attributes(db).query_attr(db, "derive"), + ); + + // Ensures models always derive Introspect if not already derived. + let model_value_derive_attr_names = derive_attr_names + .iter() + .map(|d| d.as_str()) + .filter(|&d| d != DOJO_INTROSPECT_DERIVE && d != DOJO_PACKED_DERIVE) + .collect::>() + .join(", "); + + if !derive_attr_names.contains(&DOJO_INTROSPECT_DERIVE.to_string()) + && !derive_attr_names.contains(&DOJO_PACKED_DERIVE.to_string()) + { + // Default to Introspect, and not packed. + derive_attr_names.push(DOJO_INTROSPECT_DERIVE.to_string()); + } + + let (derive_nodes, derive_diagnostics) = + handle_derive_attrs(db, &derive_attr_names, &ModuleItem::Struct(struct_ast.clone())); + + diagnostics.extend(derive_diagnostics); + + let node = RewriteNode::interpolate_patched( + MODEL_CODE_PATCH, + &UnorderedHashMap::from([ + ("model_type".to_string(), RewriteNode::Text(model_type.clone())), + ("model_version".to_string(), RewriteNode::Text(model_version)), + ("serialized_keys".to_string(), RewriteNode::new_modified(serialized_keys)), + ("serialized_values".to_string(), RewriteNode::new_modified(serialized_values)), + ("keys_to_tuple".to_string(), RewriteNode::Text(keys_to_tuple)), + ("key_type".to_string(), RewriteNode::Text(key_type)), + ("members_values".to_string(), RewriteNode::new_modified(members_values)), + ("field_accessors".to_string(), RewriteNode::new_modified(field_accessors)), + ( + "model_value_derive_attr_names".to_string(), + RewriteNode::Text(model_value_derive_attr_names), + ), + ]), + ); + + let mut builder = PatchBuilder::new(db, &struct_ast); + + for node in derive_nodes { + builder.add_modified(node); + } + + builder.add_modified(node); + + let (code, code_mappings) = builder.build(); + + crate::debug_expand(&format!("MODEL PATCH: {model_type}"), &code); + + let aux_data = ModelAuxData { name: model_type.clone(), members }; + + PluginResult { + code: Some(PluginGeneratedFile { + name: model_type.into(), + content: code, + aux_data: Some(DynGeneratedFileAuxData::new(aux_data)), + code_mappings, + }), + diagnostics, + remove_original_item: false, + } + } +} + +/// Generates field accessors (`get_[field_name]` and `set_[field_name]`) for every +/// fields of a model. +/// +/// # Arguments +/// +/// * `model_name` - the model name. +/// * `param_keys` - coma separated model keys with the format `KEY_NAME: KEY_TYPE`. +/// * `serialized_param_keys` - code to serialize model keys in a `serialized` felt252 array. +/// * `member` - information about the field for which to generate accessors. +/// +/// # Returns +/// A [`RewriteNode`] containing accessors code. +fn generate_field_accessors(model_type: String, member: &Member) -> RewriteNode { + RewriteNode::interpolate_patched( + MODEL_FIELD_CODE_PATCH, + &UnorderedHashMap::from([ + ("model_type".to_string(), RewriteNode::Text(model_type)), + ( + "field_selector".to_string(), + RewriteNode::Text( + get_selector_from_name(&member.name).expect("invalid member name").to_string(), + ), + ), + ("field_name".to_string(), RewriteNode::Text(member.name.clone())), + ("field_type".to_string(), RewriteNode::Text(member.ty.clone())), + ]), + ) +} diff --git a/crates/dojo/lang/src/attribute_macros/patches/contract.patch.cairo b/crates/dojo/lang/src/attribute_macros/patches/contract.patch.cairo new file mode 100644 index 0000000000..59b0aa6288 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/patches/contract.patch.cairo @@ -0,0 +1,31 @@ +#[starknet::contract] +pub mod $name$ { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + component!(path: world_provider_cpt, storage: world_provider, event: WorldProviderEvent); + component!(path: upgradeable_cpt, storage: upgradeable, event: UpgradeableEvent); + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl $name$__ContractImpl of IContract { + fn dojo_name(self: @ContractState) -> ByteArray { + "$name$" + } + } + + #[generate_trait] + impl $name$InternalImpl of $name$InternalTrait { + fn world(self: @ContractState, namespace: @ByteArray) -> dojo::world::storage::WorldStorage { + dojo::world::WorldStorageTrait::new(self.world_provider.world_dispatcher(), namespace) + } + } + + $body$ +} diff --git a/crates/dojo/lang/src/attribute_macros/patches/default_init.patch.cairo b/crates/dojo/lang/src/attribute_macros/patches/default_init.patch.cairo new file mode 100644 index 0000000000..435bad567e --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/patches/default_init.patch.cairo @@ -0,0 +1,14 @@ +#[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn $init_name$(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world_dispatcher().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.dojo_name(), + starknet::get_caller_address(), + )); + } + } +} diff --git a/crates/dojo/lang/src/attribute_macros/patches/event.patch.cairo b/crates/dojo/lang/src/attribute_macros/patches/event.patch.cairo new file mode 100644 index 0000000000..2c8cfe2b86 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/patches/event.patch.cairo @@ -0,0 +1,86 @@ +pub impl $type_name$DojoEventImpl of dojo::event::Event<$type_name$> { + #[inline(always)] + fn name() -> ByteArray { + "$type_name$" + } + + #[inline(always)] + fn version() -> u8 { + $event_version$ + } + + #[inline(always)] + fn definition() -> dojo::event::EventDefinition { + dojo::event::EventDefinition { + name: Self::name(), + version: Self::version(), + layout: Self::layout(), + schema: Self::schema() + } + } + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::introspect::Introspect::<$type_name$>::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::<$type_name$>::ty() + } + + #[inline(always)] + fn historical() -> bool { + $event_historical$ + } + + #[inline(always)] + fn keys(self: @$type_name$) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + $serialized_keys$ + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @$type_name$) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + $serialized_values$ + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn selector(namespace_hash: felt252) -> felt252 { + dojo::utils::selector_from_namespace_and_name(namespace_hash, @Self::name()) + } +} + +#[starknet::contract] +pub mod e_$type_name$ { + use super::$type_name$; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl $type_name$__DojoEventImpl of dojo::event::IEvent{ + fn dojo_name(self: @ContractState) -> ByteArray { + "$type_name$" + } + + fn version(self: @ContractState) -> u8 { + $event_version$ + } + + fn definition(self: @ContractState) -> dojo::event::EventDefinition { + dojo::event::Event::<$type_name$>::definition() + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::event::Event::<$type_name$>::layout() + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::<$type_name$>::ty() + } + } +} diff --git a/crates/dojo/lang/src/attribute_macros/patches/model.patch.cairo b/crates/dojo/lang/src/attribute_macros/patches/model.patch.cairo new file mode 100644 index 0000000000..c84376c600 --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/patches/model.patch.cairo @@ -0,0 +1,110 @@ +#[derive($model_value_derive_attr_names$)] +pub struct $model_type$Value { + $members_values$ +} + +type $model_type$KeyType = $key_type$; + +pub impl $model_type$KeyParser of dojo::model::model::KeyParser<$model_type$, $model_type$KeyType>{ + #[inline(always)] + fn parse_key(self: @$model_type$) -> $model_type$KeyType { + $keys_to_tuple$ + } +} + +impl $model_type$ModelValueKey of dojo::model::model_value::ModelValueKey<$model_type$Value, $model_type$KeyType> { +} + +// Impl to get the static definition of a model +pub mod m_$model_type$_definition { + use super::$model_type$; + pub impl $model_type$DefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "$model_type$" + } + + #[inline(always)] + fn version() -> u8 { + $model_version$ + } + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::<$model_type$>::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::<$model_type$>::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::<$model_type$>::size() + } + } +} + +pub impl $model_type$Definition = m_$model_type$_definition::$model_type$DefinitionImpl<$model_type$>; +pub impl $model_type$ModelValueDefinition = m_$model_type$_definition::$model_type$DefinitionImpl<$model_type$Value>; + +pub impl $model_type$ModelParser of dojo::model::model::ModelParser<$model_type$>{ + fn serialize_keys(self: @$model_type$) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + $serialized_keys$ + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @$model_type$) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + $serialized_values$ + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl $model_type$ModelValueParser of dojo::model::model_value::ModelValueParser<$model_type$Value>{ + fn serialize_values(self: @$model_type$Value) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + $serialized_values$ + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl $model_type$ModelImpl = dojo::model::model::ModelImpl<$model_type$>; +pub impl $model_type$ModelValueImpl = dojo::model::model_value::ModelValueImpl<$model_type$Value>; + +#[starknet::contract] +pub mod m_$model_type$ { + use super::$model_type$; + use super::$model_type$Value; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl $model_type$__DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(per_item)] + #[generate_trait] + impl $model_type$Impl of I$model_type${ + // Ensures the ABI contains the Model struct, even if never used + // into as a system input. + #[external(v0)] + fn ensure_abi(self: @ContractState, model: $model_type$) { + let _model = model; + } + + // Outputs ModelValue to allow a simple diff from the ABI compared to the + // model to retrieved the keys of a model. + #[external(v0)] + fn ensure_values(self: @ContractState, value: $model_type$Value) { + let _value = value; + } + } +} + +#[cfg(target: "test")] +pub impl $model_type$ModelTestImpl> = dojo::model::model::ModelTestImpl; + +#[cfg(target: "test")] +pub impl $model_type$ModelValueTestImpl> = dojo::model::model_value::ModelValueTestImpl; diff --git a/crates/dojo/lang/src/attribute_macros/patches/model_field_store.patch.cairo b/crates/dojo/lang/src/attribute_macros/patches/model_field_store.patch.cairo new file mode 100644 index 0000000000..8fa466617f --- /dev/null +++ b/crates/dojo/lang/src/attribute_macros/patches/model_field_store.patch.cairo @@ -0,0 +1,15 @@ + fn get_$field_name$(self: @S, key: $model_type$KeyType) -> $field_type$ { + $model_type$Store::get_member(self, key, $field_selector$) + } + + fn get_$field_name$_from_id(self: @S, entity_id: felt252) -> $field_type$ { + $model_type$ModelValueStore::get_member_from_id(self, entity_id, $field_selector$) + } + + fn update_$field_name$(ref self: S, key: $model_type$KeyType, value: $field_type$) { + $model_type$Store::update_member(ref self, key, $field_selector$, value); + } + + fn update_$field_name$_from_id(ref self: S, entity_id: felt252, value: $field_type$) { + $model_type$ModelValueStore::update_member_from_id(ref self, entity_id, $field_selector$, value); + } diff --git a/crates/dojo/lang/src/aux_data.rs b/crates/dojo/lang/src/aux_data.rs new file mode 100644 index 0000000000..eb2bbcdf1f --- /dev/null +++ b/crates/dojo/lang/src/aux_data.rs @@ -0,0 +1,67 @@ +//! Auxiliary data for Dojo generated files. +//! +//! The plugin generates aux data for models, contracts and events. +//! Then the compiler uses this aux data to generate the manifests and organize the artifacts. + +use cairo_lang_defs::plugin::GeneratedFileAuxData; +use serde::{Deserialize, Serialize}; + +/// Represents a member of a struct. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Member { + // Name of the member. + pub name: String, + // Type of the member. + #[serde(rename = "type")] + pub ty: String, + // Whether the member is a key. + pub key: bool, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelAuxData { + pub name: String, + pub members: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct ContractAuxData { + pub name: String, + pub systems: Vec, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct EventAuxData { + pub name: String, + pub members: Vec, +} + +impl GeneratedFileAuxData for ModelAuxData { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { + if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } + } +} + +impl GeneratedFileAuxData for EventAuxData { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { + if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } + } +} + +impl GeneratedFileAuxData for ContractAuxData { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { + if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } + } +} diff --git a/crates/dojo/lang/src/cairo_plugin.rs b/crates/dojo/lang/src/cairo_plugin.rs new file mode 100644 index 0000000000..a13cc76533 --- /dev/null +++ b/crates/dojo/lang/src/cairo_plugin.rs @@ -0,0 +1,107 @@ +//! Dojo plugin for Cairo. + +use cairo_lang_defs::plugin::{MacroPlugin, MacroPluginMetadata, PluginDiagnostic, PluginResult}; +use cairo_lang_defs::plugin_utils::PluginResultTrait; +use cairo_lang_diagnostics::Severity; +use cairo_lang_semantic::plugin::PluginSuite; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::helpers::QueryAttrs; +use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; + +use super::attribute_macros::{ + DojoContract, DojoEvent, DojoModel, DOJO_CONTRACT_ATTR, DOJO_EVENT_ATTR, DOJO_MODEL_ATTR, +}; +use super::derive_macros::{dojo_derive_all, DOJO_INTROSPECT_DERIVE, DOJO_PACKED_DERIVE}; +use super::inline_macros::SelectorFromTagMacro; + +// #[cfg(test)] +// #[path = "plugin_test.rs"] +// mod test; +pub const DOJO_PLUGIN_PACKAGE_NAME: &str = "dojo_plugin"; + +#[derive(Debug, Default)] +pub struct BuiltinDojoPlugin; + +pub fn dojo_plugin_suite() -> PluginSuite { + let mut suite = PluginSuite::default(); + + suite.add_plugin::().add_inline_macro_plugin::(); + + suite +} + +impl MacroPlugin for BuiltinDojoPlugin { + /// This function is called for every item in whole db. Hence, + /// the sooner we can return, the better. + /// As an example, compiling spawn-and-move project, it's almost 14K calls to this + /// function. + /// + /// Currently Dojo mainly supports: + /// - Contracts: which are built from attribute macros on a module. + /// - Interfaces: which are built from attribute macros on a trait. + /// - Models: which are built from attribute macros on a struct. + /// - Events: which are built from attribute macros on a struct. + /// - Enums: mostly used for deriving introspect to be used into a model or event. + fn generate_code( + &self, + db: &dyn SyntaxGroup, + item_ast: ast::ModuleItem, + metadata: &MacroPluginMetadata<'_>, + ) -> PluginResult { + // Metadata gives information from the crates from where `item_ast` was parsed. + // During the compilation phase, we inject namespace information into the `CfgSet` + // so that it can be used here. + // let namespace_config = metadata.cfg_set.into(); + + match &item_ast { + ast::ModuleItem::Module(module_ast) => { + if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { + DojoContract::from_module(db, module_ast, metadata) + } else { + PluginResult::default() + } + } + ast::ModuleItem::Enum(enum_ast) => { + dojo_derive_all(db, enum_ast.attributes(db).query_attr(db, "derive"), &item_ast) + } + ast::ModuleItem::Struct(struct_ast) => { + let n_model_attrs = struct_ast.attributes(db).query_attr(db, DOJO_MODEL_ATTR).len(); + + let n_event_attrs = struct_ast.attributes(db).query_attr(db, DOJO_EVENT_ATTR).len(); + + if n_model_attrs > 0 && n_event_attrs > 0 { + return PluginResult::diagnostic_only(PluginDiagnostic { + stable_ptr: struct_ast.stable_ptr().0, + message: format!( + "The struct {} can only have one of the dojo::model or one \ + dojo::event attribute.", + struct_ast.name(db).text(db) + ), + severity: Severity::Error, + }); + } else if n_model_attrs == 1 { + return DojoModel::from_struct(db, struct_ast.clone()); + } else if n_event_attrs == 1 { + return DojoEvent::from_struct(db, struct_ast.clone()); + } + + // Not a model or event, but has derives. + dojo_derive_all(db, struct_ast.attributes(db).query_attr(db, "derive"), &item_ast) + } + _ => PluginResult::default(), + } + } + + fn declared_attributes(&self) -> Vec { + vec![ + DOJO_CONTRACT_ATTR.to_string(), + DOJO_EVENT_ATTR.to_string(), + DOJO_MODEL_ATTR.to_string(), + "key".to_string(), + ] + } + + fn declared_derives(&self) -> Vec { + vec![DOJO_INTROSPECT_DERIVE.to_string(), DOJO_PACKED_DERIVE.to_string()] + } +} diff --git a/crates/dojo-lang/src/introspect/layout.rs b/crates/dojo/lang/src/derive_macros/introspect/layout.rs similarity index 92% rename from crates/dojo-lang/src/introspect/layout.rs rename to crates/dojo/lang/src/derive_macros/introspect/layout.rs index 7d0edf781c..43667fe502 100644 --- a/crates/dojo-lang/src/introspect/layout.rs +++ b/crates/dojo/lang/src/derive_macros/introspect/layout.rs @@ -30,7 +30,7 @@ pub fn build_field_layouts( let field_selector = get_selector_from_name(&field_name.to_string()).unwrap(); let field_layout = get_layout_from_type_clause(db, diagnostics, &m.type_clause(db)); Some(format!( - "dojo::model::FieldLayout {{ + "dojo::meta::FieldLayout {{ selector: {field_selector}, layout: {field_layout} }}" @@ -57,7 +57,7 @@ pub fn build_variant_layouts( let variant_layout = match v.type_clause(db) { OptionTypeClause::Empty(_) => { - "dojo::model::Layout::Fixed(array![].span())".to_string() + "dojo::meta::Layout::Fixed(array![].span())".to_string() } OptionTypeClause::TypeClause(type_clause) => { get_layout_from_type_clause(db, diagnostics, &type_clause) @@ -65,7 +65,7 @@ pub fn build_variant_layouts( }; format!( - "dojo::model::FieldLayout {{ + "dojo::meta::FieldLayout {{ selector: {selector}, layout: {variant_layout} }}" @@ -102,7 +102,7 @@ pub fn get_layout_from_type_clause( } /// Build the array layout describing the provided array type. -/// item_type could be something like Array for example. +/// item_type could be something like `Array` for example. pub fn build_array_layout_from_type( diagnostics: &mut Vec, diagnostic_item: ids::SyntaxStablePtrId, @@ -112,7 +112,7 @@ pub fn build_array_layout_from_type( if is_tuple(&array_item_type) { format!( - "dojo::model::Layout::Array( + "dojo::meta::Layout::Array( array![ {} ].span() @@ -121,7 +121,7 @@ pub fn build_array_layout_from_type( ) } else if is_array(&array_item_type) { format!( - "dojo::model::Layout::Array( + "dojo::meta::Layout::Array( array![ {} ].span() @@ -129,7 +129,7 @@ pub fn build_array_layout_from_type( build_array_layout_from_type(diagnostics, diagnostic_item, &array_item_type) ) } else { - format!("dojo::model::introspect::Introspect::<{}>::layout()", item_type) + format!("dojo::meta::introspect::Introspect::<{}>::layout()", item_type) } } @@ -146,7 +146,7 @@ pub fn build_tuple_layout_from_type( .collect::>() .join(",\n"); format!( - "dojo::model::Layout::Tuple( + "dojo::meta::Layout::Tuple( array![ {} ].span() @@ -176,12 +176,12 @@ pub fn build_item_layout_from_type( }); } - format!("dojo::model::introspect::Introspect::<{}>::layout()", item_type) + format!("dojo::meta::introspect::Introspect::<{}>::layout()", item_type) } } pub fn is_custom_layout(layout: &str) -> bool { - layout.starts_with("dojo::model::introspect::Introspect::") + layout.starts_with("dojo::meta::introspect::Introspect::") } pub fn build_packed_struct_layout( @@ -207,7 +207,7 @@ pub fn build_packed_struct_layout( generate_cairo_code_for_fixed_layout_with_custom_types(&layouts) } else { format!( - "dojo::model::Layout::Fixed( + "dojo::meta::Layout::Fixed( array![ {} ].span() @@ -224,7 +224,7 @@ pub fn generate_cairo_code_for_fixed_layout_with_custom_types(layouts: &[String] if is_custom_layout(l) { l.to_string() } else { - format!("dojo::model::Layout::Fixed(array![{l}].span())") + format!("dojo::meta::Layout::Fixed(array![{l}].span())") } }) .collect::>() @@ -240,7 +240,7 @@ pub fn generate_cairo_code_for_fixed_layout_with_custom_types(layouts: &[String] match ArrayTrait::pop_front(ref layouts) {{ Option::Some(mut layout) => {{ match layout {{ - dojo::model::Layout::Fixed(mut l) => {{ + dojo::meta::Layout::Fixed(mut l) => {{ loop {{ match SpanTrait::pop_front(ref l) {{ Option::Some(x) => merged_layout.append(*x), @@ -255,7 +255,7 @@ pub fn generate_cairo_code_for_fixed_layout_with_custom_types(layouts: &[String] }}; }}; - dojo::model::Layout::Fixed(merged_layout.span()) + dojo::meta::Layout::Fixed(merged_layout.span()) ", ) } @@ -288,7 +288,7 @@ pub fn build_packed_enum_layout( generate_cairo_code_for_fixed_layout_with_custom_types(&variant_layout) } else { format!( - "dojo::model::Layout::Fixed( + "dojo::meta::Layout::Fixed( array![ {} ].span() @@ -352,7 +352,7 @@ pub fn get_packed_item_layout_from_type( // as we cannot verify that an enum/struct custom type is packable, // we suppose it is and let the user verify this. // If it's not the case, the Dojo model layout function will panic. - vec![format!("dojo::model::introspect::Introspect::<{}>::layout()", item_type)] + vec![format!("dojo::meta::introspect::Introspect::<{}>::layout()", item_type)] } } } diff --git a/crates/dojo-lang/src/introspect/mod.rs b/crates/dojo/lang/src/derive_macros/introspect/mod.rs similarity index 92% rename from crates/dojo-lang/src/introspect/mod.rs rename to crates/dojo/lang/src/derive_macros/introspect/mod.rs index 3fc4f244e7..62a2b11757 100644 --- a/crates/dojo-lang/src/introspect/mod.rs +++ b/crates/dojo/lang/src/derive_macros/introspect/mod.rs @@ -28,7 +28,7 @@ pub fn handle_introspect_struct( layout::build_packed_struct_layout(db, diagnostics, &struct_ast) } else { format!( - "dojo::model::Layout::Struct( + "dojo::meta::Layout::Struct( array![ {} ].span() @@ -66,7 +66,7 @@ pub fn handle_introspect_enum( } } else { format!( - "dojo::model::Layout::Enum( + "dojo::meta::Layout::Enum( array![ {} ].span() @@ -94,19 +94,19 @@ fn generate_introspect( ) -> RewriteNode { RewriteNode::interpolate_patched( " -impl $name$Introspect<$generics$> of dojo::model::introspect::Introspect<$name$<$generics_types$>> \ +impl $name$Introspect<$generics$> of dojo::meta::introspect::Introspect<$name$<$generics_types$>> \ { #[inline(always)] fn size() -> Option { $size$ } - fn layout() -> dojo::model::Layout { + fn layout() -> dojo::meta::Layout { $layout$ } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { + fn ty() -> dojo::meta::introspect::Ty { $ty$ } } @@ -148,7 +148,7 @@ fn build_generic_types_and_impls( let generic_impls = generic_types .iter() - .map(|g| format!("{g}, impl {g}Introspect: dojo::model::introspect::Introspect<{g}>")) + .map(|g| format!("{g}, impl {g}Introspect: dojo::meta::introspect::Introspect<{g}>")) .collect::>() .join(", "); diff --git a/crates/dojo-lang/src/introspect/size.rs b/crates/dojo/lang/src/derive_macros/introspect/size.rs similarity index 98% rename from crates/dojo-lang/src/introspect/size.rs rename to crates/dojo/lang/src/derive_macros/introspect/size.rs index e1a49ca880..efb81ea25d 100644 --- a/crates/dojo-lang/src/introspect/size.rs +++ b/crates/dojo/lang/src/derive_macros/introspect/size.rs @@ -187,7 +187,7 @@ pub fn compute_item_size_from_type(item_type: &String) -> Vec { if let Some(p) = primitives.get(item_type) { vec![p.0.to_string()] } else { - vec![format!("dojo::model::introspect::Introspect::<{}>::size()", item_type)] + vec![format!("dojo::meta::introspect::Introspect::<{}>::size()", item_type)] } } } diff --git a/crates/dojo-lang/src/introspect/ty.rs b/crates/dojo/lang/src/derive_macros/introspect/ty.rs similarity index 86% rename from crates/dojo-lang/src/introspect/ty.rs rename to crates/dojo/lang/src/derive_macros/introspect/ty.rs index 8c87fc151f..d9e9e40a11 100644 --- a/crates/dojo-lang/src/introspect/ty.rs +++ b/crates/dojo/lang/src/derive_macros/introspect/ty.rs @@ -16,8 +16,8 @@ pub fn build_struct_ty(db: &dyn SyntaxGroup, name: &String, struct_ast: &ItemStr .collect::>(); format!( - "dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct {{ + "dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct {{ name: '{name}', attrs: array![].span(), children: array![ @@ -39,8 +39,8 @@ pub fn build_enum_ty(db: &dyn SyntaxGroup, name: &String, enum_ast: &ItemEnum) - }; format!( - "dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum {{ + "dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum {{ name: '{name}', attrs: array![].span(), children: array![ @@ -56,7 +56,7 @@ pub fn build_member_ty(db: &dyn SyntaxGroup, member: &Member) -> String { let attrs = if member.has_attr(db, "key") { vec!["'key'"] } else { vec![] }; format!( - "dojo::model::introspect::Member {{ + "dojo::meta::introspect::Member {{ name: '{name}', attrs: array![{}].span(), ty: {} @@ -71,7 +71,7 @@ pub fn build_variant_ty(db: &dyn SyntaxGroup, variant: &Variant) -> String { match variant.type_clause(db) { OptionTypeClause::Empty(_) => { // use an empty tuple if the variant has no data - format!("('{name}', dojo::model::introspect::Ty::Tuple(array![].span()))") + format!("('{name}', dojo::meta::introspect::Ty::Tuple(array![].span()))") } OptionTypeClause::TypeClause(type_clause) => { format!("('{name}', {})", build_ty_from_type_clause(db, &type_clause)) @@ -100,7 +100,7 @@ pub fn build_item_ty_from_type(item_type: &String) -> String { if is_array(item_type) { let array_item_type = get_array_item_type(item_type); format!( - "dojo::model::introspect::Ty::Array( + "dojo::meta::introspect::Ty::Array( array![ {} ].span() @@ -108,11 +108,11 @@ pub fn build_item_ty_from_type(item_type: &String) -> String { build_item_ty_from_type(&array_item_type) ) } else if is_byte_array(item_type) { - "dojo::model::introspect::Ty::ByteArray".to_string() + "dojo::meta::introspect::Ty::ByteArray".to_string() } else if is_tuple(item_type) { build_tuple_ty_from_type(item_type) } else { - format!("dojo::model::introspect::Introspect::<{}>::ty()", item_type) + format!("dojo::meta::introspect::Introspect::<{}>::ty()", item_type) } } @@ -123,7 +123,7 @@ pub fn build_tuple_ty_from_type(item_type: &str) -> String { .collect::>() .join(",\n"); format!( - "dojo::model::introspect::Ty::Tuple( + "dojo::meta::introspect::Ty::Tuple( array![ {} ].span() diff --git a/crates/dojo-lang/src/introspect/utils.rs b/crates/dojo/lang/src/derive_macros/introspect/utils.rs similarity index 98% rename from crates/dojo-lang/src/introspect/utils.rs rename to crates/dojo/lang/src/derive_macros/introspect/utils.rs index 7e2a2acc5f..2b6e5bf5d3 100644 --- a/crates/dojo-lang/src/introspect/utils.rs +++ b/crates/dojo/lang/src/derive_macros/introspect/utils.rs @@ -20,7 +20,7 @@ pub fn primitive_type_introspection() -> HashMap { ]) } -/// Check if the provided type is an unsupported Option, +/// Check if the provided type is an unsupported `Option`, /// because tuples are not supported with Option. pub fn is_unsupported_option_type(ty: &str) -> bool { ty.starts_with("Option<(") diff --git a/crates/dojo/lang/src/derive_macros/mod.rs b/crates/dojo/lang/src/derive_macros/mod.rs new file mode 100644 index 0000000000..9377a4d7eb --- /dev/null +++ b/crates/dojo/lang/src/derive_macros/mod.rs @@ -0,0 +1,210 @@ +//! Derive macros. +//! +//! A derive macros is a macro that is used to generate code generally for a struct or enum. +//! The input of the macro consists of the AST of the struct or enum and the attributes of the +//! derive macro. + +use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; +use cairo_lang_defs::plugin::{PluginDiagnostic, PluginGeneratedFile, PluginResult}; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::attribute::structured::{AttributeArgVariant, AttributeStructurize}; +use cairo_lang_syntax::node::ast::Attribute; +use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::ids::SyntaxStablePtrId; +use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; +use introspect::{handle_introspect_enum, handle_introspect_struct}; +use print::{handle_print_enum, handle_print_struct}; + +pub mod introspect; +pub mod print; + +pub const DOJO_PRINT_DERIVE: &str = "Print"; +pub const DOJO_INTROSPECT_DERIVE: &str = "Introspect"; +pub const DOJO_PACKED_DERIVE: &str = "IntrospectPacked"; + +/// Handles all the dojo derives macro and returns the generated code and diagnostics. +pub fn dojo_derive_all( + db: &dyn SyntaxGroup, + attrs: Vec, + item_ast: &ast::ModuleItem, +) -> PluginResult { + if attrs.is_empty() { + return PluginResult::default(); + } + + let mut diagnostics = vec![]; + + let derive_attr_names = extract_derive_attr_names(db, &mut diagnostics, attrs); + + let (rewrite_nodes, derive_diagnostics) = handle_derive_attrs(db, &derive_attr_names, item_ast); + + diagnostics.extend(derive_diagnostics); + + let mut builder = PatchBuilder::new(db, item_ast); + for node in rewrite_nodes { + builder.add_modified(node); + } + + let (code, code_mappings) = builder.build(); + + let item_name = item_ast.as_syntax_node().get_text_without_trivia(db).into(); + + PluginResult { + code: Some(PluginGeneratedFile { + name: item_name, + content: code, + aux_data: None, + code_mappings, + }), + diagnostics, + remove_original_item: false, + } +} + +/// Handles the derive attributes of a struct or enum. +pub fn handle_derive_attrs( + db: &dyn SyntaxGroup, + attrs: &[String], + item_ast: &ast::ModuleItem, +) -> (Vec, Vec) { + let mut rewrite_nodes = Vec::new(); + let mut diagnostics = Vec::new(); + + check_for_derive_attr_conflicts(&mut diagnostics, item_ast.stable_ptr().0, attrs); + + match item_ast { + ast::ModuleItem::Struct(struct_ast) => { + for a in attrs { + match a.as_str() { + DOJO_PRINT_DERIVE => { + rewrite_nodes.push(handle_print_struct(db, struct_ast.clone())); + } + DOJO_INTROSPECT_DERIVE => { + rewrite_nodes.push(handle_introspect_struct( + db, + &mut diagnostics, + struct_ast.clone(), + false, + )); + } + DOJO_PACKED_DERIVE => { + rewrite_nodes.push(handle_introspect_struct( + db, + &mut diagnostics, + struct_ast.clone(), + true, + )); + } + _ => continue, + } + } + } + ast::ModuleItem::Enum(enum_ast) => { + for a in attrs { + match a.as_str() { + DOJO_PRINT_DERIVE => { + rewrite_nodes.push(handle_print_enum(db, enum_ast.clone())); + } + DOJO_INTROSPECT_DERIVE => { + rewrite_nodes.push(handle_introspect_enum( + db, + &mut diagnostics, + enum_ast.clone(), + false, + )); + } + DOJO_PACKED_DERIVE => { + rewrite_nodes.push(handle_introspect_enum( + db, + &mut diagnostics, + enum_ast.clone(), + true, + )); + } + _ => continue, + } + } + } + _ => { + // Currently Dojo plugin doesn't support derive macros on other items than struct and + // enum. + diagnostics.push(PluginDiagnostic { + stable_ptr: item_ast.stable_ptr().0, + message: "Dojo plugin doesn't support derive macros on other items than struct \ + and enum." + .to_string(), + severity: Severity::Error, + }); + } + } + + (rewrite_nodes, diagnostics) +} + +/// Extracts the names of the derive attributes from the given attributes. +/// +/// # Examples +/// +/// Derive usage should look like this: +/// +/// ```no_run,ignore +/// #[derive(Introspect)] +/// struct MyStruct {} +/// ``` +/// +/// And this function will return `["Introspect"]`. +pub fn extract_derive_attr_names( + db: &dyn SyntaxGroup, + diagnostics: &mut Vec, + attrs: Vec, +) -> Vec { + attrs + .iter() + .filter_map(|attr| { + let args = attr.clone().structurize(db).args; + if args.is_empty() { + diagnostics.push(PluginDiagnostic { + stable_ptr: attr.stable_ptr().0, + message: "Expected args.".into(), + severity: Severity::Error, + }); + None + } else { + Some(args.into_iter().filter_map(|a| { + if let AttributeArgVariant::Unnamed(ast::Expr::Path(path)) = a.variant { + if let [ast::PathSegment::Simple(segment)] = &path.elements(db)[..] { + Some(segment.ident(db).text(db).to_string()) + } else { + None + } + } else { + None + } + })) + } + }) + .flatten() + .collect::>() +} + +/// Checks for conflicts between introspect and packed attributes. +/// +/// Introspect and IntrospectPacked cannot be used at a same time. +fn check_for_derive_attr_conflicts( + diagnostics: &mut Vec, + diagnostic_item: SyntaxStablePtrId, + attr_names: &[String], +) { + if attr_names.contains(&DOJO_INTROSPECT_DERIVE.to_string()) + && attr_names.contains(&DOJO_PACKED_DERIVE.to_string()) + { + diagnostics.push(PluginDiagnostic { + stable_ptr: diagnostic_item, + message: format!( + "{} and {} attributes cannot be used at a same time.", + DOJO_INTROSPECT_DERIVE, DOJO_PACKED_DERIVE + ), + severity: Severity::Error, + }); + } +} diff --git a/crates/dojo-lang/src/print.rs b/crates/dojo/lang/src/derive_macros/print.rs similarity index 100% rename from crates/dojo-lang/src/print.rs rename to crates/dojo/lang/src/derive_macros/print.rs diff --git a/crates/dojo-lang/src/inline_macros/delete.rs b/crates/dojo/lang/src/inline_macros/delete.rs similarity index 95% rename from crates/dojo-lang/src/inline_macros/delete.rs rename to crates/dojo/lang/src/inline_macros/delete.rs index fc51eb28fc..91070ceb65 100644 --- a/crates/dojo-lang/src/inline_macros/delete.rs +++ b/crates/dojo/lang/src/inline_macros/delete.rs @@ -90,12 +90,9 @@ impl InlineMacroExprPlugin for DeleteMacro { for entity in bundle { builder.add_str(&format!( - " - let __delete_model_instance__ = {}; - dojo::model::Model::delete_model(@__delete_model_instance__, {}); - ", - entity, + "dojo::model::ModelStore::delete({}, @{})\n;", world.as_syntax_node().get_text(db), + entity, )); } builder.add_str("}"); diff --git a/crates/dojo-lang/src/inline_macros/emit.rs b/crates/dojo/lang/src/inline_macros/emit.rs similarity index 79% rename from crates/dojo-lang/src/inline_macros/emit.rs rename to crates/dojo/lang/src/inline_macros/emit.rs index 7cb364764b..57b87b424c 100644 --- a/crates/dojo-lang/src/inline_macros/emit.rs +++ b/crates/dojo/lang/src/inline_macros/emit.rs @@ -5,10 +5,9 @@ use cairo_lang_defs::plugin::{ }; use cairo_lang_defs::plugin_utils::unsupported_bracket_diagnostic; use cairo_lang_diagnostics::Severity; -use cairo_lang_starknet::plugin::consts::EVENT_TRAIT; use cairo_lang_syntax::node::{ast, TypedStablePtr, TypedSyntaxNode}; -use crate::inline_macros::unsupported_arg_diagnostic; +use super::unsupported_arg_diagnostic; #[derive(Debug, Default)] pub struct EmitMacro; @@ -54,17 +53,17 @@ impl InlineMacroExprPlugin for EmitMacro { match models.value(db) { ast::Expr::Parenthesized(parens) => { let syntax_node = parens.expr(db).as_syntax_node(); - bundle.push((syntax_node.get_text(db), syntax_node)); + bundle.push(syntax_node.get_text(db)); } ast::Expr::Tuple(list) => { list.expressions(db).elements(db).into_iter().for_each(|expr| { let syntax_node = expr.as_syntax_node(); - bundle.push((syntax_node.get_text(db), syntax_node)); + bundle.push(syntax_node.get_text(db)); }) } ast::Expr::StructCtorCall(ctor) => { let syntax_node = ctor.as_syntax_node(); - bundle.push((syntax_node.get_text(db), syntax_node)); + bundle.push(syntax_node.get_text(db)); } _ => { return InlinePluginResult { @@ -89,26 +88,15 @@ impl InlineMacroExprPlugin for EmitMacro { }; } - for (event, _) in bundle { - builder.add_str("{"); - - builder.add_str( - " - let mut keys = Default::::default(); - let mut data = Default::::default();", - ); - + for event in bundle { builder.add_str(&format!( " - {EVENT_TRAIT}::append_keys_and_data(@{event}, ref keys, ref data);", - event = event + let __event_instance__ = {}; + dojo::event::Event::emit(@__event_instance__, {}); + ", + event, + world.as_syntax_node().get_text(db), )); - - builder.add_str("\n "); - builder.add_node(world.as_syntax_node()); - builder.add_str(".emit(keys, data.span());"); - - builder.add_str("}"); } builder.add_str("}"); diff --git a/crates/dojo-lang/src/inline_macros/get.rs b/crates/dojo/lang/src/inline_macros/get.rs similarity index 84% rename from crates/dojo-lang/src/inline_macros/get.rs rename to crates/dojo/lang/src/inline_macros/get.rs index 4b4bb82731..f2c8f9a601 100644 --- a/crates/dojo-lang/src/inline_macros/get.rs +++ b/crates/dojo/lang/src/inline_macros/get.rs @@ -29,10 +29,7 @@ impl InlineMacroExprPlugin for GetMacro { return unsupported_bracket_diagnostic(db, syntax); }; let mut builder = PatchBuilder::new(db, syntax); - builder.add_str( - "{ - let mut __get_macro_keys__ = core::array::ArrayTrait::new();\n", - ); + builder.add_str("{\n"); let args = arg_list.arguments(db).elements(db); @@ -80,29 +77,22 @@ impl InlineMacroExprPlugin for GetMacro { _ => keys.as_syntax_node().get_text(db), }; - builder.add_str(&format!( - "core::serde::Serde::serialize(@{args}, ref __get_macro_keys__); - let __get_macro_keys__ = core::array::ArrayTrait::span(@__get_macro_keys__);\n" - )); - for model in &models { let mut lookup_err_msg = format!("{} not found", model.to_string()); lookup_err_msg.truncate(CAIRO_ERR_MSG_LEN); builder.add_str(&format!( - "\n - let __{model}: {model} = dojo::model::Model::get({}, __get_macro_keys__);\n", + "let __{model}: {model} = dojo::model::ModelStore::get(@{}, {});\n", world.as_syntax_node().get_text(db), + args, )); } - builder.add_str(&format!( - "({}) - }}", - models.iter().map(|c| format!("__{c}")).join(",") - )); + builder.add_str(&format!("({})}}", models.iter().map(|c| format!("__{c}")).join(","))); let (code, code_mappings) = builder.build(); + crate::debug_expand(&format!("GET MACRO: {args}"), &code); + InlinePluginResult { code: Some(PluginGeneratedFile { name: "get_inline_macro".into(), diff --git a/crates/dojo-lang/src/inline_macros/get_models_test_class_hashes.rs b/crates/dojo/lang/src/inline_macros/get_models_test_class_hashes.rs similarity index 100% rename from crates/dojo-lang/src/inline_macros/get_models_test_class_hashes.rs rename to crates/dojo/lang/src/inline_macros/get_models_test_class_hashes.rs diff --git a/crates/dojo-lang/src/inline_macros/mod.rs b/crates/dojo/lang/src/inline_macros/mod.rs similarity index 91% rename from crates/dojo-lang/src/inline_macros/mod.rs rename to crates/dojo/lang/src/inline_macros/mod.rs index 5c90d35004..1f28612be1 100644 --- a/crates/dojo-lang/src/inline_macros/mod.rs +++ b/crates/dojo/lang/src/inline_macros/mod.rs @@ -1,3 +1,7 @@ +//! Inline macros. +//! +//! An inline macros is a macro that is used directly within the code. + use cairo_lang_defs::plugin::{InlinePluginResult, PluginDiagnostic}; use cairo_lang_diagnostics::Severity; use cairo_lang_syntax::node::db::SyntaxGroup; @@ -13,6 +17,14 @@ pub mod set; pub mod spawn_test_world; pub mod utils; +pub use delete::DeleteMacro; +pub use emit::EmitMacro; +pub use get::GetMacro; +pub use get_models_test_class_hashes::GetModelsTestClassHashes; +pub use selector_from_tag::SelectorFromTagMacro; +pub use set::SetMacro; +pub use spawn_test_world::SpawnTestWorld; + const CAIRO_ERR_MSG_LEN: usize = 31; pub fn extract_models( diff --git a/crates/dojo-lang/src/inline_macros/selector_from_tag.rs b/crates/dojo/lang/src/inline_macros/selector_from_tag.rs similarity index 98% rename from crates/dojo-lang/src/inline_macros/selector_from_tag.rs rename to crates/dojo/lang/src/inline_macros/selector_from_tag.rs index 4f2fa02a6b..4145100d4e 100644 --- a/crates/dojo-lang/src/inline_macros/selector_from_tag.rs +++ b/crates/dojo/lang/src/inline_macros/selector_from_tag.rs @@ -6,7 +6,7 @@ use cairo_lang_defs::plugin::{ use cairo_lang_defs::plugin_utils::unsupported_bracket_diagnostic; use cairo_lang_diagnostics::Severity; use cairo_lang_syntax::node::{ast, TypedStablePtr, TypedSyntaxNode}; -use dojo_world::contracts::naming; +use dojo_types::naming; #[derive(Debug, Default)] pub struct SelectorFromTagMacro; diff --git a/crates/dojo-lang/src/inline_macros/set.rs b/crates/dojo/lang/src/inline_macros/set.rs similarity index 97% rename from crates/dojo-lang/src/inline_macros/set.rs rename to crates/dojo/lang/src/inline_macros/set.rs index b027d22c58..7a040fbae9 100644 --- a/crates/dojo-lang/src/inline_macros/set.rs +++ b/crates/dojo/lang/src/inline_macros/set.rs @@ -105,11 +105,10 @@ impl InlineMacroExprPlugin for SetMacro { for entity in bundle { builder.add_str(&format!( " - let __set_model_instance__ = {}; - dojo::model::Model::set_model(@__set_model_instance__, {}); + dojo::model::ModelStore::set({}, @{}); ", - entity, world.as_syntax_node().get_text(db), + entity, )); } builder.add_str("}"); diff --git a/crates/dojo-lang/src/inline_macros/spawn_test_world.rs b/crates/dojo/lang/src/inline_macros/spawn_test_world.rs similarity index 95% rename from crates/dojo-lang/src/inline_macros/spawn_test_world.rs rename to crates/dojo/lang/src/inline_macros/spawn_test_world.rs index aa21fd8290..e40004bebc 100644 --- a/crates/dojo-lang/src/inline_macros/spawn_test_world.rs +++ b/crates/dojo/lang/src/inline_macros/spawn_test_world.rs @@ -6,6 +6,7 @@ use cairo_lang_defs::plugin::{ use cairo_lang_defs::plugin_utils::unsupported_bracket_diagnostic; use cairo_lang_diagnostics::Severity; use cairo_lang_syntax::node::{ast, TypedStablePtr, TypedSyntaxNode}; +use tracing::trace; use super::unsupported_arg_diagnostic; use super::utils::{extract_namespaces, load_manifest_models_and_namespaces}; @@ -66,7 +67,7 @@ impl InlineMacroExprPlugin for SpawnTestWorld { code: None, diagnostics: vec![PluginDiagnostic { stable_ptr: syntax.stable_ptr().untyped(), - message: "Failed to load models and namespaces, ensure you have run \ + message: "failed to load models and namespaces, ensure you have run \ `sozo build` first." .to_string(), severity: Severity::Error, @@ -75,6 +76,8 @@ impl InlineMacroExprPlugin for SpawnTestWorld { } }; + trace!(?namespaces, ?models, "Spawning test world from macro."); + let mut builder = PatchBuilder::new(db, syntax); builder.add_str(&format!( diff --git a/crates/dojo-lang/src/inline_macros/utils.rs b/crates/dojo/lang/src/inline_macros/utils.rs similarity index 65% rename from crates/dojo-lang/src/inline_macros/utils.rs rename to crates/dojo/lang/src/inline_macros/utils.rs index 53bb8342fa..5366b477e7 100644 --- a/crates/dojo-lang/src/inline_macros/utils.rs +++ b/crates/dojo/lang/src/inline_macros/utils.rs @@ -7,10 +7,6 @@ use cairo_lang_syntax::node::ast::{self, ExprPath, ExprStructCtorCall}; use cairo_lang_syntax::node::db::SyntaxGroup; use cairo_lang_syntax::node::kind::SyntaxKind; use cairo_lang_syntax::node::{SyntaxNode, TypedStablePtr, TypedSyntaxNode}; -use camino::Utf8PathBuf; -use dojo_world::config::namespace_config::DOJO_MANIFESTS_DIR_CFG_KEY; -use dojo_world::contracts::naming; -use dojo_world::manifest::BaseManifest; #[derive(Debug)] pub enum SystemRWOpRecord { @@ -35,28 +31,23 @@ pub fn parent_of_kind( /// Reads all the models and namespaces from base manifests files. pub fn load_manifest_models_and_namespaces( - cfg_set: &CfgSet, - whitelisted_namespaces: &[String], + _cfg_set: &CfgSet, + _whitelisted_namespaces: &[String], ) -> anyhow::Result<(Vec, Vec)> { - let dojo_manifests_dir = get_dojo_manifests_dir(cfg_set.clone())?; - - let base_dir = dojo_manifests_dir.join("base"); - let base_abstract_manifest = BaseManifest::load_from_path(&base_dir)?; - - let mut models = HashSet::new(); - let mut namespaces = HashSet::new(); - - for model in base_abstract_manifest.models { - let qualified_path = model.inner.qualified_path; - let namespace = naming::split_tag(&model.inner.tag)?.0; - - if !whitelisted_namespaces.is_empty() && !whitelisted_namespaces.contains(&namespace) { - continue; - } - - models.insert(qualified_path); - namespaces.insert(namespace); - } + let models = HashSet::::new(); + let namespaces = HashSet::::new(); + + // for model in annotations.models { + // let qualified_path = model.qualified_path; + // let namespace = naming::split_tag(&model.tag)?.0; + // + // if !whitelisted_namespaces.is_empty() && !whitelisted_namespaces.contains(&namespace) { + // continue; + // } + // + // models.insert(qualified_path); + // namespaces.insert(namespace); + // } let models_vec: Vec = models.into_iter().collect(); let namespaces_vec: Vec = namespaces.into_iter().collect(); @@ -64,17 +55,6 @@ pub fn load_manifest_models_and_namespaces( Ok((namespaces_vec, models_vec)) } -/// Gets the dojo_manifests_dir from the cfg_set. -pub fn get_dojo_manifests_dir(cfg_set: CfgSet) -> anyhow::Result { - for cfg in cfg_set.into_iter() { - if cfg.key == DOJO_MANIFESTS_DIR_CFG_KEY { - return Ok(Utf8PathBuf::from(cfg.value.unwrap().as_str().to_string())); - } - } - - Err(anyhow::anyhow!("dojo_manifests_dir not found")) -} - /// Extracts the namespaces from a fixed size array of strings. pub fn extract_namespaces( db: &dyn SyntaxGroup, diff --git a/crates/dojo/lang/src/lib.rs b/crates/dojo/lang/src/lib.rs new file mode 100644 index 0000000000..7207eb6d67 --- /dev/null +++ b/crates/dojo/lang/src/lib.rs @@ -0,0 +1,39 @@ +//! Dojo compiler. +//! +//! This crate contains the Dojo compiler, with a cairo plugin for the Cairo language. + +pub mod attribute_macros; +pub mod aux_data; +pub mod cairo_plugin; +pub mod derive_macros; +pub mod inline_macros; +pub mod semantics; +pub mod syntax; + +pub use cairo_plugin::{dojo_plugin_suite, BuiltinDojoPlugin, DOJO_PLUGIN_PACKAGE_NAME}; + +pub const CAIRO_PATH_SEPARATOR: &str = "::"; +pub const WORLD_QUALIFIED_PATH: &str = "dojo::world::world_contract::world"; +pub const WORLD_CONTRACT_TAG: &str = "dojo-world"; +pub const RESOURCE_METADATA_QUALIFIED_PATH: &str = "dojo::model::metadata::resource_metadata"; +pub const CONTRACTS_DIR: &str = "contracts"; +pub const MODELS_DIR: &str = "models"; +pub const EVENTS_DIR: &str = "events"; +pub const MANIFESTS_DIR: &str = "manifests"; +pub const MANIFESTS_BASE_DIR: &str = "base"; + +/// Prints the given string only if the `DOJO_EXPAND` environemnt variable is set. +/// This is useful for debugging the compiler with verbose output. +/// +/// # Arguments +/// +/// * `loc` - The location of the code to be expanded. +/// * `code` - The code to be expanded. +pub fn debug_expand(loc: &str, code: &str) { + if std::env::var("DOJO_EXPAND").is_ok() { + println!( + "\n*> EXPAND {} <*\n>>>>>>>>>>>>>>>>>>>>>>>>>>>\n{}\n<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + loc, code + ); + } +} diff --git a/crates/dojo-lang/src/plugin_test.rs b/crates/dojo/lang/src/plugin_test.rs similarity index 89% rename from crates/dojo-lang/src/plugin_test.rs rename to crates/dojo/lang/src/plugin_test.rs index 4023b900c4..609bdb6f74 100644 --- a/crates/dojo-lang/src/plugin_test.rs +++ b/crates/dojo/lang/src/plugin_test.rs @@ -6,9 +6,10 @@ use cairo_lang_defs::ids::ModuleId; use cairo_lang_defs::plugin::MacroPlugin; use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; use cairo_lang_filesystem::db::{ - init_files_group, AsFilesGroupMut, CrateConfiguration, FilesDatabase, FilesGroup, FilesGroupEx, + init_files_group, AsFilesGroupMut, CrateConfiguration, ExternalFiles, FilesDatabase, + FilesGroup, FilesGroupEx, }; -use cairo_lang_filesystem::ids::{CrateLongId, Directory}; +use cairo_lang_filesystem::ids::{CrateLongId, Directory, VirtualFile}; use cairo_lang_parser::db::ParserDatabase; use cairo_lang_plugins::get_base_plugins; use cairo_lang_plugins::test_utils::expand_module_text; @@ -18,45 +19,29 @@ use cairo_lang_test_utils::parse_test_file::TestRunnerResult; use cairo_lang_test_utils::verify_diagnostics_expectation; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use cairo_lang_utils::Upcast; -use dojo_world::config::namespace_config::DEFAULT_NAMESPACE_CFG_KEY; use smol_str::SmolStr; use super::BuiltinDojoPlugin; -cairo_lang_test_utils::test_file_test!( - expand_plugin, - "src/plugin_test_data", - { - model: "model", - print: "print", - introspect: "introspect", - system: "system", - }, - test_expand_plugin -); - -pub fn test_expand_plugin( - inputs: &OrderedHashMap, - args: &OrderedHashMap, -) -> TestRunnerResult { - test_expand_plugin_inner( - inputs, - args, - &[Arc::new(BuiltinDojoPlugin), Arc::new(StarkNetPlugin::default())], - ) -} - #[salsa::database(DefsDatabase, ParserDatabase, SyntaxDatabase, FilesDatabase)] -#[allow(missing_debug_implementations)] pub struct DatabaseForTesting { storage: salsa::Storage, } impl salsa::Database for DatabaseForTesting {} +impl ExternalFiles for DatabaseForTesting { + fn try_ext_as_virtual(&self, external_id: salsa::InternId) -> Option { + try_ext_as_virtual_impl(self.upcast(), external_id) + } +} impl Default for DatabaseForTesting { fn default() -> Self { let mut res = Self { storage: Default::default() }; init_files_group(&mut res); - res.set_macro_plugins(get_base_plugins()); + res.set_macro_plugins(vec![ + Arc::new(FooToBarPlugin), + Arc::new(RemoveOrigPlugin), + Arc::new(DummyPlugin), + ]); res } } @@ -81,6 +66,30 @@ impl Upcast for DatabaseForTesting { } } +cairo_lang_test_utils::test_file_test!( + expand_plugin, + "src/plugin/plugin_test_data", + { + model: "model", + event: "event", + print: "print", + introspect: "introspect", + system: "system", + }, + test_expand_plugin +); + +pub fn test_expand_plugin( + inputs: &OrderedHashMap, + args: &OrderedHashMap, +) -> TestRunnerResult { + test_expand_plugin_inner( + inputs, + args, + &[Arc::new(BuiltinDojoPlugin), Arc::new(StarkNetPlugin::default())], + ) +} + /// Tests expansion of given code, with the default plugins plus the given extra plugins. pub fn test_expand_plugin_inner( inputs: &OrderedHashMap, diff --git a/crates/dojo/lang/src/plugin_test_data/event b/crates/dojo/lang/src/plugin_test_data/event new file mode 100644 index 0000000000..ffd85c4e82 --- /dev/null +++ b/crates/dojo/lang/src/plugin_test_data/event @@ -0,0 +1,1585 @@ +//! > Test expansion of the dojo::event. + +//! > test_runner_name +test_expand_plugin + +//! > test_id +event + +//! > cairo_code +#[derive(Drop, Serde)] +#[dojo::event] +pub struct Message { + #[key] + pub identity: ContractAddress, + #[key] + pub channel: felt252, + pub message: ByteArray, + #[key] + pub salt: felt252 +} + +#[dojo::event(namespace: 'my_namespace')] +struct MyEventWithNamespace { + #[key] + id: felt252, + name: ByteArray, +} + +#[dojo::event(historical: false)] +struct MyEventNoHistorical { + #[key] + id: felt252, + name: ByteArray, +} + +//! > expanded_cairo_code +#[derive(Drop, Serde)] +#[dojo::event] +pub struct Message { + #[key] + pub identity: ContractAddress, + #[key] + pub channel: felt252, + pub message: ByteArray, + #[key] + pub salt: felt252 +} + +#[dojo::event(namespace: 'my_namespace')] +struct MyEventWithNamespace { + #[key] + id: felt252, + name: ByteArray, +} + +#[dojo::event(historical: false)] +struct MyEventNoHistorical { + #[key] + id: felt252, + name: ByteArray, +}impl MessageDrop of core::traits::Drop::; +impl MessageSerde of core::serde::Serde:: { + fn serialize(self: @Message, ref output: core::array::Array) { + core::serde::Serde::serialize(self.identity, ref output); + core::serde::Serde::serialize(self.channel, ref output); + core::serde::Serde::serialize(self.message, ref output); + core::serde::Serde::serialize(self.salt, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Message { + identity: core::serde::Serde::deserialize(ref serialized)?, + channel: core::serde::Serde::deserialize(ref serialized)?, + message: core::serde::Serde::deserialize(ref serialized)?, + salt: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} + +impl MessageIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 1234962429638067342109111948666382589302318509162806680039978245403372666376, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'Message', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'identity', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'channel', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'message', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::ByteArray + }, +dojo::meta::introspect::Member { + name: 'salt', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[generate_trait] +pub impl MessageEmitterImpl of MessageEmitter { + fn emit(self: @Message, world: dojo::world::IWorldDispatcher) { + dojo::event::Event::::emit(self, world); + } +} + +pub impl MessageEventImpl of dojo::event::Event { + + fn emit(self: @Message, world: dojo::world::IWorldDispatcher) { + dojo::world::IWorldDispatcherTrait::emit_event( + world, + Self::selector(), + Self::keys(self), + Self::values(self), + Self::historical() + ); + } + + #[inline(always)] + fn name() -> ByteArray { + "Message" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-Message" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 1906185680711303922822303398414928927091284519615502535643957313578662707163 + } + + #[inline(always)] + fn instance_selector(self: @Message) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1218932985479400212550774377351312162398071867364919833219536439613388630232 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + #[inline(always)] + fn definition() -> dojo::event::EventDefinition { + dojo::event::EventDefinition { + name: Self::name(), + namespace: Self::namespace(), + namespace_selector: Self::namespace_hash(), + version: Self::version(), + layout: Self::layout(), + schema: Self::schema() + } + } + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::introspect::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + + #[inline(always)] + fn historical() -> bool { + true + } + + #[inline(always)] + fn keys(self: @Message) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.identity, ref serialized); +core::serde::Serde::serialize(self.channel, ref serialized); +core::serde::Serde::serialize(self.salt, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Message) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.message, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +#[starknet::contract] +pub mod message { + use super::Message; + + #[abi(embed_v0)] + impl DojoEventImpl of dojo::event::IEvent{ + fn name(self: @ContractState) -> ByteArray { + "Message" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-Message" + } + + fn version(self: @ContractState) -> u8 { + 1 + } + + fn selector(self: @ContractState) -> felt252 { + 1906185680711303922822303398414928927091284519615502535643957313578662707163 + } + + fn name_hash(self: @ContractState) -> felt252 { + 1218932985479400212550774377351312162398071867364919833219536439613388630232 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn definition(self: @ContractState) -> dojo::event::EventDefinition { + dojo::event::Event::::definition() + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::event::Event::::layout() + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__definition(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::definition(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoEventImpl__name as name; + pub use super::__wrapper__DojoEventImpl__namespace as namespace; + pub use super::__wrapper__DojoEventImpl__tag as tag; + pub use super::__wrapper__DojoEventImpl__version as version; + pub use super::__wrapper__DojoEventImpl__selector as selector; + pub use super::__wrapper__DojoEventImpl__name_hash as name_hash; + pub use super::__wrapper__DojoEventImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoEventImpl__definition as definition; + pub use super::__wrapper__DojoEventImpl__layout as layout; + pub use super::__wrapper__DojoEventImpl__schema as schema; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl MyEventWithNamespaceIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'MyEventWithNamespace', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'name', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::ByteArray + } + + ].span() + } + ) + } +} + #[generate_trait] +pub impl MyEventWithNamespaceEmitterImpl of MyEventWithNamespaceEmitter { + fn emit(self: @MyEventWithNamespace, world: dojo::world::IWorldDispatcher) { + dojo::event::Event::::emit(self, world); + } +} + +pub impl MyEventWithNamespaceEventImpl of dojo::event::Event { + + fn emit(self: @MyEventWithNamespace, world: dojo::world::IWorldDispatcher) { + dojo::world::IWorldDispatcherTrait::emit_event( + world, + Self::selector(), + Self::keys(self), + Self::values(self), + Self::historical() + ); + } + + #[inline(always)] + fn name() -> ByteArray { + "MyEventWithNamespace" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "my_namespace" + } + + #[inline(always)] + fn tag() -> ByteArray { + "my_namespace-MyEventWithNamespace" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 522863814429969509522276935486616304495946442516761817333050868296788859995 + } + + #[inline(always)] + fn instance_selector(self: @MyEventWithNamespace) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2098606738830025182570698512150760386142000891530754603737354272913658631235 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + #[inline(always)] + fn definition() -> dojo::event::EventDefinition { + dojo::event::EventDefinition { + name: Self::name(), + namespace: Self::namespace(), + namespace_selector: Self::namespace_hash(), + version: Self::version(), + layout: Self::layout(), + schema: Self::schema() + } + } + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::introspect::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + + #[inline(always)] + fn historical() -> bool { + true + } + + #[inline(always)] + fn keys(self: @MyEventWithNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @MyEventWithNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.name, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +#[starknet::contract] +pub mod my_event_with_namespace { + use super::MyEventWithNamespace; + + #[abi(embed_v0)] + impl DojoEventImpl of dojo::event::IEvent{ + fn name(self: @ContractState) -> ByteArray { + "MyEventWithNamespace" + } + + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn tag(self: @ContractState) -> ByteArray { + "my_namespace-MyEventWithNamespace" + } + + fn version(self: @ContractState) -> u8 { + 1 + } + + fn selector(self: @ContractState) -> felt252 { + 522863814429969509522276935486616304495946442516761817333050868296788859995 + } + + fn name_hash(self: @ContractState) -> felt252 { + 2098606738830025182570698512150760386142000891530754603737354272913658631235 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + fn definition(self: @ContractState) -> dojo::event::EventDefinition { + dojo::event::Event::::definition() + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::event::Event::::layout() + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__definition(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::definition(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoEventImpl__name as name; + pub use super::__wrapper__DojoEventImpl__namespace as namespace; + pub use super::__wrapper__DojoEventImpl__tag as tag; + pub use super::__wrapper__DojoEventImpl__version as version; + pub use super::__wrapper__DojoEventImpl__selector as selector; + pub use super::__wrapper__DojoEventImpl__name_hash as name_hash; + pub use super::__wrapper__DojoEventImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoEventImpl__definition as definition; + pub use super::__wrapper__DojoEventImpl__layout as layout; + pub use super::__wrapper__DojoEventImpl__schema as schema; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl MyEventNoHistoricalIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'MyEventNoHistorical', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'name', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::ByteArray + } + + ].span() + } + ) + } +} + #[generate_trait] +pub impl MyEventNoHistoricalEmitterImpl of MyEventNoHistoricalEmitter { + fn emit(self: @MyEventNoHistorical, world: dojo::world::IWorldDispatcher) { + dojo::event::Event::::emit(self, world); + } +} + +pub impl MyEventNoHistoricalEventImpl of dojo::event::Event { + + fn emit(self: @MyEventNoHistorical, world: dojo::world::IWorldDispatcher) { + dojo::world::IWorldDispatcherTrait::emit_event( + world, + Self::selector(), + Self::keys(self), + Self::values(self), + Self::historical() + ); + } + + #[inline(always)] + fn name() -> ByteArray { + "MyEventNoHistorical" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-MyEventNoHistorical" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 1337059065882820731687976087854228588833382671052971042794952278702302659992 + } + + #[inline(always)] + fn instance_selector(self: @MyEventNoHistorical) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 900791686958237697199683333646433800101626975808368629569299817255472139882 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + #[inline(always)] + fn definition() -> dojo::event::EventDefinition { + dojo::event::EventDefinition { + name: Self::name(), + namespace: Self::namespace(), + namespace_selector: Self::namespace_hash(), + version: Self::version(), + layout: Self::layout(), + schema: Self::schema() + } + } + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::introspect::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + + #[inline(always)] + fn historical() -> bool { + false + } + + #[inline(always)] + fn keys(self: @MyEventNoHistorical) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @MyEventNoHistorical) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.name, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +#[starknet::contract] +pub mod my_event_no_historical { + use super::MyEventNoHistorical; + + #[abi(embed_v0)] + impl DojoEventImpl of dojo::event::IEvent{ + fn name(self: @ContractState) -> ByteArray { + "MyEventNoHistorical" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-MyEventNoHistorical" + } + + fn version(self: @ContractState) -> u8 { + 1 + } + + fn selector(self: @ContractState) -> felt252 { + 1337059065882820731687976087854228588833382671052971042794952278702302659992 + } + + fn name_hash(self: @ContractState) -> felt252 { + 900791686958237697199683333646433800101626975808368629569299817255472139882 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn definition(self: @ContractState) -> dojo::event::EventDefinition { + dojo::event::Event::::definition() + } + + fn layout(self: @ContractState) -> dojo::meta::Layout { + dojo::event::Event::::layout() + } + + fn schema(self: @ContractState) -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Introspect::::ty() + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__definition(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::definition(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__DojoEventImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoEventImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoEventImpl__name as name; + pub use super::__wrapper__DojoEventImpl__namespace as namespace; + pub use super::__wrapper__DojoEventImpl__tag as tag; + pub use super::__wrapper__DojoEventImpl__version as version; + pub use super::__wrapper__DojoEventImpl__selector as selector; + pub use super::__wrapper__DojoEventImpl__name_hash as name_hash; + pub use super::__wrapper__DojoEventImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoEventImpl__definition as definition; + pub use super::__wrapper__DojoEventImpl__layout as layout; + pub use super::__wrapper__DojoEventImpl__schema as schema; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + pub trait MessageEmitter { + fn emit(self: @Message, world: dojo::world::IWorldDispatcher); +} + pub trait MyEventWithNamespaceEmitter { + fn emit(self: @MyEventWithNamespace, world: dojo::world::IWorldDispatcher); +} + pub trait MyEventNoHistoricalEmitter { + fn emit(self: @MyEventNoHistorical, world: dojo::world::IWorldDispatcher); +} + +//! > expected_diagnostics diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo/lang/src/plugin_test_data/introspect similarity index 62% rename from crates/dojo-lang/src/plugin_test_data/introspect rename to crates/dojo/lang/src/plugin_test_data/introspect index 90233dbf2f..bdbc6724dd 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo/lang/src/plugin_test_data/introspect @@ -529,22 +529,22 @@ impl Vec2Serde of core::serde::Serde:: { } } -impl Vec2Introspect<> of dojo::model::introspect::Introspect> { +impl Vec2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::model::introspect::Introspect::::layout() } ].span() @@ -552,21 +552,21 @@ dojo::model::FieldLayout { } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'Vec2', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'y', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -595,36 +595,36 @@ impl PlainEnumSerde of core::serde::Serde:: { impl PlainEnumCopy of core::traits::Copy::; impl PlainEnumDrop of core::traits::Drop::; -impl PlainEnumIntrospect<> of dojo::model::introspect::Introspect> { +impl PlainEnumIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::Layout::Fixed(array![].span()) + layout: dojo::meta::Layout::Fixed(array![].span()) }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::Layout::Fixed(array![].span()) + layout: dojo::meta::Layout::Fixed(array![].span()) } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'PlainEnum', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::Tuple(array![].span())), -('Right', dojo::model::introspect::Ty::Tuple(array![].span())) + ('Left', dojo::meta::introspect::Ty::Tuple(array![].span())), +('Right', dojo::meta::introspect::Ty::Tuple(array![].span())) ].span() } @@ -652,36 +652,36 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; -impl EnumWithPrimitiveIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithPrimitiveIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithPrimitive', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Introspect::::ty()), -('Right', dojo::model::introspect::Introspect::::ty()) + ('Left', dojo::meta::introspect::Introspect::::ty()), +('Right', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -709,11 +709,11 @@ impl EnumWithStructSerde of core::serde::Serde:: { impl EnumWithStructCopy of core::traits::Copy::; impl EnumWithStructDrop of core::traits::Drop::; -impl EnumWithStructIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithStructIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(1) ]; @@ -724,30 +724,30 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithStruct', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Introspect::::ty()), -('Right', dojo::model::introspect::Introspect::::ty()) + ('Left', dojo::meta::introspect::Introspect::::ty()), +('Right', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -775,42 +775,42 @@ impl EnumWithSimpleArraySerde of core::serde::Serde:: { impl EnumWithSimpleArrayCopy of core::traits::Copy::; impl EnumWithSimpleArrayDrop of core::traits::Drop::; -impl EnumWithSimpleArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithSimpleArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::>::layout() + layout: dojo::meta::introspect::Introspect::>::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::>::layout() + layout: dojo::meta::introspect::Introspect::>::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithSimpleArray', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::Array( + ('Left', dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() )), -('Right', dojo::model::introspect::Ty::Array( +('Right', dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() )) @@ -840,36 +840,36 @@ impl EnumWithByteArraySerde of core::serde::Serde:: { impl EnumWithByteArrayCopy of core::traits::Copy::; impl EnumWithByteArrayDrop of core::traits::Drop::; -impl EnumWithByteArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithByteArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithByteArray', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::ByteArray), -('Right', dojo::model::introspect::Ty::ByteArray) + ('Left', dojo::meta::introspect::Ty::ByteArray), +('Right', dojo::meta::introspect::Ty::ByteArray) ].span() } @@ -897,30 +897,30 @@ impl EnumWithSimpleTupleSerde of core::serde::Serde:: { impl EnumWithSimpleTupleCopy of core::traits::Copy::; impl EnumWithSimpleTupleDrop of core::traits::Drop::; -impl EnumWithSimpleTupleIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithSimpleTupleIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(4) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -929,22 +929,22 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithSimpleTuple', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::Tuple( + ('Left', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )), -('Right', dojo::model::introspect::Ty::Tuple( +('Right', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )) @@ -974,11 +974,11 @@ impl EnumWithComplexTupleSerde of core::serde::Serde:: { impl EnumWithComplexTupleCopy of core::traits::Copy::; impl EnumWithComplexTupleDrop of core::traits::Drop::; -impl EnumWithComplexTupleIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithComplexTupleIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(2) ]; @@ -989,24 +989,24 @@ Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -1015,22 +1015,22 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithComplexTuple', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::Tuple( + ('Left', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )), -('Right', dojo::model::introspect::Ty::Tuple( +('Right', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )) @@ -1060,36 +1060,36 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; -impl EnumWithPrimitiveIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithPrimitiveIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithPrimitive', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Introspect::::ty()), -('Right', dojo::model::introspect::Introspect::::ty()) + ('Left', dojo::meta::introspect::Introspect::::ty()), +('Right', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -1117,11 +1117,11 @@ impl EnumCustomSerde of core::serde::Serde:: { impl EnumCustomCopy of core::traits::Copy::; impl EnumCustomDrop of core::traits::Drop::; -impl EnumCustomIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumCustomIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(1) ]; @@ -1132,30 +1132,30 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumCustom', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Introspect::::ty()), -('Right', dojo::model::introspect::Introspect::::ty()) + ('Left', dojo::meta::introspect::Introspect::::ty()), +('Right', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -1183,12 +1183,12 @@ impl EnumTupleMixSerde of core::serde::Serde:: { impl EnumTupleMixCopy of core::traits::Copy::; impl EnumTupleMixDrop of core::traits::Drop::; -impl EnumTupleMixIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumTupleMixIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), -dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), +dojo::meta::introspect::Introspect::::size(), Option::Some(2) ]; @@ -1199,26 +1199,26 @@ Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -1227,24 +1227,24 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumTupleMix', attrs: array![].span(), children: array![ - ('Left', dojo::model::introspect::Ty::Tuple( + ('Left', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )), -('Right', dojo::model::introspect::Ty::Tuple( +('Right', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )) @@ -1276,29 +1276,29 @@ impl EnumWithDifferentVariantDataSerde of core::serde::Serde::; impl EnumWithDifferentVariantDataDrop of core::traits::Drop::; -impl EnumWithDifferentVariantDataIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithDifferentVariantDataIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::Layout::Fixed(array![].span()) + layout: dojo::meta::Layout::Fixed(array![].span()) }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 1, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 2, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -1307,18 +1307,18 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithDifferentVariantData', attrs: array![].span(), children: array![ - ('One', dojo::model::introspect::Ty::Tuple(array![].span())), -('Two', dojo::model::introspect::Introspect::::ty()), -('Three', dojo::model::introspect::Ty::Tuple( + ('One', dojo::meta::introspect::Ty::Tuple(array![].span())), +('Two', dojo::meta::introspect::Introspect::::ty()), +('Three', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )) @@ -1330,48 +1330,48 @@ dojo::model::introspect::Introspect::::ty() impl StructWithPrimitivesCopy of core::traits::Copy::; impl StructWithPrimitivesDrop of core::traits::Drop::; -impl StructWithPrimitivesIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithPrimitivesIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithPrimitives', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -1382,11 +1382,11 @@ dojo::model::introspect::Member { impl StructWithStructCopy of core::traits::Copy::; impl StructWithStructDrop of core::traits::Drop::; -impl StructWithStructIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithStructIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(1) ]; @@ -1397,42 +1397,42 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithStruct', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -1443,50 +1443,50 @@ dojo::model::introspect::Member { impl StructWithSimpleArrayCopy of core::traits::Copy::; impl StructWithSimpleArrayDrop of core::traits::Drop::; -impl StructWithSimpleArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithSimpleArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::introspect::Introspect::>::layout() + layout: dojo::meta::introspect::Introspect::>::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithSimpleArray', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( + ty: dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -1499,48 +1499,48 @@ dojo::model::introspect::Member { impl StructWithByteArrayCopy of core::traits::Copy::; impl StructWithByteArrayDrop of core::traits::Drop::; -impl StructWithByteArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithByteArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithByteArray', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::ByteArray + ty: dojo::meta::introspect::Ty::ByteArray } ].span() @@ -1551,50 +1551,50 @@ dojo::model::introspect::Member { impl StructWithComplexArrayCopy of core::traits::Copy::; impl StructWithComplexArrayDrop of core::traits::Drop::; -impl StructWithComplexArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithComplexArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::introspect::Introspect::>::layout() + layout: dojo::meta::introspect::Introspect::>::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithComplexArray', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( + ty: dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -1607,25 +1607,25 @@ dojo::model::introspect::Member { impl StructWithSimpleTupleCopy of core::traits::Copy::; impl StructWithSimpleTupleDrop of core::traits::Drop::; -impl StructWithSimpleTupleIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithSimpleTupleIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(4) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -1634,29 +1634,29 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithSimpleTuple', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -1669,12 +1669,12 @@ dojo::model::introspect::Introspect::::ty() impl StructWithComplexTupleCopy of core::traits::Copy::; impl StructWithComplexTupleDrop of core::traits::Drop::; -impl StructWithComplexTupleIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithComplexTupleIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), -dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), +dojo::meta::introspect::Introspect::::size(), Option::Some(2) ]; @@ -1685,20 +1685,20 @@ Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) } @@ -1707,30 +1707,30 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithComplexTuple', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -1743,26 +1743,26 @@ dojo::model::introspect::Introspect::::ty() impl StructWithNestedArraysCopy of core::traits::Copy::; impl StructWithNestedArraysDrop of core::traits::Drop::; -impl StructWithNestedArraysIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithNestedArraysIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Array( + layout: dojo::meta::Layout::Array( array![ - dojo::model::Layout::Array( + dojo::meta::Layout::Array( array![ - dojo::model::introspect::Introspect::>::layout() + dojo::meta::introspect::Introspect::>::layout() ].span() ) ].span() @@ -1773,32 +1773,32 @@ dojo::model::FieldLayout { } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithNestedArrays', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( + ty: dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Ty::Array( + dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Ty::Array( + dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() ) ].span() @@ -1815,12 +1815,12 @@ dojo::model::introspect::Member { impl StructWithNestedTuplesCopy of core::traits::Copy::; impl StructWithNestedTuplesDrop of core::traits::Drop::; -impl StructWithNestedTuplesIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithNestedTuplesIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), -dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), +dojo::meta::introspect::Introspect::::size(), Option::Some(3) ]; @@ -1831,27 +1831,27 @@ Option::Some(3) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::Layout::Tuple( + dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ), -dojo::model::Layout::Tuple( +dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) ].span() @@ -1862,37 +1862,37 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithNestedTuples', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Ty::Tuple( + dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ), -dojo::model::introspect::Ty::Tuple( +dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ) ].span() @@ -1907,33 +1907,33 @@ dojo::model::introspect::Introspect::::ty() impl StructWithNestedTuplesAndByteArrayCopy of core::traits::Copy::; impl StructWithNestedTuplesAndByteArrayDrop of core::traits::Drop::; -impl StructWithNestedTuplesAndByteArrayIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithNestedTuplesAndByteArrayIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::Layout::Tuple( + dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ), -dojo::model::Layout::Tuple( +dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) ].span() @@ -1944,37 +1944,37 @@ dojo::model::introspect::Introspect::::layout() } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithNestedTuplesAndByteArray', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Ty::Tuple( + dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ), -dojo::model::introspect::Ty::Tuple( +dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Ty::ByteArray + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Ty::ByteArray ].span() ) ].span() @@ -1989,53 +1989,53 @@ dojo::model::introspect::Ty::ByteArray impl StructWithNestedEverythingCopy of core::traits::Copy::; impl StructWithNestedEverythingDrop of core::traits::Drop::; -impl StructWithNestedEverythingIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithNestedEverythingIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() }, -dojo::model::FieldLayout { +dojo::meta::FieldLayout { selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::model::Layout::Tuple( + layout: dojo::meta::Layout::Tuple( array![ - dojo::model::Layout::Tuple( + dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ), -dojo::model::Layout::Tuple( +dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ), -dojo::model::Layout::Tuple( +dojo::meta::Layout::Tuple( array![ - dojo::model::Layout::Array( + dojo::meta::Layout::Array( array![ - dojo::model::Layout::Tuple( + dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout(), -dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() ].span() ) ].span() ), -dojo::model::introspect::Introspect::::layout() +dojo::meta::introspect::Introspect::::layout() ].span() ), -dojo::model::Layout::Tuple( +dojo::meta::Layout::Tuple( array![ - dojo::model::introspect::Introspect::::layout() + dojo::meta::introspect::Introspect::::layout() ].span() ) ].span() @@ -2046,57 +2046,57 @@ dojo::model::Layout::Tuple( } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithNestedEverything', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'player', attrs: array!['key'].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'before', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'after', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Ty::Tuple( + dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ), -dojo::model::introspect::Ty::Tuple( +dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ), -dojo::model::introspect::Ty::Tuple( +dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Ty::Array( + dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Ty::Tuple( + dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ) ].span() ), -dojo::model::introspect::Introspect::::ty() +dojo::meta::introspect::Introspect::::ty() ].span() ), -dojo::model::introspect::Ty::Tuple( +dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() ) ].span() @@ -2121,34 +2121,34 @@ impl GenericStructSerde, +core::traits::Destruct> o } } -impl GenericStructIntrospect> of dojo::model::introspect::Introspect> { +impl GenericStructIntrospect> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { - dojo::model::introspect::Introspect::::size() + dojo::meta::introspect::Introspect::::size() } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 1246920879054256875300693562709339669009726288543267794550465531256469553289, - layout: dojo::model::introspect::Introspect::::layout() + layout: dojo::meta::introspect::Introspect::::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'GenericStruct', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 't', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -2169,18 +2169,18 @@ impl StructWithBadOptionSerde of core::serde::Serde:: { } } -impl StructWithBadOptionIntrospect<> of dojo::model::introspect::Introspect> { +impl StructWithBadOptionIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { - dojo::model::introspect::Introspect::>::size() + dojo::meta::introspect::Introspect::>::size() } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::model::introspect::Introspect:: + layout: dojo::meta::introspect::Introspect:: >::layout() } ].span() @@ -2188,16 +2188,16 @@ impl StructWithBadOptionIntrospect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructWithBadOption', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::>::ty() + ty: dojo::meta::introspect::Introspect::>::ty() } ].span() @@ -2224,11 +2224,11 @@ impl EnumWithBadOptionSerde of core::serde::Serde:: { } } -impl EnumWithBadOptionIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumWithBadOptionIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::>::size(), + dojo::meta::introspect::Introspect::>::size(), Option::Some(1) ]; @@ -2239,25 +2239,25 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ - dojo::model::FieldLayout { + dojo::meta::FieldLayout { selector: 0, - layout: dojo::model::introspect::Introspect::>::layout() + layout: dojo::meta::introspect::Introspect::>::layout() } ].span() ) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumWithBadOption', attrs: array![].span(), children: array![ - ('first', dojo::model::introspect::Introspect::>::ty()) + ('first', dojo::meta::introspect::Introspect::>::ty()) ].span() } @@ -2265,14 +2265,14 @@ Option::Some(1) } } -impl EnumIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumIncompatibleAttrsIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ ].span() @@ -2280,9 +2280,9 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumIncompatibleAttrs', attrs: array![].span(), children: array![ @@ -2294,14 +2294,14 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl EnumIncompatibleAttrsIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8 ].span() @@ -2309,9 +2309,9 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumIncompatibleAttrs', attrs: array![].span(), children: array![ @@ -2323,14 +2323,14 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl StructIncompatibleAttrsIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ ].span() @@ -2338,9 +2338,9 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect< } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructIncompatibleAttrs', attrs: array![].span(), children: array![ @@ -2352,14 +2352,14 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect< } } -impl StructIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect> { +impl StructIncompatibleAttrsIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ ].span() @@ -2367,9 +2367,9 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect< } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructIncompatibleAttrs', attrs: array![].span(), children: array![ @@ -2381,14 +2381,14 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::model::introspect::Introspect< } } -impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect> { +impl StructIncompatibleAttrs2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Struct( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( array![ ].span() @@ -2396,9 +2396,9 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructIncompatibleAttrs2', attrs: array![].span(), children: array![ @@ -2410,14 +2410,14 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect } } -impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect> { +impl StructIncompatibleAttrs2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ ].span() @@ -2425,9 +2425,9 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructIncompatibleAttrs2', attrs: array![].span(), children: array![ @@ -2439,14 +2439,14 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect } } -impl EnumIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect> { +impl EnumIncompatibleAttrs2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Enum( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Enum( array![ ].span() @@ -2454,9 +2454,9 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumIncompatibleAttrs2', attrs: array![].span(), children: array![ @@ -2468,14 +2468,14 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl EnumIncompatibleAttrs2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8 ].span() @@ -2483,9 +2483,9 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumIncompatibleAttrs2', attrs: array![].span(), children: array![ @@ -2497,14 +2497,14 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl StructPacked1Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8 ].span() @@ -2512,16 +2512,16 @@ impl StructPacked1Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructPacked1', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -2530,14 +2530,14 @@ impl StructPacked1Introspect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl StructPacked2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(3) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8,128,128 ].span() @@ -2545,21 +2545,21 @@ impl StructPacked2Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructPacked2', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'y', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -2568,14 +2568,14 @@ dojo::model::introspect::Member { } } -impl StructPacked3Introspect<> of dojo::model::introspect::Introspect> { +impl StructPacked3Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(4) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 128,128,8,32 ].span() @@ -2583,24 +2583,24 @@ impl StructPacked3Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructPacked3', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'y', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Tuple( + ty: dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -2611,14 +2611,14 @@ dojo::model::introspect::Introspect::::ty() } } -impl StructNotPackable1Introspect<> of dojo::model::introspect::Introspect> { +impl StructNotPackable1Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8,ERROR ].span() @@ -2626,23 +2626,23 @@ impl StructNotPackable1Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructNotPackable1', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'y', attrs: array![].span(), - ty: dojo::model::introspect::Ty::Array( + ty: dojo::meta::introspect::Ty::Array( array![ - dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty() ].span() ) } @@ -2653,11 +2653,11 @@ dojo::model::introspect::Member { } } -impl StructPackableWithInnerPackedIntrospect<> of dojo::model::introspect::Introspect> { +impl StructPackableWithInnerPackedIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(1) ]; @@ -2666,10 +2666,10 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { + fn layout() -> dojo::meta::Layout { let mut layouts = array![ - dojo::model::Layout::Fixed(array![8].span()), -dojo::model::introspect::Introspect::::layout() + dojo::meta::Layout::Fixed(array![8].span()), +dojo::meta::introspect::Introspect::::layout() ]; let mut merged_layout = ArrayTrait::::new(); @@ -2677,7 +2677,7 @@ dojo::model::introspect::Introspect::::layout() match ArrayTrait::pop_front(ref layouts) { Option::Some(mut layout) => { match layout { - dojo::model::Layout::Fixed(mut l) => { + dojo::meta::Layout::Fixed(mut l) => { loop { match SpanTrait::pop_front(ref l) { Option::Some(x) => merged_layout.append(*x), @@ -2692,26 +2692,26 @@ dojo::model::introspect::Introspect::::layout() }; }; - dojo::model::Layout::Fixed(merged_layout.span()) + dojo::meta::Layout::Fixed(merged_layout.span()) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Struct( - dojo::model::introspect::Struct { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { name: 'StructPackableWithInnerPacked', attrs: array![].span(), children: array![ - dojo::model::introspect::Member { + dojo::meta::introspect::Member { name: 'x', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() }, -dojo::model::introspect::Member { +dojo::meta::introspect::Member { name: 'y', attrs: array![].span(), - ty: dojo::model::introspect::Introspect::::ty() + ty: dojo::meta::introspect::Introspect::::ty() } ].span() @@ -2720,14 +2720,14 @@ dojo::model::introspect::Member { } } -impl EnumPacked1Introspect<> of dojo::model::introspect::Introspect> { +impl EnumPacked1Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(1) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8 ].span() @@ -2735,15 +2735,15 @@ impl EnumPacked1Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumPacked1', attrs: array![].span(), children: array![ - ('a', dojo::model::introspect::Ty::Tuple(array![].span())), -('b', dojo::model::introspect::Ty::Tuple(array![].span())), -('c', dojo::model::introspect::Ty::Tuple(array![].span())) + ('a', dojo::meta::introspect::Ty::Tuple(array![].span())), +('b', dojo::meta::introspect::Ty::Tuple(array![].span())), +('c', dojo::meta::introspect::Ty::Tuple(array![].span())) ].span() } @@ -2751,14 +2751,14 @@ impl EnumPacked1Introspect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl EnumPacked2Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(2) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8,8 ].span() @@ -2766,15 +2766,15 @@ impl EnumPacked2Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumPacked2', attrs: array![].span(), children: array![ - ('a', dojo::model::introspect::Introspect::::ty()), -('b', dojo::model::introspect::Introspect::::ty()), -('c', dojo::model::introspect::Introspect::::ty()) + ('a', dojo::meta::introspect::Introspect::::ty()), +('b', dojo::meta::introspect::Introspect::::ty()), +('c', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -2782,14 +2782,14 @@ impl EnumPacked2Introspect<> of dojo::model::introspect::Introspect of dojo::model::introspect::Introspect> { +impl EnumPacked3Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::Some(3) } - fn layout() -> dojo::model::Layout { - dojo::model::Layout::Fixed( + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Fixed( array![ 8,128,128 ].span() @@ -2797,19 +2797,19 @@ impl EnumPacked3Introspect<> of dojo::model::introspect::Introspect dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumPacked3', attrs: array![].span(), children: array![ - ('a', dojo::model::introspect::Ty::Tuple( + ('a', dojo::meta::introspect::Ty::Tuple( array![ - dojo::model::introspect::Introspect::::ty(), -dojo::model::introspect::Introspect::::ty() + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() ].span() )), -('b', dojo::model::introspect::Introspect::::ty()) +('b', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -2817,11 +2817,11 @@ dojo::model::introspect::Introspect::::ty() } } -impl EnumPackableWithInnerPackedIntrospect<> of dojo::model::introspect::Introspect> { +impl EnumPackableWithInnerPackedIntrospect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::model::introspect::Introspect::::size(), + dojo::meta::introspect::Introspect::::size(), Option::Some(1) ]; @@ -2830,10 +2830,10 @@ Option::Some(1) } - fn layout() -> dojo::model::Layout { + fn layout() -> dojo::meta::Layout { let mut layouts = array![ - dojo::model::Layout::Fixed(array![8].span()), -dojo::model::introspect::Introspect::::layout() + dojo::meta::Layout::Fixed(array![8].span()), +dojo::meta::introspect::Introspect::::layout() ]; let mut merged_layout = ArrayTrait::::new(); @@ -2841,7 +2841,7 @@ dojo::model::introspect::Introspect::::layout() match ArrayTrait::pop_front(ref layouts) { Option::Some(mut layout) => { match layout { - dojo::model::Layout::Fixed(mut l) => { + dojo::meta::Layout::Fixed(mut l) => { loop { match SpanTrait::pop_front(ref l) { Option::Some(x) => merged_layout.append(*x), @@ -2856,19 +2856,19 @@ dojo::model::introspect::Introspect::::layout() }; }; - dojo::model::Layout::Fixed(merged_layout.span()) + dojo::meta::Layout::Fixed(merged_layout.span()) } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumPackableWithInnerPacked', attrs: array![].span(), children: array![ - ('a', dojo::model::introspect::Introspect::::ty()), -('b', dojo::model::introspect::Introspect::::ty()) + ('a', dojo::meta::introspect::Introspect::::ty()), +('b', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -2876,25 +2876,25 @@ dojo::model::introspect::Introspect::::layout() } } -impl EnumNotPackable1Introspect<> of dojo::model::introspect::Introspect> { +impl EnumNotPackable1Introspect<> of dojo::meta::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - fn layout() -> dojo::model::Layout { + fn layout() -> dojo::meta::Layout { ERROR } #[inline(always)] - fn ty() -> dojo::model::introspect::Ty { - dojo::model::introspect::Ty::Enum( - dojo::model::introspect::Enum { + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Enum( + dojo::meta::introspect::Enum { name: 'EnumNotPackable1', attrs: array![].span(), children: array![ - ('a', dojo::model::introspect::Introspect::::ty()), -('b', dojo::model::introspect::Introspect::::ty()) + ('a', dojo::meta::introspect::Introspect::::ty()), +('b', dojo::meta::introspect::Introspect::::ty()) ].span() } @@ -2914,24 +2914,24 @@ error: Option cannot be used with tuples. Prefer using a struct. ^*****************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /tmp/plugin_test/introspect/src/lib.cairo:180:6 -enum EnumIncompatibleAttrs {} - ^*******************^ + --> /tmp/plugin_test/introspect/src/lib.cairo:179:1 +#[derive(Introspect, IntrospectPacked)] +^*************************************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /tmp/plugin_test/introspect/src/lib.cairo:183:8 -struct StructIncompatibleAttrs {} - ^*********************^ + --> /tmp/plugin_test/introspect/src/lib.cairo:182:1 +#[derive(Introspect, IntrospectPacked)] +^*************************************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /tmp/plugin_test/introspect/src/lib.cairo:187:8 -struct StructIncompatibleAttrs2 {} - ^**********************^ + --> /tmp/plugin_test/introspect/src/lib.cairo:185:1 +#[derive(Introspect)] +^*******************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /tmp/plugin_test/introspect/src/lib.cairo:191:6 -enum EnumIncompatibleAttrs2 {} - ^********************^ + --> /tmp/plugin_test/introspect/src/lib.cairo:189:1 +#[derive(Introspect)] +^*******************^ error: Array field cannot be packed. --> /tmp/plugin_test/introspect/src/lib.cairo:213:6 diff --git a/crates/dojo/lang/src/plugin_test_data/model b/crates/dojo/lang/src/plugin_test_data/model new file mode 100644 index 0000000000..ad5ec36787 --- /dev/null +++ b/crates/dojo/lang/src/plugin_test_data/model @@ -0,0 +1,9182 @@ +//! > Test expansion of the dojo::model. + +//! > test_runner_name +test_expand_plugin + +//! > test_id +model + +//! > cairo_code +#[dojo::model(version: 0)] +#[dojo::model(version: 0)] +struct BadModelMultipleAttr { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 0, version: 0)] +struct BadModelMultipleVersions { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: hello)] +struct BadModelBadVersionType { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version)] +struct BadModelNoVersionValue { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(my_arg: 1)] +struct BadModelUnexpectedArgWithValue { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(my_arg)] +struct BadModelUnexpectedArg { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 2)] +struct BadModelNotSupportedVersion { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 0)] +struct Modelv0 { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'MyNamespace')] +struct ModelWithBadNamespaceFormat { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'my_namespace')] +struct ModelWithShortStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: "my_namespace")] +struct ModelWithStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model] +struct Position { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model] +struct Roles { + role_ids: Array +} + +#[dojo::model] +struct OnlyKeyModel { + #[key] + id: felt252 +} + +#[dojo::model] +struct U256KeyModel { + #[key] + id: u256 +} + +#[dojo::model] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, +} + +#[dojo::model] +type OtherPlayer = Player; + +#[dojo::model] +struct ModelWithSimpleArray { + #[key] + player: ContractAddress, + x: u16, + y: Array +} + +#[dojo::model] +struct ModelWithByteArray { + #[key] + player: ContractAddress, + x: u16, + y: ByteArray +} + +#[dojo::model] +struct ModelWithComplexArray { + #[key] + player: ContractAddress, + x: u16, + y: Array +} + +#[dojo::model] +struct ModelWithTuple { + #[key] + player: ContractAddress, + x: u16, + y: (u8, u16, u32) +} + +#[dojo::model] +struct ModelWithTupleNoPrimitives { + #[key] + player: ContractAddress, + x: u16, + y: (u8, Vec3, u32) +} + +//! > expanded_cairo_code +#[dojo::model(version: 0)] +#[dojo::model(version: 0)] +struct BadModelMultipleAttr { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 0, version: 0)] +struct BadModelMultipleVersions { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: hello)] +struct BadModelBadVersionType { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version)] +struct BadModelNoVersionValue { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(my_arg: 1)] +struct BadModelUnexpectedArgWithValue { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(my_arg)] +struct BadModelUnexpectedArg { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 2)] +struct BadModelNotSupportedVersion { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(version: 0)] +struct Modelv0 { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'MyNamespace')] +struct ModelWithBadNamespaceFormat { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'my_namespace')] +struct ModelWithShortStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: "my_namespace")] +struct ModelWithStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model] +struct Position { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model] +struct Roles { + role_ids: Array +} + +#[dojo::model] +struct OnlyKeyModel { + #[key] + id: felt252 +} + +#[dojo::model] +struct U256KeyModel { + #[key] + id: u256 +} + +#[dojo::model] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, +} + +#[dojo::model] +type OtherPlayer = Player; + +#[dojo::model] +struct ModelWithSimpleArray { + #[key] + player: ContractAddress, + x: u16, + y: Array +} + +#[dojo::model] +struct ModelWithByteArray { + #[key] + player: ContractAddress, + x: u16, + y: ByteArray +} + +#[dojo::model] +struct ModelWithComplexArray { + #[key] + player: ContractAddress, + x: u16, + y: Array +} + +#[dojo::model] +struct ModelWithTuple { + #[key] + player: ContractAddress, + x: u16, + y: (u8, u16, u32) +} + +#[dojo::model] +struct ModelWithTupleNoPrimitives { + #[key] + player: ContractAddress, + x: u16, + y: (u8, Vec3, u32) +} +impl Modelv0Introspect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::meta::introspect::Introspect::::size() + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'Modelv0', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct Modelv0Entity { + __id: felt252, // private field + pub v: Vec3, + +} + +type Modelv0KeyType = felt252; + +pub impl Modelv0KeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @Modelv0) -> Modelv0KeyType { + *self.id + } +} + +impl Modelv0EntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod modelv_0_definition { + use super::Modelv0; + pub impl Modelv0DefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "Modelv0" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-Modelv0" + } + + #[inline(always)] + fn version() -> u8 { + 0 + } + + #[inline(always)] + fn selector() -> felt252 { + "Modelv0" + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2212879130471315306779111820244908968466545702031328551192231795237740448313 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl Modelv0Definition = modelv_0_definition::Modelv0DefinitionImpl; +pub impl Modelv0EntityDefinition = modelv_0_definition::Modelv0DefinitionImpl; + +pub impl Modelv0ModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @Modelv0) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @Modelv0) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl Modelv0EntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @Modelv0Entity) -> felt252 { + *self.__id + } + fn serialize_values(self: @Modelv0Entity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl Modelv0ModelImpl = dojo::model::model::ModelImpl; +pub impl Modelv0Store = dojo::model::model::ModelStoreImpl; + +pub impl Modelv0EntityImpl = dojo::model::entity::EntityImpl; +pub impl Modelv0EntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl Modelv0MembersStoreImpl of Modelv0MembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: Modelv0KeyType) -> Vec3 { + Modelv0Store::get_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { + Modelv0EntityStore::get_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn update_v(self: dojo::world::IWorldDispatcher, key: Modelv0KeyType, value: Vec3) { + Modelv0Store::update_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3) { + Modelv0EntityStore::update_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + +} + + +#[starknet::interface] +pub trait IModelv0 { + fn ensure_abi(self: @T, model: Modelv0); +} + +#[starknet::contract] +pub mod modelv_0 { + use super::Modelv0; + use super::IModelv0; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl Modelv0Impl of IModelv0{ + fn ensure_abi(self: @ContractState, model: Modelv0) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__Modelv0Impl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + Modelv0Impl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__Modelv0Impl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithBadNamespaceFormatIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::meta::introspect::Introspect::::size() + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithBadNamespaceFormat', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithBadNamespaceFormatEntity { + __id: felt252, // private field + pub v: Vec3, + +} + +type ModelWithBadNamespaceFormatKeyType = felt252; + +pub impl ModelWithBadNamespaceFormatKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithBadNamespaceFormat) -> ModelWithBadNamespaceFormatKeyType { + *self.id + } +} + +impl ModelWithBadNamespaceFormatEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_bad_namespace_format_definition { + use super::ModelWithBadNamespaceFormat; + pub impl ModelWithBadNamespaceFormatDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithBadNamespaceFormat" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "MyNamespace" + } + + #[inline(always)] + fn tag() -> ByteArray { + "MyNamespace-ModelWithBadNamespaceFormat" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3498075185010572568869958326439183660947774785526793544998939163671395407352 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 513559242384681567568052881519197161166285694153303371154270254637843894159 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 2518247443458975119180817677753479732439290689944304814934908400279022945373 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithBadNamespaceFormatDefinition = model_with_bad_namespace_format_definition::ModelWithBadNamespaceFormatDefinitionImpl; +pub impl ModelWithBadNamespaceFormatEntityDefinition = model_with_bad_namespace_format_definition::ModelWithBadNamespaceFormatDefinitionImpl; + +pub impl ModelWithBadNamespaceFormatModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithBadNamespaceFormat) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithBadNamespaceFormat) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithBadNamespaceFormatEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithBadNamespaceFormatEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithBadNamespaceFormatEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithBadNamespaceFormatModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithBadNamespaceFormatStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithBadNamespaceFormatEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithBadNamespaceFormatEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithBadNamespaceFormatMembersStoreImpl of ModelWithBadNamespaceFormatMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithBadNamespaceFormatKeyType) -> Vec3 { + ModelWithBadNamespaceFormatStore::get_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { + ModelWithBadNamespaceFormatEntityStore::get_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithBadNamespaceFormatKeyType, value: Vec3) { + ModelWithBadNamespaceFormatStore::update_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3) { + ModelWithBadNamespaceFormatEntityStore::update_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithBadNamespaceFormat { + fn ensure_abi(self: @T, model: ModelWithBadNamespaceFormat); +} + +#[starknet::contract] +pub mod model_with_bad_namespace_format { + use super::ModelWithBadNamespaceFormat; + use super::IModelWithBadNamespaceFormat; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithBadNamespaceFormatImpl of IModelWithBadNamespaceFormat{ + fn ensure_abi(self: @ContractState, model: ModelWithBadNamespaceFormat) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithBadNamespaceFormatImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithBadNamespaceFormatImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithBadNamespaceFormatImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithShortStringNamespaceIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::meta::introspect::Introspect::::size() + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithShortStringNamespace', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithShortStringNamespaceEntity { + __id: felt252, // private field + pub v: Vec3, + +} + +type ModelWithShortStringNamespaceKeyType = felt252; + +pub impl ModelWithShortStringNamespaceKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithShortStringNamespace) -> ModelWithShortStringNamespaceKeyType { + *self.id + } +} + +impl ModelWithShortStringNamespaceEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_short_string_namespace_definition { + use super::ModelWithShortStringNamespace; + pub impl ModelWithShortStringNamespaceDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithShortStringNamespace" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "my_namespace" + } + + #[inline(always)] + fn tag() -> ByteArray { + "my_namespace-ModelWithShortStringNamespace" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 643350075018191729855964658181798951445581630505240307235771395728709379388 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 4646597166239297873853881466258165424425132957303541470648153031188639878 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithShortStringNamespaceDefinition = model_with_short_string_namespace_definition::ModelWithShortStringNamespaceDefinitionImpl; +pub impl ModelWithShortStringNamespaceEntityDefinition = model_with_short_string_namespace_definition::ModelWithShortStringNamespaceDefinitionImpl; + +pub impl ModelWithShortStringNamespaceModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithShortStringNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithShortStringNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithShortStringNamespaceEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithShortStringNamespaceEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithShortStringNamespaceEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithShortStringNamespaceModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithShortStringNamespaceStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithShortStringNamespaceEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithShortStringNamespaceEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithShortStringNamespaceMembersStoreImpl of ModelWithShortStringNamespaceMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithShortStringNamespaceKeyType) -> Vec3 { + ModelWithShortStringNamespaceStore::get_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { + ModelWithShortStringNamespaceEntityStore::get_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithShortStringNamespaceKeyType, value: Vec3) { + ModelWithShortStringNamespaceStore::update_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3) { + ModelWithShortStringNamespaceEntityStore::update_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithShortStringNamespace { + fn ensure_abi(self: @T, model: ModelWithShortStringNamespace); +} + +#[starknet::contract] +pub mod model_with_short_string_namespace { + use super::ModelWithShortStringNamespace; + use super::IModelWithShortStringNamespace; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithShortStringNamespaceImpl of IModelWithShortStringNamespace{ + fn ensure_abi(self: @ContractState, model: ModelWithShortStringNamespace) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithShortStringNamespaceImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithShortStringNamespaceImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithShortStringNamespaceImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithStringNamespaceIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::meta::introspect::Introspect::::size() + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithStringNamespace', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithStringNamespaceEntity { + __id: felt252, // private field + pub v: Vec3, + +} + +type ModelWithStringNamespaceKeyType = felt252; + +pub impl ModelWithStringNamespaceKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithStringNamespace) -> ModelWithStringNamespaceKeyType { + *self.id + } +} + +impl ModelWithStringNamespaceEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_string_namespace_definition { + use super::ModelWithStringNamespace; + pub impl ModelWithStringNamespaceDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithStringNamespace" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "my_namespace" + } + + #[inline(always)] + fn tag() -> ByteArray { + "my_namespace-ModelWithStringNamespace" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2567055065785696374111447326195815858786390804996225951953791904194802101726 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 36187013840655350498900857372670392628596870210415176261336407419317644423 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithStringNamespaceDefinition = model_with_string_namespace_definition::ModelWithStringNamespaceDefinitionImpl; +pub impl ModelWithStringNamespaceEntityDefinition = model_with_string_namespace_definition::ModelWithStringNamespaceDefinitionImpl; + +pub impl ModelWithStringNamespaceModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithStringNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithStringNamespace) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithStringNamespaceEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithStringNamespaceEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithStringNamespaceEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithStringNamespaceModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithStringNamespaceStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithStringNamespaceEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithStringNamespaceEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithStringNamespaceMembersStoreImpl of ModelWithStringNamespaceMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithStringNamespaceKeyType) -> Vec3 { + ModelWithStringNamespaceStore::get_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { + ModelWithStringNamespaceEntityStore::get_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithStringNamespaceKeyType, value: Vec3) { + ModelWithStringNamespaceStore::update_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3) { + ModelWithStringNamespaceEntityStore::update_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithStringNamespace { + fn ensure_abi(self: @T, model: ModelWithStringNamespace); +} + +#[starknet::contract] +pub mod model_with_string_namespace { + use super::ModelWithStringNamespace; + use super::IModelWithStringNamespace; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithStringNamespaceImpl of IModelWithStringNamespace{ + fn ensure_abi(self: @ContractState, model: ModelWithStringNamespace) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithStringNamespaceImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithStringNamespaceImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithStringNamespaceImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl PositionIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::meta::introspect::Introspect::::size() + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'Position', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct PositionEntity { + __id: felt252, // private field + pub v: Vec3, + +} + +type PositionKeyType = felt252; + +pub impl PositionKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @Position) -> PositionKeyType { + *self.id + } +} + +impl PositionEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod position_definition { + use super::Position; + pub impl PositionDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "Position" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-Position" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 1782729361185285637005619480739442196364037716000358448825261820703351159758 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2899920299641094436341712346886623904698864491830316325765258522168980161362 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl PositionDefinition = position_definition::PositionDefinitionImpl; +pub impl PositionEntityDefinition = position_definition::PositionDefinitionImpl; + +pub impl PositionModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @Position) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @Position) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl PositionEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @PositionEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @PositionEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl PositionModelImpl = dojo::model::model::ModelImpl; +pub impl PositionStore = dojo::model::model::ModelStoreImpl; + +pub impl PositionEntityImpl = dojo::model::entity::EntityImpl; +pub impl PositionEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl PositionMembersStoreImpl of PositionMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: PositionKeyType) -> Vec3 { + PositionStore::get_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3 { + PositionEntityStore::get_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080) + } + + fn update_v(self: dojo::world::IWorldDispatcher, key: PositionKeyType, value: Vec3) { + PositionStore::update_member(self, key, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3) { + PositionEntityStore::update_member_from_id(self, entity_id, 578691550836206188651404750433984985630363913126316857592149308417275000080, value); + } + + +} + + +#[starknet::interface] +pub trait IPosition { + fn ensure_abi(self: @T, model: Position); +} + +#[starknet::contract] +pub mod position { + use super::Position; + use super::IPosition; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl PositionImpl of IPosition{ + fn ensure_abi(self: @ContractState, model: Position) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__PositionImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + PositionImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__PositionImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl PlayerIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(1) + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'Player', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'game', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'name', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + #[derive()] +pub struct PlayerEntity { + __id: felt252, // private field + pub name: felt252, + +} + +type PlayerKeyType = (felt252, ContractAddress); + +pub impl PlayerKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @Player) -> PlayerKeyType { + (*self.game, *self.player) + } +} + +impl PlayerEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod player_definition { + use super::Player; + pub impl PlayerDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "Player" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-Player" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 32472305970791489884889070587064570056671760620943135506258424375410423946 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1073075359926275415180704315933677548333097210683379121732618306925003101845 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl PlayerDefinition = player_definition::PlayerDefinitionImpl; +pub impl PlayerEntityDefinition = player_definition::PlayerDefinitionImpl; + +pub impl PlayerModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @Player) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.game, ref serialized); +core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @Player) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.name, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl PlayerEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @PlayerEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @PlayerEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.name, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl PlayerModelImpl = dojo::model::model::ModelImpl; +pub impl PlayerStore = dojo::model::model::ModelStoreImpl; + +pub impl PlayerEntityImpl = dojo::model::entity::EntityImpl; +pub impl PlayerEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl PlayerMembersStoreImpl of PlayerMembersStore { + fn get_name(self: @dojo::world::IWorldDispatcher, key: PlayerKeyType) -> felt252 { + PlayerStore::get_member(self, key, 1528802474226268325865027367859591458315299653151958663884057507666229546336) + } + + fn get_name_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> felt252 { + PlayerEntityStore::get_member_from_id(self, entity_id, 1528802474226268325865027367859591458315299653151958663884057507666229546336) + } + + fn update_name(self: dojo::world::IWorldDispatcher, key: PlayerKeyType, value: felt252) { + PlayerStore::update_member(self, key, 1528802474226268325865027367859591458315299653151958663884057507666229546336, value); + } + + fn update_name_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: felt252) { + PlayerEntityStore::update_member_from_id(self, entity_id, 1528802474226268325865027367859591458315299653151958663884057507666229546336, value); + } + + +} + + +#[starknet::interface] +pub trait IPlayer { + fn ensure_abi(self: @T, model: Player); +} + +#[starknet::contract] +pub mod player { + use super::Player; + use super::IPlayer; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl PlayerImpl of IPlayer{ + fn ensure_abi(self: @ContractState, model: Player) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__PlayerImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + PlayerImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__PlayerImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithSimpleArrayIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::meta::introspect::Introspect::::layout() + }, +dojo::meta::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::meta::introspect::Introspect:: +>::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithSimpleArray', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::Array( + array![ + dojo::meta::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithSimpleArrayEntity { + __id: felt252, // private field + pub x: u16, +pub y: Array, + +} + +type ModelWithSimpleArrayKeyType = ContractAddress; + +pub impl ModelWithSimpleArrayKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithSimpleArray) -> ModelWithSimpleArrayKeyType { + *self.player + } +} + +impl ModelWithSimpleArrayEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_simple_array_definition { + use super::ModelWithSimpleArray; + pub impl ModelWithSimpleArrayDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithSimpleArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-ModelWithSimpleArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2155888289741706273257207428305937938996511115291276975807216945184181752777 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 173141902001925402715103859951360389436088950156916962046507357841237663931 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithSimpleArrayDefinition = model_with_simple_array_definition::ModelWithSimpleArrayDefinitionImpl; +pub impl ModelWithSimpleArrayEntityDefinition = model_with_simple_array_definition::ModelWithSimpleArrayDefinitionImpl; + +pub impl ModelWithSimpleArrayModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithSimpleArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithSimpleArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithSimpleArrayEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithSimpleArrayEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithSimpleArrayEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithSimpleArrayModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithSimpleArrayStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithSimpleArrayEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithSimpleArrayEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithSimpleArrayMembersStoreImpl of ModelWithSimpleArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType) -> u16 { + ModelWithSimpleArrayStore::get_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { + ModelWithSimpleArrayEntityStore::get_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType, value: u16) { + ModelWithSimpleArrayStore::update_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16) { + ModelWithSimpleArrayEntityStore::update_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType) -> Array { + ModelWithSimpleArrayStore::get_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Array { + ModelWithSimpleArrayEntityStore::get_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType, value: Array) { + ModelWithSimpleArrayStore::update_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Array) { + ModelWithSimpleArrayEntityStore::update_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithSimpleArray { + fn ensure_abi(self: @T, model: ModelWithSimpleArray); +} + +#[starknet::contract] +pub mod model_with_simple_array { + use super::ModelWithSimpleArray; + use super::IModelWithSimpleArray; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithSimpleArrayImpl of IModelWithSimpleArray{ + fn ensure_abi(self: @ContractState, model: ModelWithSimpleArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithSimpleArrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithSimpleArrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithSimpleArrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithByteArrayIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::meta::introspect::Introspect::::layout() + }, +dojo::meta::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::meta::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithByteArray', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::ByteArray + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithByteArrayEntity { + __id: felt252, // private field + pub x: u16, +pub y: ByteArray, + +} + +type ModelWithByteArrayKeyType = ContractAddress; + +pub impl ModelWithByteArrayKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithByteArray) -> ModelWithByteArrayKeyType { + *self.player + } +} + +impl ModelWithByteArrayEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_byte_array_definition { + use super::ModelWithByteArray; + pub impl ModelWithByteArrayDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithByteArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-ModelWithByteArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2309493726682581230048608406375650493303358263694405202817326852234706548038 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2176409715042145900636260236501596599545103472111273072320531220776338338674 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithByteArrayDefinition = model_with_byte_array_definition::ModelWithByteArrayDefinitionImpl; +pub impl ModelWithByteArrayEntityDefinition = model_with_byte_array_definition::ModelWithByteArrayDefinitionImpl; + +pub impl ModelWithByteArrayModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithByteArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithByteArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithByteArrayEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithByteArrayEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithByteArrayEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithByteArrayModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithByteArrayStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithByteArrayEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithByteArrayEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithByteArrayMembersStoreImpl of ModelWithByteArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType) -> u16 { + ModelWithByteArrayStore::get_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { + ModelWithByteArrayEntityStore::get_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType, value: u16) { + ModelWithByteArrayStore::update_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16) { + ModelWithByteArrayEntityStore::update_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType) -> ByteArray { + ModelWithByteArrayStore::get_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> ByteArray { + ModelWithByteArrayEntityStore::get_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType, value: ByteArray) { + ModelWithByteArrayStore::update_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: ByteArray) { + ModelWithByteArrayEntityStore::update_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithByteArray { + fn ensure_abi(self: @T, model: ModelWithByteArray); +} + +#[starknet::contract] +pub mod model_with_byte_array { + use super::ModelWithByteArray; + use super::IModelWithByteArray; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithByteArrayImpl of IModelWithByteArray{ + fn ensure_abi(self: @ContractState, model: ModelWithByteArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithByteArrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithByteArrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithByteArrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithComplexArrayIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::meta::introspect::Introspect::::layout() + }, +dojo::meta::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::meta::introspect::Introspect:: +>::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithComplexArray', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::Array( + array![ + dojo::meta::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithComplexArrayEntity { + __id: felt252, // private field + pub x: u16, +pub y: Array, + +} + +type ModelWithComplexArrayKeyType = ContractAddress; + +pub impl ModelWithComplexArrayKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithComplexArray) -> ModelWithComplexArrayKeyType { + *self.player + } +} + +impl ModelWithComplexArrayEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_complex_array_definition { + use super::ModelWithComplexArray; + pub impl ModelWithComplexArrayDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithComplexArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-ModelWithComplexArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 1293570145807126672811046976011709110822800800255162893130594439459909679461 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2866472224509756243720005045848892642397514372569303051745174230372637769655 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithComplexArrayDefinition = model_with_complex_array_definition::ModelWithComplexArrayDefinitionImpl; +pub impl ModelWithComplexArrayEntityDefinition = model_with_complex_array_definition::ModelWithComplexArrayDefinitionImpl; + +pub impl ModelWithComplexArrayModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithComplexArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithComplexArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithComplexArrayEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithComplexArrayEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithComplexArrayEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithComplexArrayModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithComplexArrayStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithComplexArrayEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithComplexArrayEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithComplexArrayMembersStoreImpl of ModelWithComplexArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType) -> u16 { + ModelWithComplexArrayStore::get_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { + ModelWithComplexArrayEntityStore::get_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType, value: u16) { + ModelWithComplexArrayStore::update_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16) { + ModelWithComplexArrayEntityStore::update_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType) -> Array { + ModelWithComplexArrayStore::get_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Array { + ModelWithComplexArrayEntityStore::get_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType, value: Array) { + ModelWithComplexArrayStore::update_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Array) { + ModelWithComplexArrayEntityStore::update_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithComplexArray { + fn ensure_abi(self: @T, model: ModelWithComplexArray); +} + +#[starknet::contract] +pub mod model_with_complex_array { + use super::ModelWithComplexArray; + use super::IModelWithComplexArray; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithComplexArrayImpl of IModelWithComplexArray{ + fn ensure_abi(self: @ContractState, model: ModelWithComplexArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithComplexArrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithComplexArrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithComplexArrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithTupleIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(4) + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::meta::introspect::Introspect::::layout() + }, +dojo::meta::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::meta::Layout::Tuple( + array![ + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithTuple', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::Tuple( + array![ + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithTupleEntity { + __id: felt252, // private field + pub x: u16, +pub y: (u8, u16, u32), + +} + +type ModelWithTupleKeyType = ContractAddress; + +pub impl ModelWithTupleKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithTuple) -> ModelWithTupleKeyType { + *self.player + } +} + +impl ModelWithTupleEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_tuple_definition { + use super::ModelWithTuple; + pub impl ModelWithTupleDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithTuple" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-ModelWithTuple" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2556860780543194947392385177981405629628409496147617432088261544126553394590 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 3222351670132870101782632958288197874250493316621507272653773018669253981260 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithTupleDefinition = model_with_tuple_definition::ModelWithTupleDefinitionImpl; +pub impl ModelWithTupleEntityDefinition = model_with_tuple_definition::ModelWithTupleDefinitionImpl; + +pub impl ModelWithTupleModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithTuple) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithTuple) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithTupleEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithTupleEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithTupleEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithTupleModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithTupleStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithTupleEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithTupleEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithTupleMembersStoreImpl of ModelWithTupleMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType) -> u16 { + ModelWithTupleStore::get_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { + ModelWithTupleEntityStore::get_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType, value: u16) { + ModelWithTupleStore::update_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16) { + ModelWithTupleEntityStore::update_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType) -> (u8, u16, u32) { + ModelWithTupleStore::get_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, u16, u32) { + ModelWithTupleEntityStore::get_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType, value: (u8, u16, u32)) { + ModelWithTupleStore::update_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: (u8, u16, u32)) { + ModelWithTupleEntityStore::update_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithTuple { + fn ensure_abi(self: @T, model: ModelWithTuple); +} + +#[starknet::contract] +pub mod model_with_tuple { + use super::ModelWithTuple; + use super::IModelWithTuple; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithTupleImpl of IModelWithTuple{ + fn ensure_abi(self: @ContractState, model: ModelWithTuple) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithTupleImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithTupleImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithTupleImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithTupleNoPrimitivesIntrospect<> of dojo::meta::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::meta::introspect::Introspect::::size(), +Option::Some(3) + ]; + + if dojo::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::utils::sum(sizes)) + + } + + fn layout() -> dojo::meta::Layout { + dojo::meta::Layout::Struct( + array![ + dojo::meta::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::meta::introspect::Introspect::::layout() + }, +dojo::meta::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::meta::Layout::Tuple( + array![ + dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout(), +dojo::meta::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::meta::introspect::Ty { + dojo::meta::introspect::Ty::Struct( + dojo::meta::introspect::Struct { + name: 'ModelWithTupleNoPrimitives', + attrs: array![].span(), + children: array![ + dojo::meta::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::meta::introspect::Introspect::::ty() + }, +dojo::meta::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::meta::introspect::Ty::Tuple( + array![ + dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty(), +dojo::meta::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + #[derive()] +pub struct ModelWithTupleNoPrimitivesEntity { + __id: felt252, // private field + pub x: u16, +pub y: (u8, Vec3, u32), + +} + +type ModelWithTupleNoPrimitivesKeyType = ContractAddress; + +pub impl ModelWithTupleNoPrimitivesKeyParser of dojo::model::model::KeyParser{ + #[inline(always)] + fn parse_key(self: @ModelWithTupleNoPrimitives) -> ModelWithTupleNoPrimitivesKeyType { + *self.player + } +} + +impl ModelWithTupleNoPrimitivesEntityKey of dojo::model::entity::EntityKey { +} + +// Impl to get the static definition of a model +pub mod model_with_tuple_no_primitives_definition { + use super::ModelWithTupleNoPrimitives; + pub impl ModelWithTupleNoPrimitivesDefinitionImpl of dojo::model::ModelDefinition{ + #[inline(always)] + fn name() -> ByteArray { + "ModelWithTupleNoPrimitives" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_test" + } + + #[inline(always)] + fn tag() -> ByteArray { + "dojo_test-ModelWithTupleNoPrimitives" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 59168777730614245274545541976317431416582911855710103554159293691166950405 + } + + #[inline(always)] + fn name_hash() -> felt252 { + 157059227407493660591195028728750607977045261142495925435047270200565107096 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + + #[inline(always)] + fn layout() -> dojo::meta::Layout { + dojo::meta::Introspect::::layout() + } + + #[inline(always)] + fn schema() -> dojo::meta::introspect::Ty { + dojo::meta::Introspect::::ty() + } + + #[inline(always)] + fn size() -> Option { + dojo::meta::Introspect::::size() + } + } + +} + + +pub impl ModelWithTupleNoPrimitivesDefinition = model_with_tuple_no_primitives_definition::ModelWithTupleNoPrimitivesDefinitionImpl; +pub impl ModelWithTupleNoPrimitivesEntityDefinition = model_with_tuple_no_primitives_definition::ModelWithTupleNoPrimitivesDefinitionImpl; + +pub impl ModelWithTupleNoPrimitivesModelParser of dojo::model::model::ModelParser{ + fn serialize_keys(self: @ModelWithTupleNoPrimitives) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } + fn serialize_values(self: @ModelWithTupleNoPrimitives) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + +pub impl ModelWithTupleNoPrimitivesEntityParser of dojo::model::entity::EntityParser{ + fn parse_id(self: @ModelWithTupleNoPrimitivesEntity) -> felt252 { + *self.__id + } + fn serialize_values(self: @ModelWithTupleNoPrimitivesEntity) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized); +core::serde::Serde::serialize(self.y, ref serialized); + + core::array::ArrayTrait::span(@serialized) + } +} + + +pub impl ModelWithTupleNoPrimitivesModelImpl = dojo::model::model::ModelImpl; +pub impl ModelWithTupleNoPrimitivesStore = dojo::model::model::ModelStoreImpl; + +pub impl ModelWithTupleNoPrimitivesEntityImpl = dojo::model::entity::EntityImpl; +pub impl ModelWithTupleNoPrimitivesEntityStore = dojo::model::entity::EntityStoreImpl; + + +#[generate_trait] +pub impl ModelWithTupleNoPrimitivesMembersStoreImpl of ModelWithTupleNoPrimitivesMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType) -> u16 { + ModelWithTupleNoPrimitivesStore::get_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16 { + ModelWithTupleNoPrimitivesEntityStore::get_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331) + } + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType, value: u16) { + ModelWithTupleNoPrimitivesStore::update_member(self, key, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16) { + ModelWithTupleNoPrimitivesEntityStore::update_member_from_id(self, entity_id, 512066735765477566404754172672287371265995314501343422459174036873487219331, value); + } + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType) -> (u8, Vec3, u32) { + ModelWithTupleNoPrimitivesStore::get_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, Vec3, u32) { + ModelWithTupleNoPrimitivesEntityStore::get_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819) + } + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType, value: (u8, Vec3, u32)) { + ModelWithTupleNoPrimitivesStore::update_member(self, key, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: (u8, Vec3, u32)) { + ModelWithTupleNoPrimitivesEntityStore::update_member_from_id(self, entity_id, 1591024729085637502504777720563487898377940395575083379770417352976841400819, value); + } + + +} + + +#[starknet::interface] +pub trait IModelWithTupleNoPrimitives { + fn ensure_abi(self: @T, model: ModelWithTupleNoPrimitives); +} + +#[starknet::contract] +pub mod model_with_tuple_no_primitives { + use super::ModelWithTupleNoPrimitives; + use super::IModelWithTupleNoPrimitives; + + #[abi(embed_v0)] + impl DojoModelImpl = dojo::model::component::IModelImpl; + + #[abi(embed_v0)] + impl ModelWithTupleNoPrimitivesImpl of IModelWithTupleNoPrimitives{ + fn ensure_abi(self: @ContractState, model: ModelWithTupleNoPrimitives) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateIModelImpl of + dojo::model::component::UnsafeNewContractStateTraitForIModelImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ModelWithTupleNoPrimitivesImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + ModelWithTupleNoPrimitivesImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ModelWithTupleNoPrimitivesImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} +pub trait Modelv0MembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: Modelv0KeyType) -> Vec3; + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; + + fn update_v(self: dojo::world::IWorldDispatcher, key: Modelv0KeyType, value: Vec3); + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3); + + +} +pub trait IModelv0DispatcherTrait { + fn ensure_abi(self: T, model: Modelv0); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelv0Dispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelv0DispatcherImpl of IModelv0DispatcherTrait { + fn ensure_abi(self: IModelv0Dispatcher, model: Modelv0) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelv0LibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelv0LibraryDispatcherImpl of IModelv0DispatcherTrait { + fn ensure_abi(self: IModelv0LibraryDispatcher, model: Modelv0) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelv0SafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Modelv0) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelv0SafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelv0SafeLibraryDispatcherImpl of IModelv0SafeDispatcherTrait { + fn ensure_abi(self: IModelv0SafeLibraryDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelv0SafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelv0SafeDispatcherImpl of IModelv0SafeDispatcherTrait { + fn ensure_abi(self: IModelv0SafeDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithBadNamespaceFormatMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithBadNamespaceFormatKeyType) -> Vec3; + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithBadNamespaceFormatKeyType, value: Vec3); + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3); + + +} +pub trait IModelWithBadNamespaceFormatDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithBadNamespaceFormatDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithBadNamespaceFormatDispatcherImpl of IModelWithBadNamespaceFormatDispatcherTrait { + fn ensure_abi(self: IModelWithBadNamespaceFormatDispatcher, model: ModelWithBadNamespaceFormat) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithBadNamespaceFormatLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithBadNamespaceFormatLibraryDispatcherImpl of IModelWithBadNamespaceFormatDispatcherTrait { + fn ensure_abi(self: IModelWithBadNamespaceFormatLibraryDispatcher, model: ModelWithBadNamespaceFormat) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithBadNamespaceFormatSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithBadNamespaceFormatSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherImpl of IModelWithBadNamespaceFormatSafeDispatcherTrait { + fn ensure_abi(self: IModelWithBadNamespaceFormatSafeLibraryDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithBadNamespaceFormatSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithBadNamespaceFormatSafeDispatcherImpl of IModelWithBadNamespaceFormatSafeDispatcherTrait { + fn ensure_abi(self: IModelWithBadNamespaceFormatSafeDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithShortStringNamespaceMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithShortStringNamespaceKeyType) -> Vec3; + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithShortStringNamespaceKeyType, value: Vec3); + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3); + + +} +pub trait IModelWithShortStringNamespaceDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithShortStringNamespace); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithShortStringNamespaceDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithShortStringNamespaceDispatcherImpl of IModelWithShortStringNamespaceDispatcherTrait { + fn ensure_abi(self: IModelWithShortStringNamespaceDispatcher, model: ModelWithShortStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithShortStringNamespaceLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithShortStringNamespaceLibraryDispatcherImpl of IModelWithShortStringNamespaceDispatcherTrait { + fn ensure_abi(self: IModelWithShortStringNamespaceLibraryDispatcher, model: ModelWithShortStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithShortStringNamespaceSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithShortStringNamespaceSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithShortStringNamespaceSafeLibraryDispatcherImpl of IModelWithShortStringNamespaceSafeDispatcherTrait { + fn ensure_abi(self: IModelWithShortStringNamespaceSafeLibraryDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithShortStringNamespaceSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithShortStringNamespaceSafeDispatcherImpl of IModelWithShortStringNamespaceSafeDispatcherTrait { + fn ensure_abi(self: IModelWithShortStringNamespaceSafeDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithStringNamespaceMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: ModelWithStringNamespaceKeyType) -> Vec3; + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; + + fn update_v(self: dojo::world::IWorldDispatcher, key: ModelWithStringNamespaceKeyType, value: Vec3); + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3); + + +} +pub trait IModelWithStringNamespaceDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithStringNamespace); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithStringNamespaceDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithStringNamespaceDispatcherImpl of IModelWithStringNamespaceDispatcherTrait { + fn ensure_abi(self: IModelWithStringNamespaceDispatcher, model: ModelWithStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithStringNamespaceLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithStringNamespaceLibraryDispatcherImpl of IModelWithStringNamespaceDispatcherTrait { + fn ensure_abi(self: IModelWithStringNamespaceLibraryDispatcher, model: ModelWithStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithStringNamespaceSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithStringNamespace) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithStringNamespaceSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithStringNamespaceSafeLibraryDispatcherImpl of IModelWithStringNamespaceSafeDispatcherTrait { + fn ensure_abi(self: IModelWithStringNamespaceSafeLibraryDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithStringNamespaceSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithStringNamespaceSafeDispatcherImpl of IModelWithStringNamespaceSafeDispatcherTrait { + fn ensure_abi(self: IModelWithStringNamespaceSafeDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait PositionMembersStore { + fn get_v(self: @dojo::world::IWorldDispatcher, key: PositionKeyType) -> Vec3; + + fn get_v_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Vec3; + + fn update_v(self: dojo::world::IWorldDispatcher, key: PositionKeyType, value: Vec3); + + fn update_v_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Vec3); + + +} +pub trait IPositionDispatcherTrait { + fn ensure_abi(self: T, model: Position); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPositionDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IPositionDispatcherImpl of IPositionDispatcherTrait { + fn ensure_abi(self: IPositionDispatcher, model: Position) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPositionLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IPositionLibraryDispatcherImpl of IPositionDispatcherTrait { + fn ensure_abi(self: IPositionLibraryDispatcher, model: Position) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IPositionSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Position) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPositionSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IPositionSafeLibraryDispatcherImpl of IPositionSafeDispatcherTrait { + fn ensure_abi(self: IPositionSafeLibraryDispatcher, model: Position) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPositionSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IPositionSafeDispatcherImpl of IPositionSafeDispatcherTrait { + fn ensure_abi(self: IPositionSafeDispatcher, model: Position) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait PlayerMembersStore { + fn get_name(self: @dojo::world::IWorldDispatcher, key: PlayerKeyType) -> felt252; + + fn get_name_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> felt252; + + fn update_name(self: dojo::world::IWorldDispatcher, key: PlayerKeyType, value: felt252); + + fn update_name_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: felt252); + + +} +pub trait IPlayerDispatcherTrait { + fn ensure_abi(self: T, model: Player); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPlayerDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IPlayerDispatcherImpl of IPlayerDispatcherTrait { + fn ensure_abi(self: IPlayerDispatcher, model: Player) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPlayerLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IPlayerLibraryDispatcherImpl of IPlayerDispatcherTrait { + fn ensure_abi(self: IPlayerLibraryDispatcher, model: Player) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IPlayerSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Player) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPlayerSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IPlayerSafeLibraryDispatcherImpl of IPlayerSafeDispatcherTrait { + fn ensure_abi(self: IPlayerSafeLibraryDispatcher, model: Player) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IPlayerSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IPlayerSafeDispatcherImpl of IPlayerSafeDispatcherTrait { + fn ensure_abi(self: IPlayerSafeDispatcher, model: Player) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithSimpleArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType) -> u16; + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType, value: u16); + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16); + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType) -> Array; + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Array; + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithSimpleArrayKeyType, value: Array); + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Array); + + +} +pub trait IModelWithSimpleArrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithSimpleArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithSimpleArrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithSimpleArrayDispatcherImpl of IModelWithSimpleArrayDispatcherTrait { + fn ensure_abi(self: IModelWithSimpleArrayDispatcher, model: ModelWithSimpleArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithSimpleArrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithSimpleArrayLibraryDispatcherImpl of IModelWithSimpleArrayDispatcherTrait { + fn ensure_abi(self: IModelWithSimpleArrayLibraryDispatcher, model: ModelWithSimpleArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithSimpleArraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithSimpleArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithSimpleArraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithSimpleArraySafeLibraryDispatcherImpl of IModelWithSimpleArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithSimpleArraySafeLibraryDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithSimpleArraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithSimpleArraySafeDispatcherImpl of IModelWithSimpleArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithSimpleArraySafeDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithByteArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType) -> u16; + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType, value: u16); + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16); + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType) -> ByteArray; + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> ByteArray; + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithByteArrayKeyType, value: ByteArray); + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: ByteArray); + + +} +pub trait IModelWithByteArrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithByteArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithByteArrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithByteArrayDispatcherImpl of IModelWithByteArrayDispatcherTrait { + fn ensure_abi(self: IModelWithByteArrayDispatcher, model: ModelWithByteArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithByteArrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithByteArrayLibraryDispatcherImpl of IModelWithByteArrayDispatcherTrait { + fn ensure_abi(self: IModelWithByteArrayLibraryDispatcher, model: ModelWithByteArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithByteArraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithByteArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithByteArraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithByteArraySafeLibraryDispatcherImpl of IModelWithByteArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithByteArraySafeLibraryDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithByteArraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithByteArraySafeDispatcherImpl of IModelWithByteArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithByteArraySafeDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithComplexArrayMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType) -> u16; + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType, value: u16); + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16); + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType) -> Array; + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> Array; + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithComplexArrayKeyType, value: Array); + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: Array); + + +} +pub trait IModelWithComplexArrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithComplexArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithComplexArrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithComplexArrayDispatcherImpl of IModelWithComplexArrayDispatcherTrait { + fn ensure_abi(self: IModelWithComplexArrayDispatcher, model: ModelWithComplexArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithComplexArrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithComplexArrayLibraryDispatcherImpl of IModelWithComplexArrayDispatcherTrait { + fn ensure_abi(self: IModelWithComplexArrayLibraryDispatcher, model: ModelWithComplexArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithComplexArraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithComplexArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithComplexArraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithComplexArraySafeLibraryDispatcherImpl of IModelWithComplexArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithComplexArraySafeLibraryDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithComplexArraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithComplexArraySafeDispatcherImpl of IModelWithComplexArraySafeDispatcherTrait { + fn ensure_abi(self: IModelWithComplexArraySafeDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithTupleMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType) -> u16; + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType, value: u16); + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16); + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType) -> (u8, u16, u32); + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, u16, u32); + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithTupleKeyType, value: (u8, u16, u32)); + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: (u8, u16, u32)); + + +} +pub trait IModelWithTupleDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithTuple); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithTupleDispatcherImpl of IModelWithTupleDispatcherTrait { + fn ensure_abi(self: IModelWithTupleDispatcher, model: ModelWithTuple) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithTupleLibraryDispatcherImpl of IModelWithTupleDispatcherTrait { + fn ensure_abi(self: IModelWithTupleLibraryDispatcher, model: ModelWithTuple) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithTupleSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithTuple) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithTupleSafeLibraryDispatcherImpl of IModelWithTupleSafeDispatcherTrait { + fn ensure_abi(self: IModelWithTupleSafeLibraryDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithTupleSafeDispatcherImpl of IModelWithTupleSafeDispatcherTrait { + fn ensure_abi(self: IModelWithTupleSafeDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +pub trait ModelWithTupleNoPrimitivesMembersStore { + fn get_x(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType) -> u16; + + fn get_x_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> u16; + + fn update_x(self: dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType, value: u16); + + fn update_x_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: u16); + + fn get_y(self: @dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType) -> (u8, Vec3, u32); + + fn get_y_from_id(self: @dojo::world::IWorldDispatcher, entity_id: felt252) -> (u8, Vec3, u32); + + fn update_y(self: dojo::world::IWorldDispatcher, key: ModelWithTupleNoPrimitivesKeyType, value: (u8, Vec3, u32)); + + fn update_y_from_id(self: dojo::world::IWorldDispatcher, entity_id: felt252, value: (u8, Vec3, u32)); + + +} +pub trait IModelWithTupleNoPrimitivesDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleNoPrimitivesDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithTupleNoPrimitivesDispatcherImpl of IModelWithTupleNoPrimitivesDispatcherTrait { + fn ensure_abi(self: IModelWithTupleNoPrimitivesDispatcher, model: ModelWithTupleNoPrimitives) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleNoPrimitivesLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithTupleNoPrimitivesLibraryDispatcherImpl of IModelWithTupleNoPrimitivesDispatcherTrait { + fn ensure_abi(self: IModelWithTupleNoPrimitivesLibraryDispatcher, model: ModelWithTupleNoPrimitives) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IModelWithTupleNoPrimitivesSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleNoPrimitivesSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherImpl of IModelWithTupleNoPrimitivesSafeDispatcherTrait { + fn ensure_abi(self: IModelWithTupleNoPrimitivesSafeLibraryDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IModelWithTupleNoPrimitivesSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IModelWithTupleNoPrimitivesSafeDispatcherImpl of IModelWithTupleNoPrimitivesSafeDispatcherTrait { + fn ensure_abi(self: IModelWithTupleNoPrimitivesSafeDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl IModelv0DispatcherCopy of core::traits::Copy::; +impl IModelv0DispatcherDrop of core::traits::Drop::; +impl IModelv0DispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelv0Dispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelv0Dispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelv0Dispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelv0Dispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelv0Dispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelv0Dispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelv0Dispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelv0DispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelv0DispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelv0DispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelv0DispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0DispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelv0DispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelv0DispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelv0DispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelv0DispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0DispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelv0LibraryDispatcherCopy of core::traits::Copy::; +impl IModelv0LibraryDispatcherDrop of core::traits::Drop::; +impl IModelv0LibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelv0LibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelv0LibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelv0LibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelv0LibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelv0LibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelv0LibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelv0LibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelv0LibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelv0LibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelv0LibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelv0LibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0LibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelv0LibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelv0LibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelv0LibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelv0LibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0LibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelv0SafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelv0SafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelv0SafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelv0SafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelv0SafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelv0SafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelv0SafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelv0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelv0SafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelv0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelv0SafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelv0SafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelv0SafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelv0SafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0SafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelv0SafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelv0SafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelv0SafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelv0SafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0SafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelv0SafeDispatcherCopy of core::traits::Copy::; +impl IModelv0SafeDispatcherDrop of core::traits::Drop::; +impl IModelv0SafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelv0SafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelv0SafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelv0SafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelv0SafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelv0SafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelv0SafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelv0SafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelv0SafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelv0SafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelv0SafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelv0SafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0SafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelv0SafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelv0SafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelv0SafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelv0SafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelv0SafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithBadNamespaceFormatDispatcherCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatDispatcherDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithBadNamespaceFormatDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithBadNamespaceFormatDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithBadNamespaceFormatDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithBadNamespaceFormatDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithBadNamespaceFormatDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithBadNamespaceFormatDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithBadNamespaceFormatDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithBadNamespaceFormatDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithBadNamespaceFormatDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithBadNamespaceFormatDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithBadNamespaceFormatDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithBadNamespaceFormatLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithBadNamespaceFormatLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithBadNamespaceFormatLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithBadNamespaceFormatLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithBadNamespaceFormatLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithBadNamespaceFormatLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithBadNamespaceFormatLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithBadNamespaceFormatLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithBadNamespaceFormatSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithBadNamespaceFormatSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithBadNamespaceFormatSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithBadNamespaceFormatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithBadNamespaceFormatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithBadNamespaceFormatSafeDispatcherCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeDispatcherDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithBadNamespaceFormatSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithBadNamespaceFormatSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithBadNamespaceFormatSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithBadNamespaceFormatSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithBadNamespaceFormatSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithBadNamespaceFormatSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithBadNamespaceFormatSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithBadNamespaceFormatSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithBadNamespaceFormatSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithBadNamespaceFormatSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithBadNamespaceFormatSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithBadNamespaceFormatSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithShortStringNamespaceDispatcherCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceDispatcherDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithShortStringNamespaceDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithShortStringNamespaceDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithShortStringNamespaceDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithShortStringNamespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithShortStringNamespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithShortStringNamespaceDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithShortStringNamespaceDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithShortStringNamespaceDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithShortStringNamespaceDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithShortStringNamespaceDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithShortStringNamespaceDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithShortStringNamespaceLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithShortStringNamespaceLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithShortStringNamespaceLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithShortStringNamespaceLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithShortStringNamespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithShortStringNamespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithShortStringNamespaceLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithShortStringNamespaceLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithShortStringNamespaceLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithShortStringNamespaceLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithShortStringNamespaceSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithShortStringNamespaceSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithShortStringNamespaceSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithShortStringNamespaceSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithShortStringNamespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithShortStringNamespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithShortStringNamespaceSafeDispatcherCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeDispatcherDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithShortStringNamespaceSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithShortStringNamespaceSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithShortStringNamespaceSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithShortStringNamespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithShortStringNamespaceSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithShortStringNamespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithShortStringNamespaceSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithShortStringNamespaceSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithShortStringNamespaceSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithShortStringNamespaceSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithShortStringNamespaceSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithShortStringNamespaceSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithStringNamespaceDispatcherCopy of core::traits::Copy::; +impl IModelWithStringNamespaceDispatcherDrop of core::traits::Drop::; +impl IModelWithStringNamespaceDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithStringNamespaceDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithStringNamespaceDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithStringNamespaceDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithStringNamespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithStringNamespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithStringNamespaceDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithStringNamespaceDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithStringNamespaceDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithStringNamespaceDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithStringNamespaceDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithStringNamespaceDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithStringNamespaceLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithStringNamespaceLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithStringNamespaceLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithStringNamespaceLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithStringNamespaceLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithStringNamespaceLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithStringNamespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithStringNamespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithStringNamespaceLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithStringNamespaceLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithStringNamespaceLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithStringNamespaceLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithStringNamespaceLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithStringNamespaceLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithStringNamespaceSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithStringNamespaceSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithStringNamespaceSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithStringNamespaceSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithStringNamespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithStringNamespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithStringNamespaceSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithStringNamespaceSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithStringNamespaceSafeDispatcherCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeDispatcherDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithStringNamespaceSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithStringNamespaceSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithStringNamespaceSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithStringNamespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithStringNamespaceSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithStringNamespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithStringNamespaceSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithStringNamespaceSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithStringNamespaceSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithStringNamespaceSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithStringNamespaceSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithStringNamespaceSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithStringNamespaceSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithStringNamespaceSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IPositionDispatcherCopy of core::traits::Copy::; +impl IPositionDispatcherDrop of core::traits::Drop::; +impl IPositionDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPositionDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPositionDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPositionDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPositionDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPositionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPositionDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPositionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPositionDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IPositionDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPositionDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPositionDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPositionDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IPositionDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPositionDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPositionDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IPositionLibraryDispatcherCopy of core::traits::Copy::; +impl IPositionLibraryDispatcherDrop of core::traits::Drop::; +impl IPositionLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPositionLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPositionLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPositionLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPositionLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPositionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPositionLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPositionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPositionLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IPositionLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPositionLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPositionLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPositionLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IPositionLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPositionLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPositionLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IPositionSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IPositionSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IPositionSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPositionSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPositionSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPositionSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPositionSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPositionSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPositionSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IPositionSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPositionSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPositionSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPositionSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IPositionSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPositionSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPositionSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IPositionSafeDispatcherCopy of core::traits::Copy::; +impl IPositionSafeDispatcherDrop of core::traits::Drop::; +impl IPositionSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPositionSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPositionSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPositionSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPositionSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPositionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPositionSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPositionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPositionSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IPositionSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPositionSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPositionSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPositionSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IPositionSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPositionSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPositionSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPositionSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IPlayerDispatcherCopy of core::traits::Copy::; +impl IPlayerDispatcherDrop of core::traits::Drop::; +impl IPlayerDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPlayerDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPlayerDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPlayerDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPlayerDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPlayerDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPlayerDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPlayerDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPlayerDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IPlayerDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPlayerDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPlayerDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPlayerDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IPlayerDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPlayerDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPlayerDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IPlayerLibraryDispatcherCopy of core::traits::Copy::; +impl IPlayerLibraryDispatcherDrop of core::traits::Drop::; +impl IPlayerLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPlayerLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPlayerLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPlayerLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPlayerLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPlayerLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPlayerLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPlayerLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPlayerLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IPlayerLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPlayerLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPlayerLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPlayerLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IPlayerLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPlayerLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPlayerLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IPlayerSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IPlayerSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IPlayerSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPlayerSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPlayerSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPlayerSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPlayerSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPlayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPlayerSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPlayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPlayerSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IPlayerSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPlayerSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPlayerSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPlayerSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IPlayerSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPlayerSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPlayerSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IPlayerSafeDispatcherCopy of core::traits::Copy::; +impl IPlayerSafeDispatcherDrop of core::traits::Drop::; +impl IPlayerSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IPlayerSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IPlayerSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIPlayerSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IPlayerSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IPlayerSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IPlayerSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IPlayerSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IPlayerSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IPlayerSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IPlayerSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IPlayerSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IPlayerSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IPlayerSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IPlayerSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IPlayerSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IPlayerSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithSimpleArrayDispatcherCopy of core::traits::Copy::; +impl IModelWithSimpleArrayDispatcherDrop of core::traits::Drop::; +impl IModelWithSimpleArrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithSimpleArrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithSimpleArrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithSimpleArrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithSimpleArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithSimpleArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArrayDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithSimpleArrayDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithSimpleArrayDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithSimpleArrayDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArrayDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArrayDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithSimpleArrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithSimpleArrayDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithSimpleArrayDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArrayDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithSimpleArrayLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithSimpleArrayLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithSimpleArrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithSimpleArrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithSimpleArrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithSimpleArrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithSimpleArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithSimpleArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArrayLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithSimpleArrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithSimpleArrayLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithSimpleArrayLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArrayLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArrayLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithSimpleArrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithSimpleArrayLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithSimpleArrayLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArrayLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithSimpleArraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithSimpleArraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithSimpleArraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithSimpleArraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithSimpleArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithSimpleArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArraySafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithSimpleArraySafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithSimpleArraySafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArraySafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArraySafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithSimpleArraySafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithSimpleArraySafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArraySafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithSimpleArraySafeDispatcherCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeDispatcherDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithSimpleArraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithSimpleArraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithSimpleArraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithSimpleArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithSimpleArraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithSimpleArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArraySafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithSimpleArraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithSimpleArraySafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithSimpleArraySafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArraySafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithSimpleArraySafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithSimpleArraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithSimpleArraySafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithSimpleArraySafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithSimpleArraySafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithByteArrayDispatcherCopy of core::traits::Copy::; +impl IModelWithByteArrayDispatcherDrop of core::traits::Drop::; +impl IModelWithByteArrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithByteArrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithByteArrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithByteArrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithByteArrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithByteArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithByteArrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithByteArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithByteArrayDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithByteArrayDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithByteArrayDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithByteArrayDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArrayDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithByteArrayDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithByteArrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithByteArrayDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithByteArrayDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArrayDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithByteArrayLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithByteArrayLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithByteArrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithByteArrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithByteArrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithByteArrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithByteArrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithByteArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithByteArrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithByteArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithByteArrayLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithByteArrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithByteArrayLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithByteArrayLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArrayLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithByteArrayLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithByteArrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithByteArrayLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithByteArrayLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArrayLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithByteArraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithByteArraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithByteArraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithByteArraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithByteArraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithByteArraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithByteArraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithByteArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithByteArraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithByteArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithByteArraySafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithByteArraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithByteArraySafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithByteArraySafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArraySafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithByteArraySafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithByteArraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithByteArraySafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithByteArraySafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArraySafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithByteArraySafeDispatcherCopy of core::traits::Copy::; +impl IModelWithByteArraySafeDispatcherDrop of core::traits::Drop::; +impl IModelWithByteArraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithByteArraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithByteArraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithByteArraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithByteArraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithByteArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithByteArraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithByteArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithByteArraySafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithByteArraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithByteArraySafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithByteArraySafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArraySafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithByteArraySafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithByteArraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithByteArraySafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithByteArraySafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithByteArraySafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithComplexArrayDispatcherCopy of core::traits::Copy::; +impl IModelWithComplexArrayDispatcherDrop of core::traits::Drop::; +impl IModelWithComplexArrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithComplexArrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithComplexArrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithComplexArrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithComplexArrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithComplexArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithComplexArrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithComplexArrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithComplexArrayDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithComplexArrayDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithComplexArrayDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithComplexArrayDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArrayDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithComplexArrayDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithComplexArrayDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithComplexArrayDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithComplexArrayDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArrayDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithComplexArrayLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithComplexArrayLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithComplexArrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithComplexArrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithComplexArrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithComplexArrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithComplexArrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithComplexArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithComplexArrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithComplexArrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithComplexArrayLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithComplexArrayLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithComplexArrayLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithComplexArrayLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArrayLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithComplexArrayLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithComplexArrayLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithComplexArrayLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithComplexArrayLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArrayLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithComplexArraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithComplexArraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithComplexArraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithComplexArraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithComplexArraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithComplexArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithComplexArraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithComplexArraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithComplexArraySafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithComplexArraySafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithComplexArraySafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArraySafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithComplexArraySafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithComplexArraySafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithComplexArraySafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArraySafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithComplexArraySafeDispatcherCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeDispatcherDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithComplexArraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithComplexArraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithComplexArraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithComplexArraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithComplexArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithComplexArraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithComplexArraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithComplexArraySafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithComplexArraySafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithComplexArraySafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithComplexArraySafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArraySafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithComplexArraySafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithComplexArraySafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithComplexArraySafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithComplexArraySafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithComplexArraySafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithTupleDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithTupleDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithTupleDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithTupleLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithTupleLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithTupleLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithTupleSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithTupleSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithTupleSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithTupleSafeDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleSafeDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithTupleSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithTupleSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithTupleNoPrimitivesDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleNoPrimitivesDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleNoPrimitivesDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleNoPrimitivesDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleNoPrimitivesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleNoPrimitivesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithTupleNoPrimitivesDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleNoPrimitivesDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleNoPrimitivesDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithTupleNoPrimitivesDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleNoPrimitivesDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleNoPrimitivesDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelWithTupleNoPrimitivesLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleNoPrimitivesLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleNoPrimitivesLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleNoPrimitivesLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleNoPrimitivesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleNoPrimitivesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleNoPrimitivesLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleNoPrimitivesLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleNoPrimitivesSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleNoPrimitivesSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleNoPrimitivesSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleNoPrimitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleNoPrimitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IModelWithTupleNoPrimitivesSafeDispatcherCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeDispatcherDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IModelWithTupleNoPrimitivesSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IModelWithTupleNoPrimitivesSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIModelWithTupleNoPrimitivesSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IModelWithTupleNoPrimitivesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IModelWithTupleNoPrimitivesSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IModelWithTupleNoPrimitivesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IModelWithTupleNoPrimitivesSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IModelWithTupleNoPrimitivesSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IModelv0DispatcherSubPointersDrop of core::traits::Drop::; +impl IModelv0DispatcherSubPointersCopy of core::traits::Copy::; +impl IModelv0DispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelv0DispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelv0LibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelv0LibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelv0LibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelv0LibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelv0SafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelv0SafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelv0SafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelv0SafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelv0SafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelv0SafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelv0SafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelv0SafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithBadNamespaceFormatSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithShortStringNamespaceSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithStringNamespaceDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithStringNamespaceDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithStringNamespaceDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithStringNamespaceDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithStringNamespaceLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithStringNamespaceLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithStringNamespaceLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithStringNamespaceLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithStringNamespaceSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithStringNamespaceSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPositionDispatcherSubPointersDrop of core::traits::Drop::; +impl IPositionDispatcherSubPointersCopy of core::traits::Copy::; +impl IPositionDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPositionDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPositionLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IPositionLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IPositionLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPositionLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPositionSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IPositionSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IPositionSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPositionSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPositionSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IPositionSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IPositionSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPositionSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPlayerDispatcherSubPointersDrop of core::traits::Drop::; +impl IPlayerDispatcherSubPointersCopy of core::traits::Copy::; +impl IPlayerDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPlayerDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPlayerLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IPlayerLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IPlayerLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPlayerLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPlayerSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IPlayerSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IPlayerSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPlayerSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IPlayerSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IPlayerSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IPlayerSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IPlayerSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithSimpleArrayDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithSimpleArrayDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithSimpleArrayDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithSimpleArrayDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithSimpleArrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithSimpleArrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithSimpleArrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithSimpleArrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithSimpleArraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithSimpleArraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithByteArrayDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithByteArrayDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithByteArrayDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithByteArrayDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithByteArrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithByteArrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithByteArrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithByteArrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithByteArraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithByteArraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithByteArraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithByteArraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithByteArraySafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithByteArraySafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithByteArraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithByteArraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithComplexArrayDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithComplexArrayDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithComplexArrayDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithComplexArrayDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithComplexArrayLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithComplexArrayLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithComplexArrayLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithComplexArrayLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithComplexArraySafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithComplexArraySafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IModelWithTupleNoPrimitivesSafeDispatcherSubPointersMutCopy of core::traits::Copy::; + +//! > expected_diagnostics +error: Too many 'version' attributes for dojo::model + --> /tmp/plugin_test/model/src/lib.cairo:9:1 +#[dojo::model(version: 0, version: 0)] +^************************************^ + +error: The argument 'version' of dojo::model must be an integer + --> /tmp/plugin_test/model/src/lib.cairo:16:24 +#[dojo::model(version: hello)] + ^***^ + +error: Unexpected argument 'version' for dojo::model + --> /tmp/plugin_test/model/src/lib.cairo:23:15 +#[dojo::model(version)] + ^*****^ + +error: Unexpected argument 'my_arg' for dojo::model + --> /tmp/plugin_test/model/src/lib.cairo:30:15 +#[dojo::model(my_arg: 1)] + ^*******^ + +error: Unexpected argument 'my_arg' for dojo::model + --> /tmp/plugin_test/model/src/lib.cairo:37:15 +#[dojo::model(my_arg)] + ^****^ + +error: dojo::model version 2 not supported + --> /tmp/plugin_test/model/src/lib.cairo:44:24 +#[dojo::model(version: 2)] + ^ + +error: Model must define at least one #[key] attribute + --> /tmp/plugin_test/model/src/lib.cairo:87:8 +struct Roles { + ^***^ + +error: Model must define at least one member that is not a key + --> /tmp/plugin_test/model/src/lib.cairo:92:8 +struct OnlyKeyModel { + ^**********^ + +error: Key is only supported for core types that are 1 felt long once serialized. `u256` is a struct of 2 u128, hence not supported. + --> /tmp/plugin_test/model/src/lib.cairo:100:5 + id: u256 + ^^ + +error: Model must define at least one #[key] attribute + --> /tmp/plugin_test/model/src/lib.cairo:98:8 +struct U256KeyModel { + ^**********^ + +error: Model must define at least one member that is not a key + --> /tmp/plugin_test/model/src/lib.cairo:98:8 +struct U256KeyModel { + ^**********^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:51:1 +#[dojo::model(version: 0)] +^************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:51:1 +#[dojo::model(version: 0)] +^************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:58:1 +#[dojo::model(namespace: 'MyNamespace')] +^**************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:58:1 +#[dojo::model(namespace: 'MyNamespace')] +^**************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:79:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:79:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:103:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:103:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:115:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:115:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:123:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:123:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:131:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:131:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:139:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:139:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:147:1 +#[dojo::model] +^************^ + +error: Expected args. + --> /tmp/plugin_test/model/src/lib.cairo:147:1 +#[dojo::model] +^************^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo/lang/src/plugin_test_data/print similarity index 100% rename from crates/dojo-lang/src/plugin_test_data/print rename to crates/dojo/lang/src/plugin_test_data/print diff --git a/crates/dojo/lang/src/plugin_test_data/system b/crates/dojo/lang/src/plugin_test_data/system new file mode 100644 index 0000000000..004fbe5dc7 --- /dev/null +++ b/crates/dojo/lang/src/plugin_test_data/system @@ -0,0 +1,7220 @@ +//! > Test expansion of the #[system]. + +//! > test_runner_name +test_expand_plugin + +//! > test_id +system + +//! > cairo_code +#[dojo::contract(namespace: "My@Namespace")] +mod bad_namespace_format { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } +} + +#[dojo::contract(namespace: 'my_namespace')] +mod spawn { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } +} + +#[dojo::contract(namespace: "my_namespace")] +mod proxy { + fn execute(value: felt252) -> felt252 { + value + } +} + +#[dojo::contract] +mod ctxnamed { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx2: Context, name: felt252) { + return (); + } +} + +#[dojo::contract] +mod withevent { + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + TestEvent: TestEvent, + } + + #[derive(Drop, starknet::Event)] + struct TestEvent { + address: ContractAddress, + } +} + +#[starknet::component] +mod testcomponent1 { + #[storage] + struct Storage {} +} + +#[starknet::component] +mod testcomponent2 { + #[storage] + struct Storage {} +} + +#[dojo::contract] +mod withcomponent { + component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); + component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); + + #[storage] + struct Storage { + #[substorage(v0)] + testcomponent1_storage: testcomponent1::Storage, + #[substorage(v0)] + testcomponent2_storage: testcomponent2::Storage, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + testcomponent1_event: testcomponent1::Event, + testcomponent2_event: testcomponent2::Event, + } +} +#[dojo::interface] +trait IEmptyTrait; + +#[dojo::interface] +trait IFaultyTrait { + const ONE: u8; + + #[my_attr] + fn do_with_attrs(p1: u8) -> u16; +} + +#[dojo::interface] +trait INominalTrait { + fn do_no_param() -> felt252; + fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252; + fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252; + fn do_params_no_world(p1: felt252, p2: u8) -> felt252; + fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252; + fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252; + + fn do_with_self(self: @ContractState) -> felt252; + fn do_with_ref_self(ref self: ContractState) -> felt252; +} + +#[dojo::interface] +trait IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; + fn do_with_ref_self_and_world_inv( + ref world: IWorldDispatcher, ref self: ContractState + ) -> felt252; + fn do_with_several_world_dispatchers( + world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher + ) -> felt252; + fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252; + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; +} + +#[dojo::contract] +mod MyFaultyContract { + #[abi(embed_v0)] + impl TestFaultyImpl of IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_with_ref_self_and_world( + ref self: ContractState, ref world: IWorldDispatcher + ) -> felt252 { + 'land' + } + + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { + 'land' + } + + fn do_with_ref_self_and_world_inv( + ref world: IWorldDispatcher, ref self: ContractState + ) -> felt252 { + 'land' + } + + fn do_with_several_world_dispatchers( + world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher + ) -> felt252 { + 'land' + } + + fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { + 'land' + } + } + + #[generate_trait] + impl InternalImplBad of InternalUtils { + fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { + 'land' + } + } +} + +#[dojo::contract] +mod MyNominalContract { + #[derive(Drop)] + struct Action { + damage: u8 + } + + #[abi(embed_v0)] + impl TestNominalImpl of INominalTrait { + fn do_no_param() -> felt252 { + 'land' + } + + fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_params_no_world(p1: felt252, p2: u8) -> felt252 { + 'land' + } + + fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252 { + 'land' + } + + fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252 { + 'land' + } + + fn do_with_self(self: @ContractState) -> felt252 { + 'land' + } + + fn do_with_ref_self(ref self: ContractState) -> felt252 { + 'land' + } + } + + #[generate_trait] + impl ImplInternalNoContractState of InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252 { + let _w = world; + 42 + } + } +} + +#[dojo::contract] +mod constructor_test { + #[constructor] + fn constructor(ref self: ContractState, _value: u8) {} +} + +#[dojo::contract] +mod no_init_test {} + +//! > generated_cairo_code +#[starknet::contract] +mod spawn { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[abi(embed_v0)] + fn name(self: @ContractState) -> felt252 { + 'spawn' + } + + #[abi(embed_v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + use traits::Into; + use dojo::world::Context; + + #[abi(embed_v0)] + fn execute(self: @ContractState, ctx: Context, name: felt252) { + return (); + } +} + + +#[starknet::contract] +mod proxy { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[abi(embed_v0)] + fn name(self: @ContractState) -> felt252 { + 'proxy' + } + + #[abi(embed_v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + + #[abi(embed_v0)] + fn execute(self: @ContractState, value: felt252) -> felt252 { + value + } +} + + +#[starknet::contract] +mod ctxnamed { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[abi(embed_v0)] + fn name(self: @ContractState) -> felt252 { + 'ctxnamed' + } + + #[abi(embed_v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + use traits::Into; + use dojo::world::Context; + + #[abi(embed_v0)] + fn execute(self: @ContractState, ctx2: Context, name: felt252) { + return (); + } +} + +//! > expected_diagnostics +error: The contract namespace 'My@Namespace' can only contain characters (a-z/A-Z), digits (0-9) and underscore (_). + --> /tmp/plugin_test/system/src/lib.cairo:1:1 +#[dojo::contract(namespace: "My@Namespace")] +^******************************************^ + +error: Anything other than functions is not supported in a dojo::interface + --> /tmp/plugin_test/system/src/lib.cairo:90:5 + const ONE: u8; + ^************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:111:5 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + ^***********************************************************************************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^*********************************************************************************************^ + +error: You cannot use `self` and `world` parameters together. + --> /tmp/plugin_test/system/src/lib.cairo:113:5 + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; + ^***************************************************************************************^ + +error: You cannot use `self` and `world` parameters together. + --> /tmp/plugin_test/system/src/lib.cairo:114:5 + fn do_with_ref_self_and_world_inv( + ^********************************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:121:5 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; + ^****************************************************************************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:128:9 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { + ^************************************************************************************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:132:9 + fn do_with_ref_self_and_world( + ^****************************^ + +error: You cannot use `self` and `world` parameters together. + --> /tmp/plugin_test/system/src/lib.cairo:138:9 + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { + ^****************************************************************************************^ + +error: You cannot use `self` and `world` parameters together. + --> /tmp/plugin_test/system/src/lib.cairo:142:9 + fn do_with_ref_self_and_world_inv( + ^********************************^ + +error: World parameter must be the first parameter. + --> /tmp/plugin_test/system/src/lib.cairo:158:9 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { + ^*****************************************************************************^ + +error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. + --> /tmp/plugin_test/system/src/lib.cairo:165:9 + fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { + ^***************************************************************^ + +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /tmp/plugin_test/system/src/lib.cairo:105:5 + fn do_with_self(self: @ContractState) -> felt252; + ^**********************************************^ + +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /tmp/plugin_test/system/src/lib.cairo:106:5 + fn do_with_ref_self(ref self: ContractState) -> felt252; + ^*****************************************************^ + +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /tmp/plugin_test/system/src/lib.cairo:111:5 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + ^**********************************************************************************^ + +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /tmp/plugin_test/system/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^********************************************************************************************^ + +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /tmp/plugin_test/system/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^********************************************************************************************^ + +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /tmp/plugin_test/system/src/lib.cairo:114:5 + fn do_with_ref_self_and_world_inv( + ^********************************^ + +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /tmp/plugin_test/system/src/lib.cairo:117:5 + fn do_with_several_world_dispatchers( + ^***********************************^ + +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /tmp/plugin_test/system/src/lib.cairo:121:5 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; + ^***************************************************************************^ + +error: Generated trait must have generic args matching the impl's generic params. + --> /tmp/plugin_test/system/src/lib.cairo:163:5 + #[generate_trait] + ^***************^ + +//! > expanded_cairo_code +#[dojo::contract(namespace: "My@Namespace")] +mod bad_namespace_format { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } +} + +#[starknet::component] +mod testcomponent1 { +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ComponentState { +} + +impl ComponentStateDrop of Drop> {} + +impl ComponentStateDeref of core::ops::SnapshotDeref> { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ComponentState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ComponentStateDerefMut of core::ops::DerefMut> { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ComponentState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_component_state() -> ComponentState { + ComponentState:: { + } +} + + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; +pub trait HasComponent { + fn get_component(self: @TContractState) -> @ComponentState; + fn get_component_mut(ref self: TContractState) -> ComponentState; + fn get_contract(self: @ComponentState) -> @TContractState; + fn get_contract_mut(ref self: ComponentState) -> TContractState; + fn emit>(ref self: ComponentState, event: S); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} + +#[starknet::component] +mod testcomponent2 { +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +#[phantom] +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + StorageStorageBase { + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + StorageStorageBaseMut { + } + } +} + +pub struct ComponentState { +} + +impl ComponentStateDrop of Drop> {} + +impl ComponentStateDeref of core::ops::SnapshotDeref> { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ComponentState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ComponentStateDerefMut of core::ops::DerefMut> { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ComponentState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_component_state() -> ComponentState { + ComponentState:: { + } +} + + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; +pub trait HasComponent { + fn get_component(self: @TContractState) -> @ComponentState; + fn get_component_mut(ref self: TContractState) -> ComponentState; + fn get_contract(self: @ComponentState) -> @TContractState; + fn get_contract_mut(ref self: ComponentState) -> TContractState; + fn emit>(ref self: ComponentState, event: S); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +} +#[starknet::contract] +pub mod spawn { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "spawn" + } + + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn tag(self: @ContractState) -> ByteArray { + "my_namespace-spawn" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2776321589048333240377325502911505147617911439383944762363370901236132332849 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + fn selector(self: @ContractState) -> felt252 { + 927765609926166707747357189894656840364326580388522007560729768978560453318 + } + } + + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod proxy { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "proxy" + } + + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn tag(self: @ContractState) -> ByteArray { + "my_namespace-proxy" + } + + fn name_hash(self: @ContractState) -> felt252 { + 379211399603323842291430789821178524592027629543381998047225121027704003915 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + fn selector(self: @ContractState) -> felt252 { + 1517897915978631541665409557725081861100844369870047691780983681552158397188 + } + } + + fn execute(value: felt252) -> felt252 { + value + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod ctxnamed { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "ctxnamed" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-ctxnamed" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1120614286815912604239420768209466007446460277061516527925636408561239543041 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 1088922133313711214547564678240399488767278073212336739350382494993498982824 + } + } + + use traits::Into; + use dojo::world::Context; + + fn execute(ctx2: Context, name: felt252) { + return (); + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod withevent { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "withevent" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-withevent" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2196275886623691942883456540767114081898043897719876113518403014973431884540 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 3549898308100844368972151697544420289462059777504886668025232769583717017648 + } + } + + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + TestEvent: TestEvent + } + + #[derive(Drop, starknet::Event)] + struct TestEvent { + address: ContractAddress, + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::TestEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + if __selector__ == selector!("TestEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::TestEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} +impl EventTestEventIntoEvent of Into { + fn into(self: TestEvent) -> Event { + Event::TestEvent(self) + } +} +impl TestEventDrop of core::traits::Drop::; +impl TestEventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @TestEvent, ref keys: Array, ref data: Array + ) { + core::serde::Serde::serialize(self.address, ref data); + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let address = core::serde::Serde::deserialize( + ref data + )?; + Option::Some(TestEvent {address, }) + } +} + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod withcomponent { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "withcomponent" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-withcomponent" + } + + fn name_hash(self: @ContractState) -> felt252 { + 999850881662666048155666650426666132968026605763740651763663703103974774091 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 3051237314154062498758064027519150695325862034415997374893619833554034627226 + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + #[flat] + testcomponent1_event: testcomponent1::Event, + testcomponent2_event: testcomponent2::Event + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, + #[substorage(v0)] + pub testcomponent1_storage: testcomponent1::Storage, + #[substorage(v0)] + pub testcomponent2_storage: testcomponent2::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, + pub testcomponent1_storage: starknet::storage::FlattenedStorage, + pub testcomponent2_storage: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + let __testcomponent1_storage_value__ = starknet::storage::FlattenedStorage {}; + let __testcomponent2_storage_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + testcomponent1_storage: __testcomponent1_storage_value__, + testcomponent2_storage: __testcomponent2_storage_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, + pub testcomponent1_storage: starknet::storage::FlattenedStorage>, + pub testcomponent2_storage: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + let __testcomponent1_storage_value__ = starknet::storage::FlattenedStorage {}; + let __testcomponent2_storage_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + testcomponent1_storage: __testcomponent1_storage_value__, + testcomponent2_storage: __testcomponent2_storage_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, + pub testcomponent1_storage: testcomponent1::ComponentState, + pub testcomponent2_storage: testcomponent2::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), + testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { + @testcomponent1::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { + testcomponent1::unsafe_new_component_state::() + } + fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: testcomponent1::ComponentState, event: S) { + let event: testcomponent1::Event = core::traits::Into::into(event); + let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); + } +} +impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { + @testcomponent2::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { + testcomponent2::unsafe_new_component_state::() + } + fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: testcomponent2::ComponentState, event: S) { + let event: testcomponent2::Event = core::traits::Into::into(event); + let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); + } +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent1_event(val) => { + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent2_event(val) => { + core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + { + let mut keys = keys; + let mut data = data; + match starknet::Event::deserialize(ref keys, ref data) { + Option::Some(val) => { + return Option::Some(Event::testcomponent1_event(val)); + }, + Option::None => {}, + }; + } + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + if __selector__ == selector!("testcomponent2_event") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::testcomponent2_event(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} +impl Eventtestcomponent1_eventIntoEvent of Into { + fn into(self: testcomponent1::Event) -> Event { + Event::testcomponent1_event(self) + } +} +impl Eventtestcomponent2_eventIntoEvent of Into { + fn into(self: testcomponent2::Event) -> Event { + Event::testcomponent2_event(self) + } +} + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} + + #[starknet::interface] + pub trait IEmptyTrait {} + + #[starknet::interface] + pub trait IFaultyTrait { + fn do_with_attrs(self: @TContractState, p1: u8) -> u16; + } + + #[starknet::interface] + pub trait INominalTrait { + fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; + } + + #[starknet::interface] + pub trait IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState +) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher +) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; + } +#[starknet::contract] +pub mod MyFaultyContract { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "MyFaultyContract" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-MyFaultyContract" + } + + fn name_hash(self: @ContractState) -> felt252 { + 3439743807865759203015037013733809315384408083697880336790137144257764256358 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 3304414327641815709216225681190245445308480446755012097234787467696641395890 + } + } + + #[abi(embed_v0)] + impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' +}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' +}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState +) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher +) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' +}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' +}} + #[generate_trait] + impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_provider.world(); 'land' +}} + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; +} + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_self = core::option::OptionTraitImpl::expect( + core::serde::Serde::<@ContractState>::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let mut __arg_self = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); + let mut arr = ArrayTrait::new(); + // References. + core::serde::Serde::::serialize(@__arg_self, ref arr); + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_vec = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + let mut __arg_another_world = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #2' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); + let mut arr = ArrayTrait::new(); + // References. + core::serde::Serde::::serialize(@__arg_another_world, ref arr); + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_another_world = core::option::OptionTraitImpl::expect( + core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_vec = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod MyNominalContract { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "MyNominalContract" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-MyNominalContract" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1172628497499445169993220559087829230676589931723677494032285307738203070578 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 1466845198188516049094649763342542731381088471625065496527510975945391631525 + } + } + + #[derive(Drop)] + struct Action { + damage: u8 + } + + #[abi(embed_v0)] + impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' +}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' +}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_provider.world(); 'land' +}fn do_with_self(self: @ContractState) -> felt252 { 'land' +}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' +}} + #[generate_trait] + impl ImplInternalNoContractState of InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252 { + let _w = world; + 42 + } + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +impl ActionDrop of core::traits::Drop::; + trait InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252; + } + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p1 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #2' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_with_self(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; + pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; + pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; + pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; + pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; + pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; + pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; + pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod constructor_test { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "constructor_test" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-constructor_test" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1448040114967332260450680311232069198633143381246182440670306454820750021442 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 1847799915277474306008813139960743801242059631426321875100588125825381611082 + } + } + + + #[constructor] + fn constructor(ref self: ContractState, _value: u8) { + self.world_provider.initializer(); + } +#[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg__value = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, __arg__value); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} +#[starknet::contract] +pub mod no_init_test { + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "no_init_test" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-no_init_test" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2188407785440294979090510634648735461326850740369373015349552249835679156474 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 1612380646418854749267717900057829622040529970486094087524750323429009828706 + } + } + + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + #[abi(per_item)] +#[generate_trait] +pub impl IDojoInitImpl of IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } + pub trait IDojoInit { + #[external(v0)] + fn dojo_init(self: @ContractState); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let __upgradeable_value__ = starknet::storage::FlattenedStorage {}; + let __world_provider_value__ = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: __upgradeable_value__, + world_provider: __world_provider_value__, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +#[allow(unused_imports)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; + +} + pub trait IEmptyTraitDispatcherTrait { +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IEmptyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IEmptyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { + +} + + pub trait IEmptyTraitSafeDispatcherTrait { +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IEmptyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IEmptyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { + +} + pub trait IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: T, p1: u8) -> u16; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + + pub trait IFaultyTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + pub trait INominalTraitDispatcherTrait { + fn do_no_param(self: T) -> felt252; +fn do_no_param_but_world(self: T) -> felt252; +fn do_no_param_but_world_ref(self: T) -> felt252; +fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; +fn do_params_and_world(self: T, p2: u8) -> felt252; +fn do_params_and_world_ref(self: T, p2: u8) -> felt252; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct INominalTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { + fn do_no_param(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct INominalTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { + fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + + pub trait INominalTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn do_no_param(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_no_param_but_world(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct INominalTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { + fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct INominalTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { + fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + pub trait IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; +fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + + pub trait IFaultyTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] +fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] + pub struct IFaultyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} +impl IEmptyTraitDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IEmptyTraitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IEmptyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IEmptyTraitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IEmptyTraitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IEmptyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IEmptyTraitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IEmptyTraitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IEmptyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IEmptyTraitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IEmptyTraitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IEmptyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IEmptyTraitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IEmptyTraitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IEmptyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IEmptyTraitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IEmptyTraitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IEmptyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IEmptyTraitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IEmptyTraitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IEmptyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IEmptyTraitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IEmptyTraitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IEmptyTraitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IEmptyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IEmptyTraitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IEmptyTraitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IEmptyTraitSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IFaultyTraitDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IFaultyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IFaultyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IFaultyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IFaultyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IFaultyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IFaultyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IFaultyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl INominalTraitDispatcherCopy of core::traits::Copy::; +impl INominalTraitDispatcherDrop of core::traits::Drop::; +impl INominalTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct INominalTraitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl INominalTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = INominalTraitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct INominalTraitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl INominalTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = INominalTraitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; +impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; +impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct INominalTraitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl INominalTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = INominalTraitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct INominalTraitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl INominalTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = INominalTraitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct INominalTraitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl INominalTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = INominalTraitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct INominalTraitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl INominalTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = INominalTraitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; +impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; +impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct INominalTraitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl INominalTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = INominalTraitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> INominalTraitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct INominalTraitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl INominalTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = INominalTraitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> INominalTraitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + INominalTraitSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IFaultyTraitDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IFaultyTraitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IFaultyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IFaultyTraitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IFaultyTraitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IFaultyTraitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeLibraryDispatcherSubPointers { + class_hash: __class_hash_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __class_hash_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeLibraryDispatcherSubPointersMut { + class_hash: __class_hash_value__, + } + } +} +impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IFaultyTraitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IFaultyTraitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IFaultyTraitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeDispatcherSubPointers { + contract_address: __contract_address_value__, + } + } +} +#[derive(Drop, Copy)] +pub struct IFaultyTraitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IFaultyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IFaultyTraitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IFaultyTraitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let __contract_address_value__ = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IFaultyTraitSafeDispatcherSubPointersMut { + contract_address: __contract_address_value__, + } + } +} +impl IEmptyTraitDispatcherSubPointersDrop of core::traits::Drop::; +impl IEmptyTraitDispatcherSubPointersCopy of core::traits::Copy::; +impl IEmptyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IEmptyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IEmptyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IEmptyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IEmptyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IEmptyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IEmptyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IEmptyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IEmptyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IEmptyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IEmptyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IEmptyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IEmptyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IEmptyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl INominalTraitDispatcherSubPointersDrop of core::traits::Drop::; +impl INominalTraitDispatcherSubPointersCopy of core::traits::Copy::; +impl INominalTraitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl INominalTraitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl INominalTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl INominalTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl INominalTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl INominalTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl INominalTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl INominalTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl INominalTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl INominalTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl INominalTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl INominalTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl INominalTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl INominalTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; diff --git a/crates/dojo/lang/src/semantics/mod.rs b/crates/dojo/lang/src/semantics/mod.rs new file mode 100644 index 0000000000..4c120c8d6f --- /dev/null +++ b/crates/dojo/lang/src/semantics/mod.rs @@ -0,0 +1,7 @@ +// pub mod utils; + +// #[cfg(test)] +// pub mod test_utils; + +// #[cfg(test)] +// pub mod tests; diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo/lang/src/semantics/test_data/get similarity index 59% rename from crates/dojo-lang/src/semantics/test_data/get rename to crates/dojo/lang/src/semantics/test_data/get index e64ef5f6b4..fb404d8b4f 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo/lang/src/semantics/test_data/get @@ -130,87 +130,25 @@ Block( Let( StatementLet { pattern: Variable( - __get_macro_keys__, - ), - expr: FunctionCall( - ExprFunctionCall { - function: core::array::ArrayImpl::::new, - args: [], - coupon_arg: None, - ty: core::array::Array::, - }, - ), - }, - ), - Expr( - StatementExpr { - expr: FunctionCall( - ExprFunctionCall { - function: core::Felt252Serde::serialize, - args: [ - Value( - Snapshot( - ExprSnapshot { - inner: Var( - LocalVarId(test::key), - ), - ty: @core::felt252, - }, - ), - ), - Reference( - LocalVarId(test::__get_macro_keys__), - ), - ], - coupon_arg: None, - ty: (), - }, - ), - }, - ), - Let( - StatementLet { - pattern: Variable( - __get_macro_keys__, + __Health, ), expr: FunctionCall( ExprFunctionCall { - function: core::array::ArrayImpl::::span, + function: ?4::get::, args: [ Value( Snapshot( ExprSnapshot { inner: Var( - LocalVarId(test::__get_macro_keys__), + LocalVarId(test::world), ), - ty: @core::array::Array::, + ty: @dojo::world::iworld::IWorldDispatcher, }, ), ), - ], - coupon_arg: None, - ty: core::array::Span::, - }, - ), - }, - ), - Let( - StatementLet { - pattern: Variable( - __Health, - ), - expr: FunctionCall( - ExprFunctionCall { - function: ?7::get, - args: [ - Value( - Var( - LocalVarId(test::world), - ), - ), Value( Var( - LocalVarId(test::__get_macro_keys__), + LocalVarId(test::key), ), ), ], @@ -231,7 +169,7 @@ Block( ) //! > semantic_diagnostics -error: Trait has no implementation in context: dojo::model::model::Model::. +error: Trait has no implementation in context: dojo::model::model::ModelStore::. --> lib.cairo:12:1 get!(world, key, (Health)) ^************************^ diff --git a/crates/dojo-lang/src/semantics/test_data/get_models_test_class_hashes b/crates/dojo/lang/src/semantics/test_data/get_models_test_class_hashes similarity index 100% rename from crates/dojo-lang/src/semantics/test_data/get_models_test_class_hashes rename to crates/dojo/lang/src/semantics/test_data/get_models_test_class_hashes diff --git a/crates/dojo-lang/src/semantics/test_data/selector_from_tag b/crates/dojo/lang/src/semantics/test_data/selector_from_tag similarity index 100% rename from crates/dojo-lang/src/semantics/test_data/selector_from_tag rename to crates/dojo/lang/src/semantics/test_data/selector_from_tag diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo/lang/src/semantics/test_data/set similarity index 55% rename from crates/dojo-lang/src/semantics/test_data/set rename to crates/dojo/lang/src/semantics/test_data/set index ddbd0b8287..a6e9918296 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo/lang/src/semantics/test_data/set @@ -82,61 +82,51 @@ set!(world, (Health{id: 0xb0b, health: 79})) Block( ExprBlock { statements: [ - Let( - StatementLet { - pattern: Variable( - __set_model_instance__, - ), - expr: StructCtor( - ExprStructCtor { - concrete_struct_id: test::Health, - members: [ - ( - MemberId(test::id), - Literal( - ExprLiteral { - value: 2827, - ty: core::integer::u32, - }, - ), - ), - ( - MemberId(test::health), - Literal( - ExprLiteral { - value: 79, - ty: core::integer::u16, - }, - ), - ), - ], - base_struct: None, - ty: test::Health, - }, - ), - }, - ), Expr( StatementExpr { expr: FunctionCall( ExprFunctionCall { - function: ?6::set_model, + function: dojo::model::model::ModelStoreImpl::, test::HealthSerde>, test::HealthDrop>::set, args: [ + Value( + Var( + LocalVarId(test::world), + ), + ), Value( Snapshot( ExprSnapshot { - inner: Var( - LocalVarId(test::__set_model_instance__), + inner: StructCtor( + ExprStructCtor { + concrete_struct_id: test::Health, + members: [ + ( + MemberId(test::id), + Literal( + ExprLiteral { + value: 2827, + ty: core::integer::u32, + }, + ), + ), + ( + MemberId(test::health), + Literal( + ExprLiteral { + value: 79, + ty: core::integer::u16, + }, + ), + ), + ], + base_struct: None, + ty: test::Health, + }, ), ty: @test::Health, }, ), ), - Value( - Var( - LocalVarId(test::world), - ), - ), ], coupon_arg: None, ty: (), @@ -151,17 +141,7 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: The namespace '' can only contain characters (a-z/A-Z), digits (0-9) and underscore (_). - --> lib.cairo:5:8 -struct Health { - ^****^ - warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. --> lib.cairo:10:22 fn test_func() { let key: felt252 = 0xb0b; ^*^ - -error: Trait has no implementation in context: dojo::model::model::Model::. - --> lib.cairo:12:1 -set!(world, (Health{id: 0xb0b, health: 79})) -^******************************************^ diff --git a/crates/dojo-lang/src/semantics/test_data/spawn_test_world b/crates/dojo/lang/src/semantics/test_data/spawn_test_world similarity index 90% rename from crates/dojo-lang/src/semantics/test_data/spawn_test_world rename to crates/dojo/lang/src/semantics/test_data/spawn_test_world index 70149dc31c..f97089dfd8 100644 --- a/crates/dojo-lang/src/semantics/test_data/spawn_test_world +++ b/crates/dojo/lang/src/semantics/test_data/spawn_test_world @@ -14,7 +14,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Failed to load models and namespaces, ensure you have run `sozo build` first. +error: Plugin diagnostic: failed to load models and namespaces, ensure you have run `sozo build` first. --> lib.cairo:2:1 spawn_test_world!() ^*****************^ @@ -60,7 +60,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Failed to load models and namespaces, ensure you have run `sozo build` first. +error: Plugin diagnostic: failed to load models and namespaces, ensure you have run `sozo build` first. --> lib.cairo:2:1 spawn_test_world!(["ns1", "ns2"]) ^*******************************^ diff --git a/crates/dojo-lang/src/semantics/test_utils.rs b/crates/dojo/lang/src/semantics/test_utils.rs similarity index 93% rename from crates/dojo-lang/src/semantics/test_utils.rs rename to crates/dojo/lang/src/semantics/test_utils.rs index 77b14b975f..be667a30b2 100644 --- a/crates/dojo-lang/src/semantics/test_utils.rs +++ b/crates/dojo/lang/src/semantics/test_utils.rs @@ -2,12 +2,12 @@ use std::collections::BTreeMap; use std::path::PathBuf; use std::sync::{Arc, Mutex}; -use cairo_lang_defs::db::{DefsDatabase, DefsGroup}; +use cairo_lang_defs::db::{ext_as_virtual_impl, DefsDatabase, DefsGroup}; use cairo_lang_defs::ids::{FunctionWithBodyId, ModuleId}; use cairo_lang_diagnostics::{Diagnostics, DiagnosticsBuilder}; use cairo_lang_filesystem::db::{ - init_dev_corelib, init_files_group, AsFilesGroupMut, CrateConfiguration, FilesDatabase, - FilesGroup, FilesGroupEx, + init_dev_corelib, init_files_group, AsFilesGroupMut, CrateConfiguration, ExternalFiles, + FilesDatabase, FilesGroup, FilesGroupEx, }; use cairo_lang_filesystem::ids::{ CrateId, CrateLongId, Directory, FileKind, FileLongId, VirtualFile, @@ -22,9 +22,10 @@ use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup}; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use cairo_lang_utils::{extract_matches, OptionFrom, Upcast}; use camino::Utf8PathBuf; -use dojo_test_utils::compiler::corelib; use once_cell::sync::Lazy; +use scarb::compiler::Profile; +use crate::compiler::test_utils::{build_test_config, corelib}; use crate::plugin::dojo_plugin_suite; #[salsa::database(SemanticDatabase, DefsDatabase, ParserDatabase, SyntaxDatabase, FilesDatabase)] @@ -33,6 +34,11 @@ pub struct DojoSemanticDatabase { storage: salsa::Storage, } impl salsa::Database for DojoSemanticDatabase {} +impl ExternalFiles for DojoSemanticDatabase { + fn ext_as_virtual(&self, external_id: salsa::InternId) -> VirtualFile { + ext_as_virtual_impl(self.upcast(), external_id) + } +} impl salsa::ParallelDatabase for DojoSemanticDatabase { fn snapshot(&self) -> salsa::Snapshot { salsa::Snapshot::new(DojoSemanticDatabase { storage: self.storage.snapshot() }) @@ -52,16 +58,20 @@ impl DojoSemanticDatabase { db.set_inline_macro_plugins(suite.inline_macro_plugins.into()); db.set_analyzer_plugins(suite.analyzer_plugins); - let dojo_path = Utf8PathBuf::from_path_buf("../../crates/dojo-core/src".into()).unwrap(); + let dojo_path = Utf8PathBuf::from_path_buf("../../crates/contracts/src".into()).unwrap(); let dojo_path: PathBuf = dojo_path.canonicalize_utf8().unwrap().into(); + let dojo_scarb_manifest = dojo_path.parent().unwrap().join("Scarb.toml"); let core_crate = db.intern_crate(CrateLongId::Real("dojo".into())); let core_root_dir = Directory::Real(dojo_path); + // Use a config to detect the corelib. + let config = + build_test_config(dojo_scarb_manifest.to_str().unwrap(), Profile::DEV).unwrap(); + // Ensure the crate[0] is dojo, to enable parsing of the Scarb.toml. db.set_crate_config(core_crate, Some(CrateConfiguration::default_for_root(core_root_dir))); - init_dev_corelib(&mut db, corelib()); - + init_dev_corelib(&mut db, corelib(&config)); db } /// Snapshots the db for read only. diff --git a/crates/dojo-lang/src/semantics/tests.rs b/crates/dojo/lang/src/semantics/tests.rs similarity index 95% rename from crates/dojo-lang/src/semantics/tests.rs rename to crates/dojo/lang/src/semantics/tests.rs index 2e8fba8a44..e45bcf2040 100644 --- a/crates/dojo-lang/src/semantics/tests.rs +++ b/crates/dojo/lang/src/semantics/tests.rs @@ -7,11 +7,11 @@ use cairo_lang_test_utils::parse_test_file::TestRunnerResult; use cairo_lang_test_utils::test_file_test; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; -use crate::semantics::test_utils::DojoSemanticDatabase; +use super::test_utils::DojoSemanticDatabase; test_file_test!( dojo_semantics, - "src/semantics/test_data", + "src/plugin/semantics/test_data", { get: "get", diff --git a/crates/dojo-lang/src/semantics/utils.rs b/crates/dojo/lang/src/semantics/utils.rs similarity index 100% rename from crates/dojo-lang/src/semantics/utils.rs rename to crates/dojo/lang/src/semantics/utils.rs diff --git a/crates/dojo-lang/src/syntax/mod.rs b/crates/dojo/lang/src/syntax/mod.rs similarity index 100% rename from crates/dojo-lang/src/syntax/mod.rs rename to crates/dojo/lang/src/syntax/mod.rs diff --git a/crates/dojo-lang/src/syntax/self_param.rs b/crates/dojo/lang/src/syntax/self_param.rs similarity index 95% rename from crates/dojo-lang/src/syntax/self_param.rs rename to crates/dojo/lang/src/syntax/self_param.rs index aaf3593fac..a2eac93556 100644 --- a/crates/dojo-lang/src/syntax/self_param.rs +++ b/crates/dojo/lang/src/syntax/self_param.rs @@ -1,7 +1,7 @@ use cairo_lang_syntax::node::ast; use cairo_lang_syntax::node::db::SyntaxGroup; -use crate::syntax::utils as syntax_utils; +use super::utils as syntax_utils; pub const SELF_PARAM_NAME: &str = "self"; diff --git a/crates/dojo-lang/src/syntax/utils.rs b/crates/dojo/lang/src/syntax/utils.rs similarity index 71% rename from crates/dojo-lang/src/syntax/utils.rs rename to crates/dojo/lang/src/syntax/utils.rs index b4bf5298a1..d4c8fd2c53 100644 --- a/crates/dojo-lang/src/syntax/utils.rs +++ b/crates/dojo/lang/src/syntax/utils.rs @@ -1,3 +1,4 @@ +use cairo_lang_syntax::node::ast::OptionTypeClause; use cairo_lang_syntax::node::db::SyntaxGroup; use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; @@ -14,7 +15,12 @@ use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; pub fn get_parameter_info(db: &dyn SyntaxGroup, param: ast::Param) -> (String, String, String) { let name = param.name(db).text(db).trim().to_string(); let modifiers = param.modifiers(db).as_syntax_node().get_text(db).trim().to_string(); - let param_type = param.type_clause(db).ty(db).as_syntax_node().get_text(db).trim().to_string(); + + let param_type = if let OptionTypeClause::TypeClause(ty) = param.type_clause(db) { + ty.ty(db).as_syntax_node().get_text(db).trim().to_string() + } else { + "()".to_string() + }; (name, modifiers, param_type) } diff --git a/crates/dojo-lang/src/syntax/world_param.rs b/crates/dojo/lang/src/syntax/world_param.rs similarity index 100% rename from crates/dojo-lang/src/syntax/world_param.rs rename to crates/dojo/lang/src/syntax/world_param.rs diff --git a/crates/dojo-test-utils/Cargo.toml b/crates/dojo/test-utils/Cargo.toml similarity index 75% rename from crates/dojo-test-utils/Cargo.toml rename to crates/dojo/test-utils/Cargo.toml index 900ac99221..68f8d49c0c 100644 --- a/crates/dojo-test-utils/Cargo.toml +++ b/crates/dojo/test-utils/Cargo.toml @@ -10,13 +10,13 @@ anyhow.workspace = true assert_fs.workspace = true async-trait.workspace = true camino.workspace = true -dojo-lang = { path = "../dojo-lang" } -dojo-world = { path = "../dojo-world", features = [ "manifest", "migration" ] } +dojo-lang.workspace = true +dojo-world.workspace = true jsonrpsee = { workspace = true, features = [ "server" ] } -katana-core = { path = "../katana/core" } +katana-core = { workspace = true } katana-executor = { workspace = true, features = [ "blockifier" ] } katana-node.workspace = true -katana-primitives = { path = "../katana/primitives" } +katana-primitives = { workspace = true } scarb.workspace = true scarb-ui.workspace = true serde.workspace = true @@ -29,7 +29,7 @@ url.workspace = true [build-dependencies] assert_fs.workspace = true camino.workspace = true -dojo-lang = { path = "../dojo-lang" } +dojo-lang.workspace = true scarb.workspace = true scarb-ui.workspace = true diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo/test-utils/src/compiler.rs similarity index 85% rename from crates/dojo-test-utils/src/compiler.rs rename to crates/dojo/test-utils/src/compiler.rs index 53fa5269de..419359db2a 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo/test-utils/src/compiler.rs @@ -6,9 +6,7 @@ use std::{env, fs, io}; use assert_fs::TempDir; use camino::{Utf8Path, Utf8PathBuf}; -use dojo_lang::compiler::DojoCompiler; -use dojo_lang::plugin::CairoPluginRepository; -use dojo_lang::scarb_internal::{compile_workspace, CompileInfo}; +use scarb::compiler::plugin::CairoPluginRepository; use scarb::compiler::{CompilationUnit, CompilerRepository, Profile}; use scarb::core::{Config, TargetKind}; use scarb::ops; @@ -142,7 +140,7 @@ pub fn copy_build_project_temp( dojo_core_path: &str, do_build: bool, profile: Profile, -) -> (Utf8PathBuf, Config, Option) { +) -> (Utf8PathBuf, Config) { let source_project_dir = Utf8PathBuf::from(source_project_path).parent().unwrap().to_path_buf(); let temp_project_dir = Utf8PathBuf::from( @@ -166,25 +164,21 @@ pub fn copy_build_project_temp( let packages: Vec = ws.members().map(|p| p.id).collect(); - let compile_info = if do_build { - Some( - compile_workspace( - &config, - CompileOpts { - include_target_names: vec![], - include_target_kinds: vec![], - exclude_target_kinds: vec![TargetKind::TEST], - features: features_opts, - }, - packages, - ) - .unwrap(), + if do_build { + scarb::ops::compile( + packages, + CompileOpts { + include_target_names: vec![], + include_target_kinds: vec![], + exclude_target_kinds: vec![TargetKind::TEST], + features: features_opts, + }, + &ws, ) - } else { - None - }; + .unwrap(); + } - (temp_project_dir, config, compile_info) + (temp_project_dir, config) } /// Copies a project to a new location, excluding the manifests and target directories. @@ -202,6 +196,9 @@ pub fn copy_project_temp( fs::create_dir_all(destination_dir)?; } + let dojo_cairo_test_path = + Utf8PathBuf::from(dojo_core_path.to_string().replace("core", "core-cairo-test")); + for entry in fs::read_dir(source_dir)? { let entry = entry?; let path = entry.path(); @@ -251,6 +248,36 @@ pub fn copy_project_temp( fs::write(dest_path.to_path_buf(), table.to_string().as_bytes()) .expect("Failed to write to Scab.toml"); } + + let dojo_cairo_test = if table.contains_key("workspace") { + if table["workspace"].as_table().unwrap().contains_key("dev-dependencies") { + Some( + table["workspace"]["dev-dependencies"]["dojo_cairo_test"] + .as_table_mut() + .unwrap(), + ) + } else { + None + } + } else if table.contains_key("dev-dependencies") { + Some(table["dev-dependencies"]["dojo_cairo_test"].as_table_mut().unwrap()) + } else { + None + }; + + if let Some(dojo_cairo_test) = dojo_cairo_test { + if dojo_cairo_test.contains_key("path") { + dojo_cairo_test["path"] = Value::String( + fs::canonicalize(dojo_cairo_test_path.clone()) + .unwrap() + .to_string_lossy() + .to_string(), + ); + + fs::write(dest_path.to_path_buf(), table.to_string().as_bytes()) + .expect("Failed to write to Scab.toml"); + } + } } } } @@ -270,22 +297,22 @@ pub fn copy_project_temp( /// * `path` - The path to the Scarb.toml file to build the config for. /// * `profile` - The profile to use for the config. pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result { - let mut compilers = CompilerRepository::empty(); - compilers.add(Box::new(DojoCompiler::default())).unwrap(); + let compilers = CompilerRepository::empty(); - let cairo_plugins = CairoPluginRepository::default(); + let cairo_plugins = CairoPluginRepository::empty(); // If the cache_dir is not overriden, we can't run tests in parallel. let cache_dir = TempDir::new().unwrap(); let path = Utf8PathBuf::from_path_buf(path.into()).unwrap(); + println!("path: {:?}", path); Config::builder(path.canonicalize_utf8().unwrap()) .global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap())) .ui_verbosity(Verbosity::Verbose) .log_filter_directive(env::var_os("SCARB_LOG")) .compilers(compilers) .profile(profile) - .cairo_plugins(cairo_plugins.into()) + .cairo_plugins(cairo_plugins) .build() } @@ -352,7 +379,7 @@ mod tests { copy_project_temp( &Utf8PathBuf::from(&project_dir.to_string_lossy()), &Utf8PathBuf::from(&dest_dir.to_string_lossy()), - &Utf8PathBuf::from("../dojo-core"), + &Utf8PathBuf::from("../dojo/core"), &ignore_dirs, ) .unwrap(); diff --git a/crates/dojo-test-utils/src/lib.rs b/crates/dojo/test-utils/src/lib.rs similarity index 64% rename from crates/dojo-test-utils/src/lib.rs rename to crates/dojo/test-utils/src/lib.rs index 48fcaf5848..71363b0556 100644 --- a/crates/dojo-test-utils/src/lib.rs +++ b/crates/dojo/test-utils/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(unused_crate_dependencies)] +// #![warn(unused_crate_dependencies)] pub mod compiler; pub mod migration; diff --git a/crates/dojo/test-utils/src/migration.rs b/crates/dojo/test-utils/src/migration.rs new file mode 100644 index 0000000000..5037eda76f --- /dev/null +++ b/crates/dojo/test-utils/src/migration.rs @@ -0,0 +1,16 @@ +use camino::Utf8PathBuf; + +pub const SPAWN_AND_MOVE_TEST_DB_DIR: &str = "/tmp/spawn-and-move-db"; +pub const TYPES_TEST_DB_DIR: &str = "/tmp/types-test-db"; + +/// Copies the spawn and move test database to a temporary directory and returns the path to the +/// temporary directory. Must be used if the test is going to modify the database. +pub fn copy_spawn_and_move_db() -> Utf8PathBuf { + crate::compiler::copy_tmp_dir(&Utf8PathBuf::from(SPAWN_AND_MOVE_TEST_DB_DIR)) +} + +/// Copies the types test database to a temporary directory and returns the path to the temporary +/// directory. Must be used if the test is going to modify the database. +pub fn copy_types_test_db() -> Utf8PathBuf { + crate::compiler::copy_tmp_dir(&Utf8PathBuf::from(TYPES_TEST_DB_DIR)) +} diff --git a/crates/dojo-test-utils/src/rpc.rs b/crates/dojo/test-utils/src/rpc.rs similarity index 100% rename from crates/dojo-test-utils/src/rpc.rs rename to crates/dojo/test-utils/src/rpc.rs diff --git a/crates/dojo-test-utils/src/sequencer.rs b/crates/dojo/test-utils/src/sequencer.rs similarity index 100% rename from crates/dojo-test-utils/src/sequencer.rs rename to crates/dojo/test-utils/src/sequencer.rs diff --git a/crates/dojo-types/Cargo.toml b/crates/dojo/types/Cargo.toml similarity index 85% rename from crates/dojo-types/Cargo.toml rename to crates/dojo/types/Cargo.toml index 1a939f6abb..88d725071c 100644 --- a/crates/dojo-types/Cargo.toml +++ b/crates/dojo/types/Cargo.toml @@ -6,14 +6,17 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow.workspace = true cainome.workspace = true crypto-bigint.workspace = true hex.workspace = true itertools.workspace = true num-traits.workspace = true +regex.workspace = true serde.workspace = true serde_json.workspace = true starknet.workspace = true +starknet-crypto.workspace = true strum.workspace = true strum_macros.workspace = true thiserror.workspace = true diff --git a/crates/dojo-types/src/event.rs b/crates/dojo/types/src/event.rs similarity index 100% rename from crates/dojo-types/src/event.rs rename to crates/dojo/types/src/event.rs diff --git a/crates/dojo-types/src/lib.rs b/crates/dojo/types/src/lib.rs similarity index 97% rename from crates/dojo-types/src/lib.rs rename to crates/dojo/types/src/lib.rs index 3cd9ffa3d7..b06fe9f62b 100644 --- a/crates/dojo-types/src/lib.rs +++ b/crates/dojo/types/src/lib.rs @@ -5,6 +5,7 @@ use serde::Serialize; use starknet::core::types::Felt; pub mod event; +pub mod naming; pub mod packing; pub mod primitive; pub mod primitive_conversion; diff --git a/crates/dojo/types/src/naming.rs b/crates/dojo/types/src/naming.rs new file mode 100644 index 0000000000..9fd1c2f364 --- /dev/null +++ b/crates/dojo/types/src/naming.rs @@ -0,0 +1,178 @@ +use anyhow::{anyhow, Result}; +use cainome::cairo_serde::{ByteArray, CairoSerde}; +use regex::Regex; +use starknet::core::types::Felt; +use starknet_crypto::poseidon_hash_many; + +pub const CONTRACT_NAME_SEPARATOR: &str = "::"; +pub const TAG_SEPARATOR: char = '-'; +pub const SELECTOR_CHUNK_SIZE: usize = 8; + +pub fn capitalize(s: &str) -> String { + let mut c = s.chars(); + match c.next() { + None => String::new(), + Some(f) => f.to_uppercase().collect::() + c.as_str(), + } +} + +pub fn get_name_from_tag(tag: &str) -> String { + let parts: Vec<&str> = tag.split(TAG_SEPARATOR).collect(); + parts.last().unwrap().to_string() +} + +pub fn get_namespace_from_tag(tag: &str) -> String { + let parts: Vec<&str> = tag.split(TAG_SEPARATOR).collect(); + parts.first().unwrap().to_string() +} + +pub fn get_tag(namespace: &str, name: &str) -> String { + format!("{namespace}{TAG_SEPARATOR}{name}") +} + +pub fn is_valid_tag(tag: &str) -> bool { + let (namespace, name) = match split_tag(tag) { + Ok((nm, n)) => (nm, n), + Err(_) => return false, + }; + + is_name_valid(&namespace) && is_name_valid(&name) +} + +/// Check if the provided name follows the format rules for Dojo toolchain. +/// It's not yet enforced at the world level though. +pub fn is_name_valid(name: &str) -> bool { + Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(name) +} + +/// Get the namespace and the name of a world element from its tag. +pub fn split_tag(tag: &str) -> Result<(String, String)> { + let parts: Vec<&str> = tag.split(TAG_SEPARATOR).collect(); + match parts.len() { + 2 => Ok((parts[0].to_string(), parts[1].to_string())), + _ => Err(anyhow!( + "Unexpected tag. Expected format: {TAG_SEPARATOR} or " + )), + } +} + +pub fn get_filename_from_tag(tag: &str) -> String { + if [format!("dojo{TAG_SEPARATOR}world").as_str(), format!("dojo{TAG_SEPARATOR}base").as_str()] + .contains(&tag) + { + return tag.to_string(); + } + + let mut selector = format!("{:x}", compute_selector_from_tag(tag)); + selector.truncate(SELECTOR_CHUNK_SIZE); + + format!("{tag}{TAG_SEPARATOR}{selector}") +} + +pub fn get_tag_from_filename(filename: &str) -> Result { + let parts: Vec<&str> = filename.split(TAG_SEPARATOR).collect(); + if parts.len() != 3 { + return Err(anyhow!( + "Unexpected filename. Expected format: \ + {TAG_SEPARATOR}{TAG_SEPARATOR}" + )); + } + + Ok(format!("{}{TAG_SEPARATOR}{}", parts[0], parts[1])) +} + +pub fn compute_bytearray_hash(value: &str) -> Felt { + let ba = ByteArray::from_string(value).unwrap_or_else(|_| panic!("Invalid ByteArray: {value}")); + poseidon_hash_many(&ByteArray::cairo_serialize(&ba)) +} + +pub fn compute_selector_from_tag(tag: &str) -> Felt { + let (namespace, name) = + split_tag(tag).unwrap_or_else(|_| panic!("Invalid tag to split: {tag}")); + compute_selector_from_names(&namespace, &name) +} + +pub fn compute_selector_from_names(namespace: &str, name: &str) -> Felt { + compute_selector_from_hashes(compute_bytearray_hash(namespace), compute_bytearray_hash(name)) +} + +pub fn compute_selector_from_hashes(namespace_hash: Felt, model_hash: Felt) -> Felt { + poseidon_hash_many(&[namespace_hash, model_hash]) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_split_tag_success() { + assert_eq!( + split_tag("namespace-name").unwrap(), + ("namespace".to_string(), "name".to_string()) + ); + } + + #[test] + fn test_split_tag_invalid_chars() { + assert!(split_tag("invalid:namespace").is_err()); + assert!(split_tag("invalid namespace").is_err()); + assert!(split_tag("inv-alid-namespace").is_err()); + } + + #[test] + fn test_get_filename_from_tag_success() { + assert_eq!(get_filename_from_tag("dojo-world"), "dojo-world"); + assert_eq!(get_filename_from_tag("dojo-base"), "dojo-base"); + + let tag = "namespace-model"; + let filename = get_filename_from_tag(tag); + assert!(filename.starts_with(tag)); + assert_eq!(filename.split(TAG_SEPARATOR).count(), 3); + } + + #[test] + fn test_compute_bytearray_hash_success() { + let hash = compute_bytearray_hash("test"); + assert_eq!( + hash, + Felt::from_hex("0x2ca96bf6e71766195fa290b97c50f073b218d4e8c6948c899e3b07d754d6760") + .unwrap() + ); + } + + #[test] + fn test_compute_selector_from_tag_success() { + let selector = compute_selector_from_tag("namespace-model"); + assert_eq!( + selector, + Felt::from_hex("0x6cfe11a346c1bb31de8f454d65880454952e22d9adc2374fe67734196e0cbcb") + .unwrap() + ); + } + + #[test] + fn test_compute_selector_from_names_success() { + let selector = compute_selector_from_names("namespace", "model"); + assert_eq!( + selector, + Felt::from_hex("0x6cfe11a346c1bb31de8f454d65880454952e22d9adc2374fe67734196e0cbcb") + .unwrap() + ); + } + + #[test] + fn test_is_valid_tag_success() { + assert!(is_valid_tag("namespace-model")); + assert!(is_valid_tag("dojo-world")); + assert!(is_valid_tag("dojo_examples-base_test")); + } + + #[test] + fn test_is_valid_tag_failure() { + assert!(!is_valid_tag("invalid tag")); + assert!(!is_valid_tag("invalid@tag")); + assert!(!is_valid_tag("invalid-")); + assert!(!is_valid_tag("-invalid")); + assert!(!is_valid_tag("")); + } +} diff --git a/crates/dojo-types/src/packing.rs b/crates/dojo/types/src/packing.rs similarity index 100% rename from crates/dojo-types/src/packing.rs rename to crates/dojo/types/src/packing.rs diff --git a/crates/dojo-types/src/primitive.rs b/crates/dojo/types/src/primitive.rs similarity index 100% rename from crates/dojo-types/src/primitive.rs rename to crates/dojo/types/src/primitive.rs diff --git a/crates/dojo-types/src/primitive_conversion.rs b/crates/dojo/types/src/primitive_conversion.rs similarity index 100% rename from crates/dojo-types/src/primitive_conversion.rs rename to crates/dojo/types/src/primitive_conversion.rs diff --git a/crates/dojo-types/src/schema.rs b/crates/dojo/types/src/schema.rs similarity index 100% rename from crates/dojo-types/src/schema.rs rename to crates/dojo/types/src/schema.rs diff --git a/crates/dojo-types/src/storage.rs b/crates/dojo/types/src/storage.rs similarity index 100% rename from crates/dojo-types/src/storage.rs rename to crates/dojo/types/src/storage.rs diff --git a/crates/dojo-types/src/system.rs b/crates/dojo/types/src/system.rs similarity index 100% rename from crates/dojo-types/src/system.rs rename to crates/dojo/types/src/system.rs diff --git a/crates/dojo-types/tests/json.rs b/crates/dojo/types/tests/json.rs similarity index 100% rename from crates/dojo-types/tests/json.rs rename to crates/dojo/types/tests/json.rs diff --git a/crates/dojo-utils/Cargo.toml b/crates/dojo/utils/Cargo.toml similarity index 70% rename from crates/dojo-utils/Cargo.toml rename to crates/dojo/utils/Cargo.toml index 798b732482..771c3f9d70 100644 --- a/crates/dojo-utils/Cargo.toml +++ b/crates/dojo/utils/Cargo.toml @@ -12,7 +12,10 @@ reqwest.workspace = true rpassword.workspace = true starknet.workspace = true thiserror.workspace = true -tokio = { version = "1", features = [ "signal", "time" ], default-features = false } +tokio = { version = "1.39.2", features = [ "signal", "time", "macros" ], default-features = false } +tracing.workspace = true +serde_json.workspace = true +colored_json.workspace = true [dev-dependencies] assert_matches.workspace = true diff --git a/crates/dojo-utils/src/env.rs b/crates/dojo/utils/src/env.rs similarity index 100% rename from crates/dojo-utils/src/env.rs rename to crates/dojo/utils/src/env.rs diff --git a/crates/dojo-utils/src/keystore.rs b/crates/dojo/utils/src/keystore.rs similarity index 100% rename from crates/dojo-utils/src/keystore.rs rename to crates/dojo/utils/src/keystore.rs diff --git a/crates/dojo/utils/src/lib.rs b/crates/dojo/utils/src/lib.rs new file mode 100644 index 0000000000..380dd650cb --- /dev/null +++ b/crates/dojo/utils/src/lib.rs @@ -0,0 +1,19 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +pub mod parse; +mod tx; + +pub use tx::declarer::*; +pub use tx::deployer::*; +pub use tx::error::TransactionError; +pub use tx::invoker::*; +pub use tx::waiter::*; +pub use tx::{ + get_predeployed_accounts, parse_block_id, TransactionExt, TransactionResult, TxnAction, + TxnConfig, +}; + +pub mod env; +pub mod keystore; + +pub mod signal; diff --git a/crates/dojo-utils/src/parse.rs b/crates/dojo/utils/src/parse.rs similarity index 100% rename from crates/dojo-utils/src/parse.rs rename to crates/dojo/utils/src/parse.rs diff --git a/crates/dojo-utils/src/signal.rs b/crates/dojo/utils/src/signal.rs similarity index 100% rename from crates/dojo-utils/src/signal.rs rename to crates/dojo/utils/src/signal.rs diff --git a/crates/dojo/utils/src/tx/declarer.rs b/crates/dojo/utils/src/tx/declarer.rs new file mode 100644 index 0000000000..fed211ff88 --- /dev/null +++ b/crates/dojo/utils/src/tx/declarer.rs @@ -0,0 +1,123 @@ +//! Declare operations for the migration. +//! +//! Since a resource can be found in different namespaces, we want to optimize +//! the declaration to avoid declaring several times the same contract. +//! Also, checking onchain if the class is declared is less expensive that trying to declare. +//! +//! Declare transactions can't be multicalled. The only way to do so is by having multiple accounts. + +use std::collections::HashMap; +use std::sync::Arc; +use std::time::Duration; + +use starknet::accounts::ConnectedAccount; +use starknet::core::types::{ + BlockId, BlockTag, DeclareTransactionResult, Felt, FlattenedSierraClass, StarknetError, +}; +use starknet::providers::{Provider, ProviderError}; + +use crate::{TransactionError, TransactionExt, TransactionResult, TransactionWaiter, TxnConfig}; + +/// A declarer is in charge of declaring contracts. +#[derive(Debug)] +pub struct Declarer +where + A: ConnectedAccount + Send + Sync, +{ + /// The account to use to deploy the contracts. + pub account: A, + /// The transaction configuration. + pub txn_config: TxnConfig, + /// The classes to declare, identified by their casm class hash. + pub classes: HashMap, +} + +impl Declarer +where + A: ConnectedAccount + Send + Sync, +{ + /// Creates a new declarer. + pub fn new(account: A, txn_config: TxnConfig) -> Self { + Self { account, txn_config, classes: HashMap::new() } + } + + /// Adds a class to the declarer, do nothing if the class is already known. + pub fn add_class(&mut self, casm_class_hash: Felt, class: FlattenedSierraClass) { + self.classes.entry(casm_class_hash).or_insert(class); + } + + /// Extends the classes to the declarer. + pub fn extend_classes(&mut self, classes: Vec<(Felt, FlattenedSierraClass)>) { + for (casm_class_hash, class) in classes { + self.classes.entry(casm_class_hash).or_insert(class); + } + } + + /// Declares all the classes registered in the declarer with a single account. + /// + /// Takes ownership of the declarer to avoid cloning the classes. + /// + /// The order of the declarations is not guaranteed. + pub async fn declare_all( + self, + ) -> Result, TransactionError> { + let mut results = vec![]; + + for (casm_class_hash, class) in self.classes { + results.push( + Self::declare(casm_class_hash, class, &self.account, &self.txn_config).await?, + ); + } + + Ok(results) + } + + /// Declares a class. + pub async fn declare( + casm_class_hash: Felt, + class: FlattenedSierraClass, + account: &A, + txn_config: &TxnConfig, + ) -> Result> { + let class_hash = class.class_hash(); + + match account.provider().get_class(BlockId::Tag(BlockTag::Pending), class_hash).await { + Err(ProviderError::StarknetError(StarknetError::ClassHashNotFound)) => {} + Ok(_) => { + tracing::trace!( + class_hash = format!("{:#066x}", class_hash), + "Class already declared." + ); + return Ok(TransactionResult::Noop); + } + Err(e) => return Err(TransactionError::Provider(e)), + } + + let DeclareTransactionResult { transaction_hash, class_hash } = + account.declare_v2(Arc::new(class), casm_class_hash).send_with_cfg(txn_config).await?; + + tracing::trace!( + transaction_hash = format!("{:#066x}", transaction_hash), + class_hash = format!("{:#066x}", class_hash), + casm_class_hash = format!("{:#066x}", casm_class_hash), + "Declared class." + ); + + // Since TxnConfig::wait doesn't work for now, we wait for the transaction manually. + if txn_config.wait { + let receipt = if let Some(timeout_ms) = txn_config.timeout_ms { + TransactionWaiter::new(transaction_hash, &account.provider()) + .with_timeout(Duration::from_millis(timeout_ms)) + .await? + } else { + TransactionWaiter::new(transaction_hash, &account.provider()).await? + }; + + if txn_config.receipt { + return Ok(TransactionResult::HashReceipt(transaction_hash, Box::new(receipt))); + } + } + + Ok(TransactionResult::Hash(transaction_hash)) + } +} diff --git a/crates/dojo/utils/src/tx/deployer.rs b/crates/dojo/utils/src/tx/deployer.rs new file mode 100644 index 0000000000..b3fda1551f --- /dev/null +++ b/crates/dojo/utils/src/tx/deployer.rs @@ -0,0 +1,110 @@ +//! The deployer is in charge of deploying contracts to starknet. + +use std::time::Duration; + +use starknet::accounts::ConnectedAccount; +use starknet::core::types::{ + BlockId, BlockTag, Call, Felt, InvokeTransactionResult, StarknetError, +}; +use starknet::core::utils::get_contract_address; +use starknet::macros::{felt, selector}; +use starknet::providers::{Provider, ProviderError}; +use tracing::trace; + +use crate::{TransactionError, TransactionExt, TransactionResult, TransactionWaiter, TxnConfig}; + +const UDC_DEPLOY_SELECTOR: Felt = selector!("deployContract"); +const UDC_ADDRESS: Felt = + felt!("0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf"); + +#[derive(Debug)] +pub struct Deployer +where + A: ConnectedAccount + Send + Sync, +{ + /// The account to use to deploy the contracts. + pub account: A, + /// The transaction configuration. + pub txn_config: TxnConfig, +} + +impl Deployer +where + A: ConnectedAccount + Send + Sync, +{ + /// Creates a new deployer. + pub fn new(account: A, txn_config: TxnConfig) -> Self { + Self { account, txn_config } + } + + /// Deploys a contract via the UDC. + pub async fn deploy_via_udc( + &self, + class_hash: Felt, + salt: Felt, + constructor_calldata: &[Felt], + deployer_address: Felt, + ) -> Result> { + let udc_calldata = [ + vec![class_hash, salt, deployer_address, Felt::from(constructor_calldata.len())], + constructor_calldata.to_vec(), + ] + .concat(); + + let contract_address = + get_contract_address(salt, class_hash, constructor_calldata, deployer_address); + + if is_deployed(contract_address, &self.account.provider()).await? { + return Ok(TransactionResult::Noop); + } + + let txn = self.account.execute_v1(vec![Call { + calldata: udc_calldata, + selector: UDC_DEPLOY_SELECTOR, + to: UDC_ADDRESS, + }]); + + let InvokeTransactionResult { transaction_hash } = + txn.send_with_cfg(&self.txn_config).await?; + + trace!( + transaction_hash = format!("{:#066x}", transaction_hash), + contract_address = format!("{:#066x}", contract_address), + "Deployed contract via UDC." + ); + + if self.txn_config.wait { + let receipt = if let Some(timeout_ms) = self.txn_config.timeout_ms { + TransactionWaiter::new(transaction_hash, &self.account.provider()) + .with_timeout(Duration::from_millis(timeout_ms)) + .await? + } else { + TransactionWaiter::new(transaction_hash, &self.account.provider()).await? + }; + + if self.txn_config.receipt { + return Ok(TransactionResult::HashReceipt(transaction_hash, Box::new(receipt))); + } + } + + Ok(TransactionResult::Hash(transaction_hash)) + } +} + +/// Checks if a contract is deployed at the given address. +pub async fn is_deployed

(contract_address: Felt, provider: &P) -> Result +where + P: Provider, +{ + match provider.get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address).await { + Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Ok(false), + Ok(_) => { + tracing::trace!( + contract_address = format!("{:#066x}", contract_address), + "Contract already deployed." + ); + Ok(true) + } + Err(e) => Err(e), + } +} diff --git a/crates/dojo/utils/src/tx/error.rs b/crates/dojo/utils/src/tx/error.rs new file mode 100644 index 0000000000..4a80eacb63 --- /dev/null +++ b/crates/dojo/utils/src/tx/error.rs @@ -0,0 +1,57 @@ +use starknet::accounts::AccountError; +use starknet::core::types::contract::{CompressProgramError, ComputeClassHashError}; +use starknet::core::types::StarknetError; +use starknet::providers::ProviderError; +use thiserror::Error; + +use crate::TransactionWaitingError; + +#[derive(Debug, Error)] +pub enum TransactionError +where + S: std::error::Error, +{ + #[error(transparent)] + SigningError(S), + #[error(transparent)] + Provider(ProviderError), + #[error("{0}")] + TransactionExecution(String), + #[error(transparent)] + TransactionWaiting(#[from] TransactionWaitingError), + #[error(transparent)] + ComputeClassHash(#[from] ComputeClassHashError), + #[error(transparent)] + ClassCompression(#[from] CompressProgramError), + #[error("Fee calculation overflow")] + FeeOutOfRange, +} + +impl From> for TransactionError +where + S: std::error::Error, +{ + fn from(value: AccountError) -> Self { + match value { + AccountError::Signing(e) => TransactionError::SigningError(e), + AccountError::Provider(e) => Self::from(e), + AccountError::ClassHashCalculation(e) => TransactionError::ComputeClassHash(e), + AccountError::ClassCompression(e) => TransactionError::ClassCompression(e), + AccountError::FeeOutOfRange => TransactionError::FeeOutOfRange, + } + } +} + +impl From for TransactionError +where + S: std::error::Error, +{ + fn from(value: ProviderError) -> Self { + match &value { + ProviderError::StarknetError(StarknetError::TransactionExecutionError(te)) => { + TransactionError::TransactionExecution(te.execution_error.clone()) + } + _ => TransactionError::Provider(value), + } + } +} diff --git a/crates/dojo/utils/src/tx/invoker.rs b/crates/dojo/utils/src/tx/invoker.rs new file mode 100644 index 0000000000..51f5506f7e --- /dev/null +++ b/crates/dojo/utils/src/tx/invoker.rs @@ -0,0 +1,131 @@ +//! Invoker to invoke contracts. + +use std::time::Duration; + +use starknet::accounts::ConnectedAccount; +use starknet::core::types::Call; +use tracing::trace; + +use super::TransactionResult; +use crate::{TransactionError, TransactionExt, TransactionWaiter, TxnConfig}; + +#[derive(Debug)] +pub struct Invoker +where + A: ConnectedAccount + Send + Sync, +{ + /// The account to use to deploy the contracts. + pub account: A, + /// The transaction configuration. + pub txn_config: TxnConfig, + /// The calls to invoke. + pub calls: Vec, +} + +impl Invoker +where + A: ConnectedAccount + Send + Sync, +{ + /// Creates a new invoker. + pub fn new(account: A, txn_config: TxnConfig) -> Self { + Self { account, txn_config, calls: vec![] } + } + + /// Adds a call to the invoker. + pub fn add_call(&mut self, call: Call) { + self.calls.push(call); + } + + /// Extends the calls to the invoker. + pub fn extend_calls(&mut self, calls: Vec) { + self.calls.extend(calls); + } + + /// First uses the ordered calls, and then extends with the + /// calls already added (considered as non-ordered). + pub fn extends_ordered(&mut self, ordered_calls: Vec) { + for call in ordered_calls.into_iter().rev() { + self.calls.insert(0, call); + } + } + + /// Invokes a single call. + pub async fn invoke( + &self, + call: Call, + ) -> Result> { + trace!(?call, "Invoke contract."); + + let tx = self.account.execute_v1(vec![call]).send_with_cfg(&self.txn_config).await?; + + trace!(transaction_hash = format!("{:#066x}", tx.transaction_hash), "Invoke contract."); + + if self.txn_config.wait { + let receipt = if let Some(timeout_ms) = self.txn_config.timeout_ms { + TransactionWaiter::new(tx.transaction_hash, &self.account.provider()) + .with_timeout(Duration::from_millis(timeout_ms)) + .await? + } else { + TransactionWaiter::new(tx.transaction_hash, &self.account.provider()).await? + }; + + if self.txn_config.receipt { + return Ok(TransactionResult::HashReceipt(tx.transaction_hash, Box::new(receipt))); + } + } + + Ok(TransactionResult::Hash(tx.transaction_hash)) + } + + /// Invokes all the calls in one single transaction. + pub async fn multicall(&self) -> Result> { + if self.calls.is_empty() { + return Ok(TransactionResult::Noop); + } + + trace!(?self.calls, "Invoke contract multicall."); + + let tx = + self.account.execute_v1(self.calls.clone()).send_with_cfg(&self.txn_config).await?; + + trace!( + transaction_hash = format!("{:#066x}", tx.transaction_hash), + "Invoke contract multicall." + ); + + if self.txn_config.wait { + let receipt = if let Some(timeout_ms) = self.txn_config.timeout_ms { + TransactionWaiter::new(tx.transaction_hash, &self.account.provider()) + .with_timeout(Duration::from_millis(timeout_ms)) + .await? + } else { + TransactionWaiter::new(tx.transaction_hash, &self.account.provider()).await? + }; + + if self.txn_config.receipt { + return Ok(TransactionResult::HashReceipt(tx.transaction_hash, Box::new(receipt))); + } + } + + Ok(TransactionResult::Hash(tx.transaction_hash)) + } + + /// Invokes all the calls individually, usually used for debugging if a multicall failed. + /// + /// The order of the calls is the same as the order of the calls added to the invoker. + pub async fn invoke_all_sequentially( + &self, + ) -> Result, TransactionError> { + if !self.calls.is_empty() { + let mut results = vec![]; + + for call in self.calls.iter() { + results.push(self.invoke(call.clone()).await?); + } + + return Ok(results); + } + + Ok(vec![]) + } +} diff --git a/crates/dojo/utils/src/tx/mod.rs b/crates/dojo/utils/src/tx/mod.rs new file mode 100644 index 0000000000..5ddb76b705 --- /dev/null +++ b/crates/dojo/utils/src/tx/mod.rs @@ -0,0 +1,263 @@ +pub mod declarer; +pub mod deployer; +pub mod error; +pub mod invoker; +pub mod waiter; + +use std::fmt; + +use anyhow::{anyhow, Result}; +use colored_json::ToColoredJson; +use reqwest::Url; +use starknet::accounts::{ + AccountDeploymentV1, AccountError, AccountFactory, AccountFactoryError, ConnectedAccount, + DeclarationV2, ExecutionEncoding, ExecutionV1, SingleOwnerAccount, +}; +use starknet::core::types::{ + BlockId, BlockTag, DeclareTransactionResult, DeployAccountTransactionResult, Felt, + InvokeTransactionResult, TransactionReceiptWithBlockInfo, +}; +use starknet::providers::jsonrpc::HttpTransport; +use starknet::providers::{AnyProvider, JsonRpcClient, Provider}; +use starknet::signers::{LocalWallet, SigningKey}; + +/// The transaction configuration to use when sending a transaction. +#[derive(Debug, Copy, Clone, Default)] +pub struct TxnConfig { + /// The multiplier for how much the actual transaction max fee should be relative to the + /// estimated fee. If `None` is provided, the multiplier is set to `1.1`. + pub fee_estimate_multiplier: Option, + pub wait: bool, + pub receipt: bool, + pub max_fee_raw: Option, + pub walnut: bool, + pub timeout_ms: Option, +} + +#[derive(Debug, Copy, Clone)] +pub enum TxnAction { + Send { + wait: bool, + receipt: bool, + max_fee_raw: Option, + /// The multiplier for how much the actual transaction max fee should be relative to the + /// estimated fee. If `None` is provided, the multiplier is set to `1.1`. + fee_estimate_multiplier: Option, + walnut: bool, + timeout_ms: Option, + }, + Estimate, + Simulate, +} + +#[derive(Debug)] +pub enum TransactionResult { + /// In some occasions, the transaction is not sent and it's not an error. + /// Typically for the deployer/declarer/invoker that have internal logic to check if the + /// transaction is needed or not. + Noop, + /// The transaction hash. + Hash(Felt), + /// The transaction hash and it's receipt. + HashReceipt(Felt, Box), +} + +impl fmt::Display for TransactionResult { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + TransactionResult::Hash(hash) => write!(f, "Transaction hash: {:#066x}", hash), + TransactionResult::HashReceipt(hash, receipt) => write!( + f, + "Transaction hash: {:#066x}\nReceipt: {}", + hash, + serde_json::to_string_pretty(&receipt) + .expect("Failed to serialize receipt") + .to_colored_json_auto() + .expect("Failed to colorize receipt") + ), + TransactionResult::Noop => write!(f, "Transaction was not sent"), + } + } +} + +impl TxnConfig { + pub fn init_wait() -> Self { + Self { wait: true, ..Default::default() } + } +} + +/// Helper trait to abstract away setting `TxnConfig` configurations before sending a transaction +/// Implemented by types from `starknet-accounts` like `Execution`, `Declaration`, etc... +#[allow(async_fn_in_trait)] +pub trait TransactionExt { + type R; + type U; + + /// Sets `fee_estimate_multiplier` and `max_fee_raw` from `TxnConfig` if its present before + /// calling `send` method on the respective type. + /// NOTE: If both are specified `max_fee_raw` will take precedence and `fee_estimate_multiplier` + /// will be ignored by `starknet-rs` + async fn send_with_cfg(self, txn_config: &TxnConfig) -> Result; +} + +impl TransactionExt for ExecutionV1<'_, T> +where + T: ConnectedAccount + Sync, +{ + type R = InvokeTransactionResult; + type U = AccountError; + + async fn send_with_cfg( + mut self, + txn_config: &TxnConfig, + ) -> Result> { + if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { + self = self.fee_estimate_multiplier(*fee_est_mul); + } + + if let TxnConfig { max_fee_raw: Some(max_fee_r), .. } = txn_config { + self = self.max_fee(*max_fee_r); + } + + // TODO: need to fix the wait that is not usable, since we don't have access to the + // account/provider. Or execution could expose it, or we need it to be stored in the + // configuration... + self.send().await + } +} + +impl TransactionExt for DeclarationV2<'_, T> +where + T: ConnectedAccount + Sync, +{ + type R = DeclareTransactionResult; + type U = AccountError; + + async fn send_with_cfg( + mut self, + txn_config: &TxnConfig, + ) -> Result> { + if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { + self = self.fee_estimate_multiplier(*fee_est_mul); + } + + if let TxnConfig { max_fee_raw: Some(max_raw_f), .. } = txn_config { + self = self.max_fee(*max_raw_f); + } + + self.send().await + } +} + +impl TransactionExt for AccountDeploymentV1<'_, T> +where + T: AccountFactory + Sync, +{ + type R = DeployAccountTransactionResult; + type U = AccountFactoryError; + + async fn send_with_cfg( + mut self, + txn_config: &TxnConfig, + ) -> Result::SignError>> { + if let TxnConfig { fee_estimate_multiplier: Some(fee_est_mul), .. } = txn_config { + self = self.fee_estimate_multiplier(*fee_est_mul); + } + + if let TxnConfig { max_fee_raw: Some(max_raw_f), .. } = txn_config { + self = self.max_fee(*max_raw_f); + } + + self.send().await + } +} + +/// Parses a string into a [`BlockId`]. +/// +/// # Arguments +/// +/// * `block_str` - a string representing a block ID. It could be a block hash starting with 0x, a +/// block number, 'pending' or 'latest'. +/// +/// # Returns +/// +/// The parsed [`BlockId`] on success. +pub fn parse_block_id(block_str: String) -> Result { + if block_str.starts_with("0x") { + let hash = Felt::from_hex(&block_str) + .map_err(|_| anyhow!("Unable to parse block hash: {}", block_str))?; + Ok(BlockId::Hash(hash)) + } else if block_str.eq("pending") { + Ok(BlockId::Tag(BlockTag::Pending)) + } else if block_str.eq("latest") { + Ok(BlockId::Tag(BlockTag::Latest)) + } else { + match block_str.parse::() { + Ok(n) => Ok(BlockId::Number(n)), + Err(_) => Err(anyhow!("Unable to parse block ID: {}", block_str)), + } + } +} + +/// Get predeployed accounts from the RPC provider. +pub async fn get_predeployed_accounts( + migrator: A, + rpc_url: &str, +) -> anyhow::Result>> { + let client = reqwest::Client::new(); + let response = client + .post(rpc_url) + .json(&serde_json::json!({ + "jsonrpc": "2.0", + "method": "dev_predeployedAccounts", + "params": [], + "id": 1 + })) + .send() + .await; + + if response.is_err() { + return Ok(vec![]); + } + + let result: serde_json::Value = response.unwrap().json().await?; + + let mut declarers = vec![]; + + if let Some(vals) = result.get("result").and_then(|v| v.as_array()) { + let chain_id = migrator.provider().chain_id().await?; + + for a in vals { + let address = a["address"].as_str().unwrap(); + + // On slot, some accounts are hidden, we skip them. + let private_key = if let Some(pk) = a["privateKey"].as_str() { + pk + } else { + continue; + }; + + let provider = AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new( + Url::parse(rpc_url).unwrap(), + ))); + + let signer = LocalWallet::from(SigningKey::from_secret_scalar( + Felt::from_hex(private_key).unwrap(), + )); + + let mut account = SingleOwnerAccount::new( + provider, + signer, + Felt::from_hex(address).unwrap(), + chain_id, + ExecutionEncoding::New, + ); + + account.set_block_id(BlockId::Tag(BlockTag::Pending)); + + declarers.push(account); + } + } + + Ok(declarers) +} diff --git a/crates/dojo-utils/src/tx/waiter.rs b/crates/dojo/utils/src/tx/waiter.rs similarity index 100% rename from crates/dojo-utils/src/tx/waiter.rs rename to crates/dojo/utils/src/tx/waiter.rs diff --git a/crates/dojo/world/Cargo.toml b/crates/dojo/world/Cargo.toml new file mode 100644 index 0000000000..9986c14186 --- /dev/null +++ b/crates/dojo/world/Cargo.toml @@ -0,0 +1,32 @@ +[package] +description = "Dojo world specification. For example, crates and flags used for compilation." +edition.workspace = true +license-file.workspace = true +name = "dojo-world" +repository.workspace = true +version.workspace = true + +[dependencies] +anyhow.workspace = true +async-trait.workspace = true +cairo-lang-starknet-classes.workspace = true +#dojo-utils.workspace = true +regex.workspace = true +serde.workspace = true +serde_json.workspace = true +serde_with.workspace = true +starknet.workspace = true +starknet-crypto.workspace = true +thiserror.workspace = true +tracing.workspace = true +cainome.workspace = true +dojo-types.workspace = true +ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ], optional = true } +toml.workspace = true +url.workspace = true + +[dev-dependencies] +tokio.workspace = true + +[features] +metadata = [ "dep:ipfs-api-backend-hyper" ] diff --git a/crates/dojo-world/abigen/Cargo.toml b/crates/dojo/world/abigen/Cargo.toml similarity index 89% rename from crates/dojo-world/abigen/Cargo.toml rename to crates/dojo/world/abigen/Cargo.toml index bc1ddb3927..d271a56081 100644 --- a/crates/dojo-world/abigen/Cargo.toml +++ b/crates/dojo/world/abigen/Cargo.toml @@ -6,9 +6,11 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow.workspace = true cairo-lang-starknet.workspace = true cairo-lang-starknet-classes.workspace = true camino.workspace = true +cainome.workspace = true scarb.workspace = true scarb-ui.workspace = true serde.workspace = true diff --git a/crates/dojo/world/abigen/src/main.rs b/crates/dojo/world/abigen/src/main.rs new file mode 100644 index 0000000000..58c139d859 --- /dev/null +++ b/crates/dojo/world/abigen/src/main.rs @@ -0,0 +1,176 @@ +//! Programs that generates the bindings for World and Model contracts. +//! +//! The bindings are generated by cainome and outputted in rust modules +//! to be imported by downstream crates. +//! +//! Usage: +//! `cargo run -r -p dojo-abigen` form the workspace root to generate the bindings. +//! Don't forget the `-r` flag to run the program in release mode as Scarb is very slow +//! in debug mode. +//! +//! To check if the bindings are up to date, run `cargo run -p dojo-abigen -- --check`. +use std::collections::HashMap; +use std::fs; +use std::path::Path; +use std::process::Command; + +use anyhow::{anyhow, Result}; +use cainome::rs::Abigen; +use camino::Utf8PathBuf; +use scarb::core::{Config, TargetKind}; +use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; + +const SCARB_MANIFEST: &str = "crates/dojo/core/Scarb.toml"; +const WORLD_ARTIFACT: &str = "crates/dojo/core/target/dev/dojo_world.contract_class.json"; +const MODEL_ARTIFACT: &str = + "crates/dojo/core/target/dev/dojo_resource_metadata.contract_class.json"; +const OUT_DIR: &str = "crates/dojo/world/src/contracts/abigen"; + +/// Entrypoint for the abigen program to generate or check the bindings for the world and model +/// contracts. +fn main() -> Result<()> { + let is_check_only = define_check_only(); + + compile_dojo_core()?; + + generate_bindings("WorldContract", WORLD_ARTIFACT, "world.rs", is_check_only)?; + generate_bindings("ModelContract", MODEL_ARTIFACT, "model.rs", is_check_only)?; + + Ok(()) +} + +/// Returns true if the bindings should be generated, false if the bindings should be checked only. +fn define_check_only() -> bool { + let args: Vec<_> = std::env::args().collect(); + + args.len() > 1 && args[1] == "--check" +} + +/// Generates the bindings for the given contracts, or verifies +/// if the bindings are up to date. +/// +/// # Arguments +/// +/// * `contract_name` - The name of the contract to generate bindings for. +/// * `contract_artifact_path` - The path to the contract artifact. +/// * `bindings_filename` - The name of the file to write the bindings to. +/// * `is_check_only` - Whether to check if the bindings are up to date or generate them. +fn generate_bindings( + contract_name: &str, + contract_artifact_path: &str, + bindings_filename: &str, + is_check_only: bool, +) -> Result<()> { + // Use a temporary file to avoid conflicts with other bindings and comparing + // the bindings with the existing file in case of check only mode. + let tmp_file = format!("/tmp/{contract_name}.rs"); + + let abigen = Abigen::new(contract_name, contract_artifact_path) + .with_types_aliases(HashMap::from([( + String::from("dojo::world::config::Config::Event"), + String::from("DojoConfigEvent"), + )])) + .with_derives(vec![ + String::from("Clone"), + String::from("serde::Serialize"), + String::from("serde::Deserialize"), + String::from("PartialEq"), + String::from("Debug"), + ]) + .with_contract_derives(vec![String::from("Debug")]); + + abigen.generate()?.write_to_file(&tmp_file)?; + + // The formatting is not the same we need nighty. + Command::new("rustfmt") + .arg("+nightly-2024-08-28") + .arg(&tmp_file) + .status() + .expect("Failed to run rustfmt on generated bindings"); + + let out_path = format!("{OUT_DIR}/{bindings_filename}"); + + if is_check_only { + let generated_bindings = fs::read_to_string(tmp_file)?; + + if Path::new(&out_path).exists() { + let tmp_e_file = "/tmp/existing_bindings.rs"; + + let existing_bindings = fs::read_to_string(out_path)?; + fs::write(tmp_e_file, existing_bindings.clone())?; + + Command::new("rustfmt") + .arg("+nightly-2024-08-28") + .arg(tmp_e_file) + .status() + .expect("Failed to run rustfmt on generated bindings"); + + let existing_bindings = + fs::read_to_string(tmp_e_file)?.replace(char::is_whitespace, ""); + + let mut first_diff_index = None; + for (i, (existing_char, generated_char)) in + existing_bindings.chars().zip(generated_bindings.chars()).enumerate() + { + if existing_char != generated_char { + first_diff_index = Some(i); + break; + } + } + + if let Some(index) = first_diff_index { + println!("First differing character is at index: {}", index); + } else { + println!("No differing characters found."); + } + + if existing_bindings != generated_bindings { + return Err(anyhow!( + "{contract_name} ABI bindings are not up to date. Consider generating them \ + running `cargo run -p dojo-abigen`.", + )); + } + } else { + return Err(anyhow!("No bindings found for {contract_name}, expected at {out_path}.")); + } + } else { + // Rename the temporary file to the output file is enough to update the bindings. + rename_file(&tmp_file, &out_path)?; + } + + Ok(()) +} + +/// Renames a file from the old path to the new path. +/// +/// # Arguments +/// +/// * `old_path` - The path to the file to rename. +/// * `new_path` - The new path to rename the file to. +fn rename_file(old_path: &str, new_path: &str) -> Result<()> { + let o = Path::new(old_path); + let n = Path::new(new_path); + Ok(fs::rename(o, n)?) +} + +/// Compiles dojo-core contracts programatically using Scarb. +fn compile_dojo_core() -> Result<()> { + let path = Utf8PathBuf::from(SCARB_MANIFEST); + let config = Config::builder(path.canonicalize_utf8()?).build()?; + let ws = scarb::ops::read_workspace(config.manifest_path(), &config)?; + let packages = ws.members().map(|p| p.id).collect(); + + let features_opts = + FeaturesOpts { features: FeaturesSelector::AllFeatures, no_default_features: false }; + + scarb::ops::compile( + packages, + CompileOpts { + include_target_names: vec![], + include_target_kinds: vec![], + exclude_target_kinds: vec![TargetKind::TEST], + features: features_opts, + }, + &ws, + ) +} diff --git a/crates/dojo-world/src/config/environment.rs b/crates/dojo/world/src/config/environment.rs similarity index 100% rename from crates/dojo-world/src/config/environment.rs rename to crates/dojo/world/src/config/environment.rs diff --git a/crates/dojo/world/src/config/metadata_config.rs b/crates/dojo/world/src/config/metadata_config.rs new file mode 100644 index 0000000000..f1409df0ab --- /dev/null +++ b/crates/dojo/world/src/config/metadata_config.rs @@ -0,0 +1,35 @@ +//! Metadata configuration for the world. + +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; +use url::Url; + +use crate::config::WorldConfig; +use crate::uri::Uri; + +/// World metadata that describes the world. +#[derive(Default, Serialize, Deserialize, Debug, Clone)] +pub struct WorldMetadata { + pub name: String, + pub seed: String, + pub description: Option, + pub cover_uri: Option, + pub icon_uri: Option, + pub website: Option, + pub socials: Option>, +} + +impl From for WorldMetadata { + fn from(config: WorldConfig) -> Self { + WorldMetadata { + name: config.name, + seed: config.seed, + description: config.description, + cover_uri: config.cover_uri, + icon_uri: config.icon_uri, + website: config.website, + socials: config.socials, + } + } +} diff --git a/crates/dojo/world/src/config/migration_config.rs b/crates/dojo/world/src/config/migration_config.rs new file mode 100644 index 0000000000..89ca259f2e --- /dev/null +++ b/crates/dojo/world/src/config/migration_config.rs @@ -0,0 +1,13 @@ +use serde::Deserialize; + +#[derive(Debug, Clone, Deserialize, Default)] +pub struct MigrationConfig { + /// Contracts to skip during migration. + /// Expecting tags. + pub skip_contracts: Option>, + /// Disable multicall. + pub disable_multicall: Option, + /// Determine the contract initialization order. + /// Expecting tags. + pub order_inits: Option>, +} diff --git a/crates/dojo-world/src/config/mod.rs b/crates/dojo/world/src/config/mod.rs similarity index 57% rename from crates/dojo-world/src/config/mod.rs rename to crates/dojo/world/src/config/mod.rs index c2d1393da5..8c0753f98a 100644 --- a/crates/dojo-world/src/config/mod.rs +++ b/crates/dojo/world/src/config/mod.rs @@ -1,13 +1,12 @@ pub mod environment; +pub mod metadata_config; pub mod migration_config; pub mod namespace_config; pub mod profile_config; pub mod world_config; pub use environment::Environment; -pub use migration_config::MigrationConfig; -pub use namespace_config::{ - NamespaceConfig, DEFAULT_NAMESPACE_CFG_KEY, DOJO_MANIFESTS_DIR_CFG_KEY, NAMESPACE_CFG_PREFIX, -}; +pub use metadata_config::WorldMetadata; +pub use namespace_config::NamespaceConfig; pub use profile_config::ProfileConfig; pub use world_config::WorldConfig; diff --git a/crates/dojo/world/src/config/namespace_config.rs b/crates/dojo/world/src/config/namespace_config.rs new file mode 100644 index 0000000000..63fe394f0b --- /dev/null +++ b/crates/dojo/world/src/config/namespace_config.rs @@ -0,0 +1,120 @@ +//! Namespace configuration to map local resource to their world representation. +//! +//! A namespace configuration is a mapping between a local artifacts names and +//! the actual namespace they will have onchain. +//! +//! Event if locally the compiled resources have no namespace, they need one to +//! be registered in the world. +//! Since the world doesn't offers a default namespace, each project should define +//! one. +//! +//! If required, the namespace configuration can be more granular by mapping +//! specific local names to different namespaces. The same resource might appear +//! under different namespaces depending on the deployment scenario. This is valid. + +use std::collections::{HashMap, HashSet}; + +use serde::{Deserialize, Serialize}; + +/// Namespace configuration. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct NamespaceConfig { + /// The default namespace to use if none is specified. + pub default: String, + /// A mapping + pub mappings: Option>>, +} + +impl NamespaceConfig { + /// Creates a new namespace configuration with a default namespace. + pub fn new(default: &str) -> Self { + NamespaceConfig { default: default.to_string(), mappings: None } + } + + /// Adds mappings to the namespace configuration. + pub fn with_mappings(self, mappings: HashMap>) -> Self { + Self { mappings: Some(mappings), ..self } + } + + /// Returns all the namespaces mapped to the given local name. + /// + /// If a resource is explicitly mapped to a namespace, it will not be + /// mapped it to the default namespace. + /// + /// However, if no explicit mapping is provided, the default namespace is used. + pub fn get_namespaces(&self, local_name: &str) -> HashSet { + let mut namespaces = HashSet::new(); + + if let Some(mappings) = &self.mappings { + for (namespace, names) in mappings { + if names.contains(&local_name.to_string()) { + namespaces.insert(namespace.clone()); + } + } + } + + if namespaces.is_empty() { + namespaces.insert(self.default.clone()); + } + + namespaces + } + + /// Returns all the namespaces registered in the configuration. + pub fn list_namespaces(&self) -> Vec { + let mut namespaces = vec![self.default.clone()]; + + if let Some(mappings) = &self.mappings { + namespaces.extend(mappings.keys().cloned()); + } + + namespaces + } +} + +impl Default for NamespaceConfig { + fn default() -> Self { + NamespaceConfig::new("DEFAULT_NAMESPACE") + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_namespaces_default() { + let config = NamespaceConfig::new("dojo").with_mappings(HashMap::new()); + + assert_eq!(config.get_namespaces("c1"), HashSet::from(["dojo".to_string()])); + } + + #[test] + fn test_get_namespaces_explicit_single() { + let config = NamespaceConfig::new("dojo") + .with_mappings(HashMap::from([("ns1".to_string(), vec!["c1".to_string()])])); + + assert_eq!(config.get_namespaces("c1"), HashSet::from(["ns1".to_string()])); + } + + #[test] + fn test_get_namespaces_explicit_multiple() { + let config = NamespaceConfig::new("dojo").with_mappings(HashMap::from([( + "ns1".to_string(), + vec!["c1".to_string(), "c2".to_string()], + )])); + + assert_eq!(config.get_namespaces("c1"), HashSet::from(["ns1".to_string()])); + assert_eq!(config.get_namespaces("c2"), HashSet::from(["ns1".to_string()])); + } + + #[test] + fn test_list_namespaces() { + let config = NamespaceConfig::new("dojo").with_mappings(HashMap::from([( + "ns1".to_string(), + vec!["c1".to_string(), "c2".to_string()], + )])); + + assert_eq!(config.list_namespaces(), vec!["dojo".to_string(), "ns1".to_string()]); + } +} diff --git a/crates/dojo-world/src/config/profile_config.rs b/crates/dojo/world/src/config/profile_config.rs similarity index 55% rename from crates/dojo-world/src/config/profile_config.rs rename to crates/dojo/world/src/config/profile_config.rs index b1f21d1f2d..0489125c3d 100644 --- a/crates/dojo-world/src/config/profile_config.rs +++ b/crates/dojo/world/src/config/profile_config.rs @@ -1,8 +1,8 @@ +use std::collections::{HashMap, HashSet}; use std::fs; +use std::path::Path; use anyhow::Result; -use camino::Utf8PathBuf; -use scarb::compiler::Profile; use serde::Deserialize; use toml; @@ -11,52 +11,79 @@ use super::migration_config::MigrationConfig; use super::namespace_config::NamespaceConfig; use super::world_config::WorldConfig; -/// Profile configuration that is used to configure the world and the environment. +/// Profile configuration that is used to configure the world and its environment. /// -/// This [`ProfileConfig`] is expected to be loaded from a TOML file that is located -/// next to the `Scarb.toml` file, named with the profile name. +/// This [`ProfileConfig`] is expected to be loaded from a TOML file. #[derive(Debug, Clone, Default, Deserialize)] pub struct ProfileConfig { pub world: WorldConfig, pub namespace: NamespaceConfig, pub env: Option, pub migration: Option, + /// A mapping of writers to be set on the world. + pub writers: Option>>, + /// A mapping of owners to be set on the world. + pub owners: Option>>, + /// A mapping of init call arguments to be passed to the contract. + pub init_call_args: Option>>, } impl ProfileConfig { - /// Loads the profile configuration for the given profile. - /// - /// # Arguments - /// - /// * `manifest_dir` - The path to the directory containing the `Scarb.toml` file. - /// * `profile` - The profile to load the configuration for. - pub fn new(manifest_dir: &Utf8PathBuf, profile: Profile) -> Result { - let dev_config_path = manifest_dir.join("dojo_dev.toml"); - let config_path = manifest_dir.join(format!("dojo_{}.toml", profile.as_str())); - - if !dev_config_path.exists() { - return Err(anyhow::anyhow!( - "Profile configuration file not found for profile `{}`. Expected at {}.", - profile.as_str(), - dev_config_path - )); + pub fn new(name: &str, seed: &str, namespace: NamespaceConfig) -> Self { + Self { + world: WorldConfig { + name: name.to_string(), + seed: seed.to_string(), + ..Default::default() + }, + namespace, + ..Default::default() } + } - // If the profile file is not found, default to `dev.toml` file that must exist. - let config_path = if !config_path.exists() { dev_config_path } else { config_path }; - - let content = fs::read_to_string(&config_path)?; + /// Loads the profile configuration from a TOML file. + pub fn from_toml>(toml_path: P) -> Result { + let content = fs::read_to_string(&toml_path)?; let config: ProfileConfig = toml::from_str(&content)?; Ok(config) } + + /// Returns the local writers for a given tag. + pub fn get_local_writers(&self, tag: &str) -> HashSet { + if let Some(writers) = &self.writers { + writers.get(tag).unwrap_or(&HashSet::new()).clone() + } else { + HashSet::new() + } + } + + /// Returns the local owners for a given tag. + pub fn get_local_owners(&self, tag: &str) -> HashSet { + if let Some(owners) = &self.owners { + owners.get(tag).unwrap_or(&HashSet::new()).clone() + } else { + HashSet::new() + } + } + + /// Returns true if the tag has to be skipped during migration. + pub fn is_skipped(&self, tag: &str) -> bool { + if let Some(migration) = &self.migration { + if let Some(skip_contracts) = &migration.skip_contracts { + skip_contracts.contains(&tag.to_string()) + } else { + false + } + } else { + false + } + } } #[cfg(test)] mod tests { use std::collections::HashMap; - use smol_str::SmolStr; - use tempfile::TempDir; use url::Url; use super::*; @@ -109,7 +136,7 @@ mod tests { [namespace] default = "test" - mappings = { "test" = "test2" } + mappings = { "test" = ["test2"] } [env] rpc_url = "https://example.com/rpc" @@ -122,12 +149,20 @@ mod tests { [migration] skip_contracts = [ "module::my-contract" ] + [writers] + "ns1" = ["ns1-actions"] + + [owners] + "ns2" = ["ns2-blup"] + + [init_call_args] + "ns1-actions" = [ "0x1", "0x2" ] "#; let config = toml::from_str::(content).unwrap(); let migration = config.migration.unwrap(); - assert_eq!(migration.skip_contracts, vec!["module::my-contract".to_string()]); + assert_eq!(migration.skip_contracts.unwrap(), vec!["module::my-contract".to_string()]); let env = config.env.unwrap(); assert_eq!(env.rpc_url, Some("https://example.com/rpc".to_string())); @@ -158,60 +193,23 @@ mod tests { assert_eq!(config.namespace.default, "test".to_string()); assert_eq!( config.namespace.mappings, - Some(HashMap::from([("test".to_string(), "test2".to_string())])) + Some(HashMap::from([("test".to_string(), vec!["test2".to_string()])])) ); - } - - #[test] - fn test_profile_config_new_dev() { - let tmp_dir = - Utf8PathBuf::from(TempDir::new().unwrap().into_path().to_string_lossy().to_string()); - let config_path = tmp_dir.join("dojo_dev.toml"); - println!("config_path: {:?}", config_path); - - let config_content = r#" - [world] - name = "test_world" - seed = "1234" - - [namespace] - default = "test_namespace" - "#; - fs::write(&config_path, config_content).unwrap(); - - let config = ProfileConfig::new(&tmp_dir, Profile::DEV).unwrap(); - - assert_eq!(config.world.name, "test_world"); - assert_eq!(config.world.seed, "1234"); - assert_eq!(config.namespace.default, "test_namespace"); - } - - #[test] - fn test_profile_config_new_custom_profile() { - let tmp_dir = - Utf8PathBuf::from(TempDir::new().unwrap().into_path().to_string_lossy().to_string()); - - let dev_config_path = tmp_dir.join("dojo_dev.toml"); - let config_path = tmp_dir.join("dojo_slot.toml"); - println!("config_path: {:?}", config_path); - - let config_content = r#" - [world] - name = "test_world" - seed = "1234" - - [namespace] - default = "test_namespace" - "#; - fs::write(&config_path, config_content).unwrap(); - fs::write(&dev_config_path, config_content).unwrap(); - - let profile = Profile::new(SmolStr::from("slot")).unwrap(); - let config = ProfileConfig::new(&tmp_dir, profile).unwrap(); - - assert_eq!(config.world.name, "test_world"); - assert_eq!(config.world.seed, "1234"); - assert_eq!(config.namespace.default, "test_namespace"); + assert_eq!( + config.writers, + Some(HashMap::from([("ns1".to_string(), HashSet::from(["ns1-actions".to_string()]))])) + ); + assert_eq!( + config.owners, + Some(HashMap::from([("ns2".to_string(), HashSet::from(["ns2-blup".to_string()]))])) + ); + assert_eq!( + config.init_call_args, + Some(HashMap::from([( + "ns1-actions".to_string(), + vec!["0x1".to_string(), "0x2".to_string()] + )])) + ); } } diff --git a/crates/dojo-world/src/config/world_config.rs b/crates/dojo/world/src/config/world_config.rs similarity index 100% rename from crates/dojo-world/src/config/world_config.rs rename to crates/dojo/world/src/config/world_config.rs diff --git a/crates/dojo-world/src/contracts/abi/README.md b/crates/dojo/world/src/contracts/abigen/README.md similarity index 78% rename from crates/dojo-world/src/contracts/abi/README.md rename to crates/dojo/world/src/contracts/abigen/README.md index dc3953a1ce..dc71035d08 100644 --- a/crates/dojo-world/src/contracts/abi/README.md +++ b/crates/dojo/world/src/contracts/abigen/README.md @@ -2,10 +2,10 @@ To ease the re-use of `dojo-world` crate on other projects that are not aware of the whole dojo stack, the ABI used for binding generation are decoupled from the compilation process. -To generate the ABI in `world.rs` or `executor.rs`, please consider to run: +To generate the ABI in `world.rs` or `model.rs`, please consider to run: ```bash -cargo run --bin dojo-world-abigen +cargo run -p dojo-world-abigen -r ``` The CI runs the same command with the `--check` argument, to ensure that the ABI that are inside the rust modules are still consistent with the latest version of `dojo-core` contracts. diff --git a/crates/dojo/world/src/contracts/abigen/model.rs b/crates/dojo/world/src/contracts/abigen/model.rs new file mode 100644 index 0000000000..9887f43e9d --- /dev/null +++ b/crates/dojo/world/src/contracts/abigen/model.rs @@ -0,0 +1,783 @@ +// **** +// Auto-generated by cainome do not edit. +// **** + +#![allow(clippy::all)] +#![allow(warnings)] + +#[derive(Debug)] +pub struct ModelContract { + pub address: starknet::core::types::Felt, + pub account: A, + pub block_id: starknet::core::types::BlockId, +} +impl ModelContract { + pub fn new(address: starknet::core::types::Felt, account: A) -> Self { + Self { + address, + account, + block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending), + } + } + pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) { + self.address = address; + } + pub fn provider(&self) -> &A::Provider { + self.account.provider() + } + pub fn set_block(&mut self, block_id: starknet::core::types::BlockId) { + self.block_id = block_id; + } + pub fn with_block(self, block_id: starknet::core::types::BlockId) -> Self { + Self { block_id, ..self } + } +} +#[derive(Debug)] +pub struct ModelContractReader { + pub address: starknet::core::types::Felt, + pub provider: P, + pub block_id: starknet::core::types::BlockId, +} +impl ModelContractReader

{ + pub fn new(address: starknet::core::types::Felt, provider: P) -> Self { + Self { + address, + provider, + block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending), + } + } + pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) { + self.address = address; + } + pub fn provider(&self) -> &P { + &self.provider + } + pub fn set_block(&mut self, block_id: starknet::core::types::BlockId) { + self.block_id = block_id; + } + pub fn with_block(self, block_id: starknet::core::types::BlockId) -> Self { + Self { block_id, ..self } + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct Enum { + pub name: starknet::core::types::Felt, + pub attrs: Vec, + pub children: Vec<(starknet::core::types::Felt, Ty)>, +} +impl cainome::cairo_serde::CairoSerde for Enum { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.name); + __size += Vec::::cairo_serialized_size(&__rust.attrs); + __size += Vec::<(starknet::core::types::Felt, Ty)>::cairo_serialized_size(&__rust.children); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.name)); + __out.extend(Vec::::cairo_serialize(&__rust.attrs)); + __out.extend(Vec::<(starknet::core::types::Felt, Ty)>::cairo_serialize(&__rust.children)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&name); + let attrs = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&attrs); + let children = + Vec::<(starknet::core::types::Felt, Ty)>::cairo_deserialize(__felts, __offset)?; + __offset += Vec::<(starknet::core::types::Felt, Ty)>::cairo_serialized_size(&children); + Ok(Enum { name, attrs, children }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct FieldLayout { + pub selector: starknet::core::types::Felt, + pub layout: Layout, +} +impl cainome::cairo_serde::CairoSerde for FieldLayout { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += Layout::cairo_serialized_size(&__rust.layout); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(Layout::cairo_serialize(&__rust.layout)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let layout = Layout::cairo_deserialize(__felts, __offset)?; + __offset += Layout::cairo_serialized_size(&layout); + Ok(FieldLayout { selector, layout }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct Member { + pub name: starknet::core::types::Felt, + pub attrs: Vec, + pub ty: Ty, +} +impl cainome::cairo_serde::CairoSerde for Member { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.name); + __size += Vec::::cairo_serialized_size(&__rust.attrs); + __size += Ty::cairo_serialized_size(&__rust.ty); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.name)); + __out.extend(Vec::::cairo_serialize(&__rust.attrs)); + __out.extend(Ty::cairo_serialize(&__rust.ty)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&name); + let attrs = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&attrs); + let ty = Ty::cairo_deserialize(__felts, __offset)?; + __offset += Ty::cairo_serialized_size(&ty); + Ok(Member { name, attrs, ty }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ModelDef { + pub name: cainome::cairo_serde::ByteArray, + pub version: u8, + pub layout: Layout, + pub schema: Ty, + pub packed_size: Option, + pub unpacked_size: Option, +} +impl cainome::cairo_serde::CairoSerde for ModelDef { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.name); + __size += u8::cairo_serialized_size(&__rust.version); + __size += Layout::cairo_serialized_size(&__rust.layout); + __size += Ty::cairo_serialized_size(&__rust.schema); + __size += Option::::cairo_serialized_size(&__rust.packed_size); + __size += Option::::cairo_serialized_size(&__rust.unpacked_size); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.name)); + __out.extend(u8::cairo_serialize(&__rust.version)); + __out.extend(Layout::cairo_serialize(&__rust.layout)); + __out.extend(Ty::cairo_serialize(&__rust.schema)); + __out.extend(Option::::cairo_serialize(&__rust.packed_size)); + __out.extend(Option::::cairo_serialize(&__rust.unpacked_size)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let version = u8::cairo_deserialize(__felts, __offset)?; + __offset += u8::cairo_serialized_size(&version); + let layout = Layout::cairo_deserialize(__felts, __offset)?; + __offset += Layout::cairo_serialized_size(&layout); + let schema = Ty::cairo_deserialize(__felts, __offset)?; + __offset += Ty::cairo_serialized_size(&schema); + let packed_size = Option::::cairo_deserialize(__felts, __offset)?; + __offset += Option::::cairo_serialized_size(&packed_size); + let unpacked_size = Option::::cairo_deserialize(__felts, __offset)?; + __offset += Option::::cairo_serialized_size(&unpacked_size); + Ok(ModelDef { name, version, layout, schema, packed_size, unpacked_size }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ResourceMetadata { + pub resource_id: starknet::core::types::Felt, + pub metadata_uri: cainome::cairo_serde::ByteArray, +} +impl cainome::cairo_serde::CairoSerde for ResourceMetadata { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.resource_id); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.metadata_uri); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.resource_id)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.metadata_uri)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let resource_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&resource_id); + let metadata_uri = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&metadata_uri); + Ok(ResourceMetadata { resource_id, metadata_uri }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ResourceMetadataValue { + pub metadata_uri: cainome::cairo_serde::ByteArray, +} +impl cainome::cairo_serde::CairoSerde for ResourceMetadataValue { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.metadata_uri); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.metadata_uri)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let metadata_uri = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&metadata_uri); + Ok(ResourceMetadataValue { metadata_uri }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct Struct { + pub name: starknet::core::types::Felt, + pub attrs: Vec, + pub children: Vec, +} +impl cainome::cairo_serde::CairoSerde for Struct { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.name); + __size += Vec::::cairo_serialized_size(&__rust.attrs); + __size += Vec::::cairo_serialized_size(&__rust.children); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.name)); + __out.extend(Vec::::cairo_serialize(&__rust.attrs)); + __out.extend(Vec::::cairo_serialize(&__rust.children)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&name); + let attrs = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&attrs); + let children = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&children); + Ok(Struct { name, attrs, children }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Event {} +impl cainome::cairo_serde::CairoSerde for Event { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Event" + ))); + } + } + } +} +impl TryFrom<&starknet::core::types::EmittedEvent> for Event { + type Error = String; + fn try_from(event: &starknet::core::types::EmittedEvent) -> Result { + use cainome::cairo_serde::CairoSerde; + if event.keys.is_empty() { + return Err("Event has no key".to_string()); + } + Err(format!("Could not match any event from keys {:?}", event.keys)) + } +} +impl TryFrom<&starknet::core::types::Event> for Event { + type Error = String; + fn try_from(event: &starknet::core::types::Event) -> Result { + use cainome::cairo_serde::CairoSerde; + if event.keys.is_empty() { + return Err("Event has no key".to_string()); + } + Err(format!("Could not match any event from keys {:?}", event.keys)) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Layout { + Fixed(Vec), + Struct(Vec), + Tuple(Vec), + Array(Vec), + ByteArray, + Enum(Vec), +} +impl cainome::cairo_serde::CairoSerde for Layout { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + Layout::Fixed(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Struct(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Tuple(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Array(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::ByteArray => 1, + Layout::Enum(val) => Vec::::cairo_serialized_size(val) + 1, + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + Layout::Fixed(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Struct(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Tuple(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Array(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&3usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::ByteArray => usize::cairo_serialize(&4usize), + Layout::Enum(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&5usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => Ok(Layout::Fixed(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 1usize => { + Ok(Layout::Struct(Vec::::cairo_deserialize(__felts, __offset + 1)?)) + } + 2usize => Ok(Layout::Tuple(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 3usize => Ok(Layout::Array(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 4usize => Ok(Layout::ByteArray), + 5usize => { + Ok(Layout::Enum(Vec::::cairo_deserialize(__felts, __offset + 1)?)) + } + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Layout" + ))); + } + } + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Ty { + Primitive(starknet::core::types::Felt), + Struct(Struct), + Enum(Enum), + Tuple(Vec), + Array(Vec), + ByteArray, +} +impl cainome::cairo_serde::CairoSerde for Ty { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + Ty::Primitive(val) => starknet::core::types::Felt::cairo_serialized_size(val) + 1, + Ty::Struct(val) => Struct::cairo_serialized_size(val) + 1, + Ty::Enum(val) => Enum::cairo_serialized_size(val) + 1, + Ty::Tuple(val) => Vec::::cairo_serialized_size(val) + 1, + Ty::Array(val) => Vec::::cairo_serialized_size(val) + 1, + Ty::ByteArray => 1, + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + Ty::Primitive(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(starknet::core::types::Felt::cairo_serialize(val)); + temp + } + Ty::Struct(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(Struct::cairo_serialize(val)); + temp + } + Ty::Enum(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend(Enum::cairo_serialize(val)); + temp + } + Ty::Tuple(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&3usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Ty::Array(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&4usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Ty::ByteArray => usize::cairo_serialize(&5usize), + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => Ok(Ty::Primitive(starknet::core::types::Felt::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 1usize => Ok(Ty::Struct(Struct::cairo_deserialize(__felts, __offset + 1)?)), + 2usize => Ok(Ty::Enum(Enum::cairo_deserialize(__felts, __offset + 1)?)), + 3usize => Ok(Ty::Tuple(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 4usize => Ok(Ty::Array(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 5usize => Ok(Ty::ByteArray), + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Ty" + ))); + } + } + } +} +impl ModelContract { + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn definition(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("definition"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn dojo_name( + &self, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("dojo_name"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn ensure_abi( + &self, + model: &ResourceMetadata, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadata::cairo_serialize(model)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("ensure_abi"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn ensure_values( + &self, + value: &ResourceMetadataValue, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadataValue::cairo_serialize(value)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("ensure_values"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn layout(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("layout"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn packed_size(&self) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("packed_size"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn schema(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("schema"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn unpacked_size(&self) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("unpacked_size"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn version(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("version"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } +} +impl ModelContractReader

{ + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn definition(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("definition"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn dojo_name( + &self, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("dojo_name"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn ensure_abi(&self, model: &ResourceMetadata) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadata::cairo_serialize(model)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("ensure_abi"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn ensure_values( + &self, + value: &ResourceMetadataValue, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadataValue::cairo_serialize(value)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("ensure_values"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn layout(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("layout"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn packed_size(&self) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("packed_size"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn schema(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("schema"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn unpacked_size(&self) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("unpacked_size"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn version(&self) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("version"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } +} diff --git a/crates/dojo/world/src/contracts/abigen/world.rs b/crates/dojo/world/src/contracts/abigen/world.rs new file mode 100644 index 0000000000..3c1dc23eca --- /dev/null +++ b/crates/dojo/world/src/contracts/abigen/world.rs @@ -0,0 +1,4057 @@ +// **** +// Auto-generated by cainome do not edit. +// **** + +#![allow(clippy::all)] +#![allow(warnings)] + +#[derive(Debug)] +pub struct WorldContract { + pub address: starknet::core::types::Felt, + pub account: A, + pub block_id: starknet::core::types::BlockId, +} +impl WorldContract { + pub fn new(address: starknet::core::types::Felt, account: A) -> Self { + Self { + address, + account, + block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending), + } + } + pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) { + self.address = address; + } + pub fn provider(&self) -> &A::Provider { + self.account.provider() + } + pub fn set_block(&mut self, block_id: starknet::core::types::BlockId) { + self.block_id = block_id; + } + pub fn with_block(self, block_id: starknet::core::types::BlockId) -> Self { + Self { block_id, ..self } + } +} +#[derive(Debug)] +pub struct WorldContractReader { + pub address: starknet::core::types::Felt, + pub provider: P, + pub block_id: starknet::core::types::BlockId, +} +impl WorldContractReader

{ + pub fn new(address: starknet::core::types::Felt, provider: P) -> Self { + Self { + address, + provider, + block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending), + } + } + pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) { + self.address = address; + } + pub fn provider(&self) -> &P { + &self.provider + } + pub fn set_block(&mut self, block_id: starknet::core::types::BlockId) { + self.block_id = block_id; + } + pub fn with_block(self, block_id: starknet::core::types::BlockId) -> Self { + Self { block_id, ..self } + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ContractInitialized { + pub selector: starknet::core::types::Felt, + pub init_calldata: Vec, +} +impl cainome::cairo_serde::CairoSerde for ContractInitialized { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += Vec::::cairo_serialized_size(&__rust.init_calldata); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(Vec::::cairo_serialize(&__rust.init_calldata)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let init_calldata = + Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&init_calldata); + Ok(ContractInitialized { selector, init_calldata }) + } +} +impl ContractInitialized { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("ContractInitialized").unwrap() + } + pub fn event_name() -> &'static str { + "ContractInitialized" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ContractRegistered { + pub name: cainome::cairo_serde::ByteArray, + pub namespace: cainome::cairo_serde::ByteArray, + pub address: cainome::cairo_serde::ContractAddress, + pub class_hash: cainome::cairo_serde::ClassHash, + pub salt: starknet::core::types::Felt, +} +impl cainome::cairo_serde::CairoSerde for ContractRegistered { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.name); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.namespace); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.salt); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.name)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.namespace)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.address)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.salt)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let address = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let salt = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&salt); + Ok(ContractRegistered { name, namespace, address, class_hash, salt }) + } +} +impl ContractRegistered { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("ContractRegistered").unwrap() + } + pub fn event_name() -> &'static str { + "ContractRegistered" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ContractUpgraded { + pub selector: starknet::core::types::Felt, + pub class_hash: cainome::cairo_serde::ClassHash, +} +impl cainome::cairo_serde::CairoSerde for ContractUpgraded { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + Ok(ContractUpgraded { selector, class_hash }) + } +} +impl ContractUpgraded { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("ContractUpgraded").unwrap() + } + pub fn event_name() -> &'static str { + "ContractUpgraded" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct EventEmitted { + pub selector: starknet::core::types::Felt, + pub system_address: cainome::cairo_serde::ContractAddress, + pub historical: bool, + pub keys: Vec, + pub values: Vec, +} +impl cainome::cairo_serde::CairoSerde for EventEmitted { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.system_address); + __size += bool::cairo_serialized_size(&__rust.historical); + __size += Vec::::cairo_serialized_size(&__rust.keys); + __size += Vec::::cairo_serialized_size(&__rust.values); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out + .extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.system_address)); + __out.extend(bool::cairo_serialize(&__rust.historical)); + __out.extend(Vec::::cairo_serialize(&__rust.keys)); + __out.extend(Vec::::cairo_serialize(&__rust.values)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let system_address = + cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&system_address); + let historical = bool::cairo_deserialize(__felts, __offset)?; + __offset += bool::cairo_serialized_size(&historical); + let keys = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&keys); + let values = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&values); + Ok(EventEmitted { selector, system_address, historical, keys, values }) + } +} +impl EventEmitted { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("EventEmitted").unwrap() + } + pub fn event_name() -> &'static str { + "EventEmitted" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct EventRegistered { + pub name: cainome::cairo_serde::ByteArray, + pub namespace: cainome::cairo_serde::ByteArray, + pub class_hash: cainome::cairo_serde::ClassHash, + pub address: cainome::cairo_serde::ContractAddress, +} +impl cainome::cairo_serde::CairoSerde for EventRegistered { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.name); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.namespace); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.name)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.namespace)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.address)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + Ok(EventRegistered { name, namespace, class_hash, address }) + } +} +impl EventRegistered { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("EventRegistered").unwrap() + } + pub fn event_name() -> &'static str { + "EventRegistered" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct EventUpgraded { + pub selector: starknet::core::types::Felt, + pub class_hash: cainome::cairo_serde::ClassHash, + pub address: cainome::cairo_serde::ContractAddress, + pub prev_address: cainome::cairo_serde::ContractAddress, +} +impl cainome::cairo_serde::CairoSerde for EventUpgraded { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); + __size += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.prev_address); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.address)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.prev_address)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = + cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + Ok(EventUpgraded { selector, class_hash, address, prev_address }) + } +} +impl EventUpgraded { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("EventUpgraded").unwrap() + } + pub fn event_name() -> &'static str { + "EventUpgraded" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct FieldLayout { + pub selector: starknet::core::types::Felt, + pub layout: Layout, +} +impl cainome::cairo_serde::CairoSerde for FieldLayout { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += Layout::cairo_serialized_size(&__rust.layout); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(Layout::cairo_serialize(&__rust.layout)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let layout = Layout::cairo_deserialize(__felts, __offset)?; + __offset += Layout::cairo_serialized_size(&layout); + Ok(FieldLayout { selector, layout }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct MetadataUpdate { + pub resource: starknet::core::types::Felt, + pub uri: cainome::cairo_serde::ByteArray, +} +impl cainome::cairo_serde::CairoSerde for MetadataUpdate { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.resource); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.uri); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.resource)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.uri)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let resource = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let uri = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&uri); + Ok(MetadataUpdate { resource, uri }) + } +} +impl MetadataUpdate { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("MetadataUpdate").unwrap() + } + pub fn event_name() -> &'static str { + "MetadataUpdate" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ModelRegistered { + pub name: cainome::cairo_serde::ByteArray, + pub namespace: cainome::cairo_serde::ByteArray, + pub class_hash: cainome::cairo_serde::ClassHash, + pub address: cainome::cairo_serde::ContractAddress, +} +impl cainome::cairo_serde::CairoSerde for ModelRegistered { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.name); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.namespace); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.name)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.namespace)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.address)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let name = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + Ok(ModelRegistered { name, namespace, class_hash, address }) + } +} +impl ModelRegistered { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("ModelRegistered").unwrap() + } + pub fn event_name() -> &'static str { + "ModelRegistered" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ModelUpgraded { + pub selector: starknet::core::types::Felt, + pub class_hash: cainome::cairo_serde::ClassHash, + pub address: cainome::cairo_serde::ContractAddress, + pub prev_address: cainome::cairo_serde::ContractAddress, +} +impl cainome::cairo_serde::CairoSerde for ModelUpgraded { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); + __size += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.prev_address); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.address)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.prev_address)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = + cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + Ok(ModelUpgraded { selector, class_hash, address, prev_address }) + } +} +impl ModelUpgraded { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("ModelUpgraded").unwrap() + } + pub fn event_name() -> &'static str { + "ModelUpgraded" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct NamespaceRegistered { + pub namespace: cainome::cairo_serde::ByteArray, + pub hash: starknet::core::types::Felt, +} +impl cainome::cairo_serde::CairoSerde for NamespaceRegistered { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.namespace); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.hash); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.namespace)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.hash)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let namespace = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let hash = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&hash); + Ok(NamespaceRegistered { namespace, hash }) + } +} +impl NamespaceRegistered { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("NamespaceRegistered").unwrap() + } + pub fn event_name() -> &'static str { + "NamespaceRegistered" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct OwnerUpdated { + pub resource: starknet::core::types::Felt, + pub contract: cainome::cairo_serde::ContractAddress, + pub value: bool, +} +impl cainome::cairo_serde::CairoSerde for OwnerUpdated { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.resource); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.contract); + __size += bool::cairo_serialized_size(&__rust.value); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.resource)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.contract)); + __out.extend(bool::cairo_serialize(&__rust.value)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let resource = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = bool::cairo_deserialize(__felts, __offset)?; + __offset += bool::cairo_serialized_size(&value); + Ok(OwnerUpdated { resource, contract, value }) + } +} +impl OwnerUpdated { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("OwnerUpdated").unwrap() + } + pub fn event_name() -> &'static str { + "OwnerUpdated" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ResourceMetadata { + pub resource_id: starknet::core::types::Felt, + pub metadata_uri: cainome::cairo_serde::ByteArray, +} +impl cainome::cairo_serde::CairoSerde for ResourceMetadata { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.resource_id); + __size += cainome::cairo_serde::ByteArray::cairo_serialized_size(&__rust.metadata_uri); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.resource_id)); + __out.extend(cainome::cairo_serde::ByteArray::cairo_serialize(&__rust.metadata_uri)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let resource_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&resource_id); + let metadata_uri = cainome::cairo_serde::ByteArray::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&metadata_uri); + Ok(ResourceMetadata { resource_id, metadata_uri }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct StoreDelRecord { + pub selector: starknet::core::types::Felt, + pub entity_id: starknet::core::types::Felt, +} +impl cainome::cairo_serde::CairoSerde for StoreDelRecord { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.entity_id); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.entity_id)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + Ok(StoreDelRecord { selector, entity_id }) + } +} +impl StoreDelRecord { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("StoreDelRecord").unwrap() + } + pub fn event_name() -> &'static str { + "StoreDelRecord" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct StoreSetRecord { + pub selector: starknet::core::types::Felt, + pub entity_id: starknet::core::types::Felt, + pub keys: Vec, + pub values: Vec, +} +impl cainome::cairo_serde::CairoSerde for StoreSetRecord { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.entity_id); + __size += Vec::::cairo_serialized_size(&__rust.keys); + __size += Vec::::cairo_serialized_size(&__rust.values); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.entity_id)); + __out.extend(Vec::::cairo_serialize(&__rust.keys)); + __out.extend(Vec::::cairo_serialize(&__rust.values)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let keys = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&keys); + let values = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&values); + Ok(StoreSetRecord { selector, entity_id, keys, values }) + } +} +impl StoreSetRecord { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("StoreSetRecord").unwrap() + } + pub fn event_name() -> &'static str { + "StoreSetRecord" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct StoreUpdateMember { + pub selector: starknet::core::types::Felt, + pub entity_id: starknet::core::types::Felt, + pub member_selector: starknet::core::types::Felt, + pub values: Vec, +} +impl cainome::cairo_serde::CairoSerde for StoreUpdateMember { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.entity_id); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.member_selector); + __size += Vec::::cairo_serialized_size(&__rust.values); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.entity_id)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.member_selector)); + __out.extend(Vec::::cairo_serialize(&__rust.values)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let member_selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&member_selector); + let values = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&values); + Ok(StoreUpdateMember { selector, entity_id, member_selector, values }) + } +} +impl StoreUpdateMember { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("StoreUpdateMember").unwrap() + } + pub fn event_name() -> &'static str { + "StoreUpdateMember" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct StoreUpdateRecord { + pub selector: starknet::core::types::Felt, + pub entity_id: starknet::core::types::Felt, + pub values: Vec, +} +impl cainome::cairo_serde::CairoSerde for StoreUpdateRecord { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.entity_id); + __size += Vec::::cairo_serialized_size(&__rust.values); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.selector)); + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.entity_id)); + __out.extend(Vec::::cairo_serialize(&__rust.values)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let values = Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&values); + Ok(StoreUpdateRecord { selector, entity_id, values }) + } +} +impl StoreUpdateRecord { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("StoreUpdateRecord").unwrap() + } + pub fn event_name() -> &'static str { + "StoreUpdateRecord" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct WorldSpawned { + pub creator: cainome::cairo_serde::ContractAddress, + pub class_hash: cainome::cairo_serde::ClassHash, +} +impl cainome::cairo_serde::CairoSerde for WorldSpawned { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.creator); + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.creator)); + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let creator = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&creator); + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + Ok(WorldSpawned { creator, class_hash }) + } +} +impl WorldSpawned { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("WorldSpawned").unwrap() + } + pub fn event_name() -> &'static str { + "WorldSpawned" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct WorldUpgraded { + pub class_hash: cainome::cairo_serde::ClassHash, +} +impl cainome::cairo_serde::CairoSerde for WorldUpgraded { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(&__rust.class_hash)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + Ok(WorldUpgraded { class_hash }) + } +} +impl WorldUpgraded { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("WorldUpgraded").unwrap() + } + pub fn event_name() -> &'static str { + "WorldUpgraded" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct WriterUpdated { + pub resource: starknet::core::types::Felt, + pub contract: cainome::cairo_serde::ContractAddress, + pub value: bool, +} +impl cainome::cairo_serde::CairoSerde for WriterUpdated { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.resource); + __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.contract); + __size += bool::cairo_serialized_size(&__rust.value); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.resource)); + __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(&__rust.contract)); + __out.extend(bool::cairo_serialize(&__rust.value)); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let resource = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?; + __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = bool::cairo_deserialize(__felts, __offset)?; + __offset += bool::cairo_serialized_size(&value); + Ok(WriterUpdated { resource, contract, value }) + } +} +impl WriterUpdated { + pub fn event_selector() -> starknet::core::types::Felt { + starknet::core::utils::get_selector_from_name("WriterUpdated").unwrap() + } + pub fn event_name() -> &'static str { + "WriterUpdated" + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Event { + WorldSpawned(WorldSpawned), + WorldUpgraded(WorldUpgraded), + NamespaceRegistered(NamespaceRegistered), + ModelRegistered(ModelRegistered), + EventRegistered(EventRegistered), + ContractRegistered(ContractRegistered), + ModelUpgraded(ModelUpgraded), + EventUpgraded(EventUpgraded), + ContractUpgraded(ContractUpgraded), + ContractInitialized(ContractInitialized), + EventEmitted(EventEmitted), + MetadataUpdate(MetadataUpdate), + StoreSetRecord(StoreSetRecord), + StoreUpdateRecord(StoreUpdateRecord), + StoreUpdateMember(StoreUpdateMember), + StoreDelRecord(StoreDelRecord), + WriterUpdated(WriterUpdated), + OwnerUpdated(OwnerUpdated), +} +impl cainome::cairo_serde::CairoSerde for Event { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + Event::WorldSpawned(val) => WorldSpawned::cairo_serialized_size(val) + 1, + Event::WorldUpgraded(val) => WorldUpgraded::cairo_serialized_size(val) + 1, + Event::NamespaceRegistered(val) => NamespaceRegistered::cairo_serialized_size(val) + 1, + Event::ModelRegistered(val) => ModelRegistered::cairo_serialized_size(val) + 1, + Event::EventRegistered(val) => EventRegistered::cairo_serialized_size(val) + 1, + Event::ContractRegistered(val) => ContractRegistered::cairo_serialized_size(val) + 1, + Event::ModelUpgraded(val) => ModelUpgraded::cairo_serialized_size(val) + 1, + Event::EventUpgraded(val) => EventUpgraded::cairo_serialized_size(val) + 1, + Event::ContractUpgraded(val) => ContractUpgraded::cairo_serialized_size(val) + 1, + Event::ContractInitialized(val) => ContractInitialized::cairo_serialized_size(val) + 1, + Event::EventEmitted(val) => EventEmitted::cairo_serialized_size(val) + 1, + Event::MetadataUpdate(val) => MetadataUpdate::cairo_serialized_size(val) + 1, + Event::StoreSetRecord(val) => StoreSetRecord::cairo_serialized_size(val) + 1, + Event::StoreUpdateRecord(val) => StoreUpdateRecord::cairo_serialized_size(val) + 1, + Event::StoreUpdateMember(val) => StoreUpdateMember::cairo_serialized_size(val) + 1, + Event::StoreDelRecord(val) => StoreDelRecord::cairo_serialized_size(val) + 1, + Event::WriterUpdated(val) => WriterUpdated::cairo_serialized_size(val) + 1, + Event::OwnerUpdated(val) => OwnerUpdated::cairo_serialized_size(val) + 1, + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + Event::WorldSpawned(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(WorldSpawned::cairo_serialize(val)); + temp + } + Event::WorldUpgraded(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(WorldUpgraded::cairo_serialize(val)); + temp + } + Event::NamespaceRegistered(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend(NamespaceRegistered::cairo_serialize(val)); + temp + } + Event::ModelRegistered(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&3usize)); + temp.extend(ModelRegistered::cairo_serialize(val)); + temp + } + Event::EventRegistered(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&4usize)); + temp.extend(EventRegistered::cairo_serialize(val)); + temp + } + Event::ContractRegistered(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&5usize)); + temp.extend(ContractRegistered::cairo_serialize(val)); + temp + } + Event::ModelUpgraded(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&6usize)); + temp.extend(ModelUpgraded::cairo_serialize(val)); + temp + } + Event::EventUpgraded(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&7usize)); + temp.extend(EventUpgraded::cairo_serialize(val)); + temp + } + Event::ContractUpgraded(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&8usize)); + temp.extend(ContractUpgraded::cairo_serialize(val)); + temp + } + Event::ContractInitialized(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&9usize)); + temp.extend(ContractInitialized::cairo_serialize(val)); + temp + } + Event::EventEmitted(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&10usize)); + temp.extend(EventEmitted::cairo_serialize(val)); + temp + } + Event::MetadataUpdate(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&11usize)); + temp.extend(MetadataUpdate::cairo_serialize(val)); + temp + } + Event::StoreSetRecord(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&12usize)); + temp.extend(StoreSetRecord::cairo_serialize(val)); + temp + } + Event::StoreUpdateRecord(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&13usize)); + temp.extend(StoreUpdateRecord::cairo_serialize(val)); + temp + } + Event::StoreUpdateMember(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&14usize)); + temp.extend(StoreUpdateMember::cairo_serialize(val)); + temp + } + Event::StoreDelRecord(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&15usize)); + temp.extend(StoreDelRecord::cairo_serialize(val)); + temp + } + Event::WriterUpdated(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&16usize)); + temp.extend(WriterUpdated::cairo_serialize(val)); + temp + } + Event::OwnerUpdated(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&17usize)); + temp.extend(OwnerUpdated::cairo_serialize(val)); + temp + } + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => { + Ok(Event::WorldSpawned(WorldSpawned::cairo_deserialize(__felts, __offset + 1)?)) + } + 1usize => { + Ok(Event::WorldUpgraded(WorldUpgraded::cairo_deserialize(__felts, __offset + 1)?)) + } + 2usize => Ok(Event::NamespaceRegistered(NamespaceRegistered::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 3usize => Ok(Event::ModelRegistered(ModelRegistered::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 4usize => Ok(Event::EventRegistered(EventRegistered::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 5usize => Ok(Event::ContractRegistered(ContractRegistered::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 6usize => { + Ok(Event::ModelUpgraded(ModelUpgraded::cairo_deserialize(__felts, __offset + 1)?)) + } + 7usize => { + Ok(Event::EventUpgraded(EventUpgraded::cairo_deserialize(__felts, __offset + 1)?)) + } + 8usize => Ok(Event::ContractUpgraded(ContractUpgraded::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 9usize => Ok(Event::ContractInitialized(ContractInitialized::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 10usize => { + Ok(Event::EventEmitted(EventEmitted::cairo_deserialize(__felts, __offset + 1)?)) + } + 11usize => { + Ok(Event::MetadataUpdate(MetadataUpdate::cairo_deserialize(__felts, __offset + 1)?)) + } + 12usize => { + Ok(Event::StoreSetRecord(StoreSetRecord::cairo_deserialize(__felts, __offset + 1)?)) + } + 13usize => Ok(Event::StoreUpdateRecord(StoreUpdateRecord::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 14usize => Ok(Event::StoreUpdateMember(StoreUpdateMember::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 15usize => { + Ok(Event::StoreDelRecord(StoreDelRecord::cairo_deserialize(__felts, __offset + 1)?)) + } + 16usize => { + Ok(Event::WriterUpdated(WriterUpdated::cairo_deserialize(__felts, __offset + 1)?)) + } + 17usize => { + Ok(Event::OwnerUpdated(OwnerUpdated::cairo_deserialize(__felts, __offset + 1)?)) + } + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Event" + ))); + } + } + } +} +impl TryFrom<&starknet::core::types::EmittedEvent> for Event { + type Error = String; + fn try_from(event: &starknet::core::types::EmittedEvent) -> Result { + use cainome::cairo_serde::CairoSerde; + if event.keys.is_empty() { + return Err("Event has no key".to_string()); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WorldSpawned") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WorldSpawned")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let creator = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "creator", "WorldSpawned", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&creator); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "WorldSpawned", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::WorldSpawned(WorldSpawned { creator, class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WorldUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WorldUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "WorldUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::WorldUpgraded(WorldUpgraded { class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("NamespaceRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "NamespaceRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "NamespaceRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let hash = + match starknet::core::types::Felt::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "hash", "NamespaceRegistered", e + )); + } + }; + data_offset += starknet::core::types::Felt::cairo_serialized_size(&hash); + return Ok(Event::NamespaceRegistered(NamespaceRegistered { namespace, hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ModelRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ModelRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "ModelRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "ModelRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ModelRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ModelRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + return Ok(Event::ModelRegistered(ModelRegistered { + name, + namespace, + class_hash, + address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "EventRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "EventRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "EventRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "EventRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + return Ok(Event::EventRegistered(EventRegistered { + name, + namespace, + class_hash, + address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "ContractRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "ContractRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ContractRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ContractRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let salt = + match starknet::core::types::Felt::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "salt", "ContractRegistered", e + )); + } + }; + data_offset += starknet::core::types::Felt::cairo_serialized_size(&salt); + return Ok(Event::ContractRegistered(ContractRegistered { + name, + namespace, + address, + class_hash, + salt, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ModelUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ModelUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ModelUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ModelUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ModelUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "prev_address", "ModelUpgraded", e + )); + } + }; + data_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + return Ok(Event::ModelUpgraded(ModelUpgraded { + selector, + class_hash, + address, + prev_address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "EventUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "EventUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "EventUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "prev_address", "EventUpgraded", e + )); + } + }; + data_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + return Ok(Event::EventUpgraded(EventUpgraded { + selector, + class_hash, + address, + prev_address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ContractUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ContractUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::ContractUpgraded(ContractUpgraded { selector, class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractInitialized") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractInitialized")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ContractInitialized", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let init_calldata = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "init_calldata", "ContractInitialized", e + )); + } + }; + data_offset += + Vec::::cairo_serialized_size(&init_calldata); + return Ok(Event::ContractInitialized(ContractInitialized { selector, init_calldata })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventEmitted") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventEmitted")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "EventEmitted", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let system_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "system_address", "EventEmitted", e + )); + } + }; + key_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&system_address); + let historical = match bool::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "historical", "EventEmitted", e + )); + } + }; + key_offset += bool::cairo_serialized_size(&historical); + let keys = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "keys", "EventEmitted", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&keys); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "EventEmitted", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::EventEmitted(EventEmitted { + selector, + system_address, + historical, + keys, + values, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("MetadataUpdate") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "MetadataUpdate")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "MetadataUpdate", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let uri = match cainome::cairo_serde::ByteArray::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "uri", "MetadataUpdate", e + )); + } + }; + data_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&uri); + return Ok(Event::MetadataUpdate(MetadataUpdate { resource, uri })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreSetRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreSetRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreSetRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreSetRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let keys = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "keys", "StoreSetRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&keys); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreSetRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreSetRecord(StoreSetRecord { selector, entity_id, keys, values })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreUpdateRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreUpdateRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreUpdateRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreUpdateRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreUpdateRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreUpdateRecord(StoreUpdateRecord { selector, entity_id, values })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreUpdateMember") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreUpdateMember")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let member_selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "member_selector", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&member_selector); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreUpdateMember", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreUpdateMember(StoreUpdateMember { + selector, + entity_id, + member_selector, + values, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreDelRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreDelRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreDelRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreDelRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + return Ok(Event::StoreDelRecord(StoreDelRecord { selector, entity_id })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WriterUpdated") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WriterUpdated")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "WriterUpdated", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "contract", "WriterUpdated", e + )); + } + }; + key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = match bool::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "value", "WriterUpdated", e + )); + } + }; + data_offset += bool::cairo_serialized_size(&value); + return Ok(Event::WriterUpdated(WriterUpdated { resource, contract, value })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("OwnerUpdated") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnerUpdated")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "OwnerUpdated", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "contract", "OwnerUpdated", e + )); + } + }; + key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = match bool::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "value", "OwnerUpdated", e + )); + } + }; + data_offset += bool::cairo_serialized_size(&value); + return Ok(Event::OwnerUpdated(OwnerUpdated { resource, contract, value })); + } + Err(format!("Could not match any event from keys {:?}", event.keys)) + } +} +impl TryFrom<&starknet::core::types::Event> for Event { + type Error = String; + fn try_from(event: &starknet::core::types::Event) -> Result { + use cainome::cairo_serde::CairoSerde; + if event.keys.is_empty() { + return Err("Event has no key".to_string()); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WorldSpawned") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WorldSpawned")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let creator = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "creator", "WorldSpawned", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&creator); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "WorldSpawned", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::WorldSpawned(WorldSpawned { creator, class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WorldUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WorldUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "WorldUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::WorldUpgraded(WorldUpgraded { class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("NamespaceRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "NamespaceRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "NamespaceRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let hash = + match starknet::core::types::Felt::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "hash", "NamespaceRegistered", e + )); + } + }; + data_offset += starknet::core::types::Felt::cairo_serialized_size(&hash); + return Ok(Event::NamespaceRegistered(NamespaceRegistered { namespace, hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ModelRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ModelRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "ModelRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "ModelRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ModelRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ModelRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + return Ok(Event::ModelRegistered(ModelRegistered { + name, + namespace, + class_hash, + address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "EventRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "EventRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "EventRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "EventRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + return Ok(Event::EventRegistered(EventRegistered { + name, + namespace, + class_hash, + address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractRegistered") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractRegistered")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let name = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "name", "ContractRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&name); + let namespace = + match cainome::cairo_serde::ByteArray::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "namespace", "ContractRegistered", e + )); + } + }; + key_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&namespace); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ContractRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ContractRegistered", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let salt = + match starknet::core::types::Felt::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "salt", "ContractRegistered", e + )); + } + }; + data_offset += starknet::core::types::Felt::cairo_serialized_size(&salt); + return Ok(Event::ContractRegistered(ContractRegistered { + name, + namespace, + address, + class_hash, + salt, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ModelUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ModelUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ModelUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ModelUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "ModelUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "prev_address", "ModelUpgraded", e + )); + } + }; + data_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + return Ok(Event::ModelUpgraded(ModelUpgraded { + selector, + class_hash, + address, + prev_address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "EventUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "EventUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + let address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "address", "EventUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&address); + let prev_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "prev_address", "EventUpgraded", e + )); + } + }; + data_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&prev_address); + return Ok(Event::EventUpgraded(EventUpgraded { + selector, + class_hash, + address, + prev_address, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractUpgraded") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractUpgraded")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ContractUpgraded", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "class_hash", "ContractUpgraded", e + )); + } + }; + data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); + return Ok(Event::ContractUpgraded(ContractUpgraded { selector, class_hash })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractInitialized") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractInitialized")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ContractInitialized", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let init_calldata = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "init_calldata", "ContractInitialized", e + )); + } + }; + data_offset += + Vec::::cairo_serialized_size(&init_calldata); + return Ok(Event::ContractInitialized(ContractInitialized { selector, init_calldata })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("EventEmitted") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventEmitted")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "EventEmitted", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let system_address = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "system_address", "EventEmitted", e + )); + } + }; + key_offset += + cainome::cairo_serde::ContractAddress::cairo_serialized_size(&system_address); + let historical = match bool::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "historical", "EventEmitted", e + )); + } + }; + key_offset += bool::cairo_serialized_size(&historical); + let keys = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "keys", "EventEmitted", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&keys); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "EventEmitted", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::EventEmitted(EventEmitted { + selector, + system_address, + historical, + keys, + values, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("MetadataUpdate") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "MetadataUpdate")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "MetadataUpdate", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let uri = match cainome::cairo_serde::ByteArray::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "uri", "MetadataUpdate", e + )); + } + }; + data_offset += cainome::cairo_serde::ByteArray::cairo_serialized_size(&uri); + return Ok(Event::MetadataUpdate(MetadataUpdate { resource, uri })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreSetRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreSetRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreSetRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreSetRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let keys = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "keys", "StoreSetRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&keys); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreSetRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreSetRecord(StoreSetRecord { selector, entity_id, keys, values })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreUpdateRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreUpdateRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreUpdateRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreUpdateRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreUpdateRecord", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreUpdateRecord(StoreUpdateRecord { selector, entity_id, values })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreUpdateMember") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreUpdateMember")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + let member_selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "member_selector", "StoreUpdateMember", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&member_selector); + let values = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "values", "StoreUpdateMember", e + )); + } + }; + data_offset += Vec::::cairo_serialized_size(&values); + return Ok(Event::StoreUpdateMember(StoreUpdateMember { + selector, + entity_id, + member_selector, + values, + })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("StoreDelRecord") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "StoreDelRecord")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "StoreDelRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let entity_id = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "entity_id", "StoreDelRecord", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&entity_id); + return Ok(Event::StoreDelRecord(StoreDelRecord { selector, entity_id })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("WriterUpdated") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "WriterUpdated")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "WriterUpdated", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "contract", "WriterUpdated", e + )); + } + }; + key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = match bool::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "value", "WriterUpdated", e + )); + } + }; + data_offset += bool::cairo_serialized_size(&value); + return Ok(Event::WriterUpdated(WriterUpdated { resource, contract, value })); + } + let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("OwnerUpdated") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnerUpdated")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let resource = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "resource", "OwnerUpdated", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&resource); + let contract = match cainome::cairo_serde::ContractAddress::cairo_deserialize( + &event.keys, + key_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "contract", "OwnerUpdated", e + )); + } + }; + key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&contract); + let value = match bool::cairo_deserialize(&event.data, data_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "value", "OwnerUpdated", e + )); + } + }; + data_offset += bool::cairo_serialized_size(&value); + return Ok(Event::OwnerUpdated(OwnerUpdated { resource, contract, value })); + } + Err(format!("Could not match any event from keys {:?}", event.keys)) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Layout { + Fixed(Vec), + Struct(Vec), + Tuple(Vec), + Array(Vec), + ByteArray, + Enum(Vec), +} +impl cainome::cairo_serde::CairoSerde for Layout { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + Layout::Fixed(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Struct(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Tuple(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::Array(val) => Vec::::cairo_serialized_size(val) + 1, + Layout::ByteArray => 1, + Layout::Enum(val) => Vec::::cairo_serialized_size(val) + 1, + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + Layout::Fixed(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Struct(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Tuple(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::Array(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&3usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + Layout::ByteArray => usize::cairo_serialize(&4usize), + Layout::Enum(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&5usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => Ok(Layout::Fixed(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 1usize => { + Ok(Layout::Struct(Vec::::cairo_deserialize(__felts, __offset + 1)?)) + } + 2usize => Ok(Layout::Tuple(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 3usize => Ok(Layout::Array(Vec::::cairo_deserialize(__felts, __offset + 1)?)), + 4usize => Ok(Layout::ByteArray), + 5usize => { + Ok(Layout::Enum(Vec::::cairo_deserialize(__felts, __offset + 1)?)) + } + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Layout" + ))); + } + } + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum ModelIndex { + Keys(Vec), + Id(starknet::core::types::Felt), + MemberId((starknet::core::types::Felt, starknet::core::types::Felt)), +} +impl cainome::cairo_serde::CairoSerde for ModelIndex { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + ModelIndex::Keys(val) => { + Vec::::cairo_serialized_size(val) + 1 + } + ModelIndex::Id(val) => starknet::core::types::Felt::cairo_serialized_size(val) + 1, + ModelIndex::MemberId(val) => { + <(starknet::core::types::Felt, starknet::core::types::Felt)>::cairo_serialized_size( + val, + ) + 1 + } + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + ModelIndex::Keys(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(Vec::::cairo_serialize(val)); + temp + } + ModelIndex::Id(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(starknet::core::types::Felt::cairo_serialize(val)); + temp + } + ModelIndex::MemberId(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend( + <(starknet::core::types::Felt, starknet::core::types::Felt)>::cairo_serialize( + val, + ), + ); + temp + } + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => Ok(ModelIndex::Keys(Vec::::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 1usize => Ok(ModelIndex::Id(starknet::core::types::Felt::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 2usize => Ok(ModelIndex::MemberId(<( + starknet::core::types::Felt, + starknet::core::types::Felt, + )>::cairo_deserialize( + __felts, __offset + 1 + )?)), + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "ModelIndex" + ))); + } + } + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub enum Resource { + Model((cainome::cairo_serde::ContractAddress, starknet::core::types::Felt)), + Event((cainome::cairo_serde::ContractAddress, starknet::core::types::Felt)), + Contract((cainome::cairo_serde::ContractAddress, starknet::core::types::Felt)), + Namespace(cainome::cairo_serde::ByteArray), + World, + Unregistered, +} +impl cainome::cairo_serde::CairoSerde for Resource { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = std::option::Option::None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + match __rust { + Resource::Model(val) => <( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialized_size(val) + + 1, + Resource::Event(val) => <( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialized_size(val) + + 1, + Resource::Contract(val) => <( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialized_size(val) + + 1, + Resource::Namespace(val) => { + cainome::cairo_serde::ByteArray::cairo_serialized_size(val) + 1 + } + Resource::World => 1, + Resource::Unregistered => 1, + _ => 0, + } + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + match __rust { + Resource::Model(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&0usize)); + temp.extend(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialize(val)); + temp + } + Resource::Event(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&1usize)); + temp.extend(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialize(val)); + temp + } + Resource::Contract(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&2usize)); + temp.extend(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_serialize(val)); + temp + } + Resource::Namespace(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&3usize)); + temp.extend(cainome::cairo_serde::ByteArray::cairo_serialize(val)); + temp + } + Resource::World => usize::cairo_serialize(&4usize), + Resource::Unregistered => usize::cairo_serialize(&5usize), + _ => vec![], + } + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let __f = __felts[__offset]; + let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap()); + match __index as usize { + 0usize => Ok(Resource::Model(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_deserialize(__felts, __offset + 1)?)), + 1usize => Ok(Resource::Event(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_deserialize(__felts, __offset + 1)?)), + 2usize => { + Ok(Resource::Contract(<( + cainome::cairo_serde::ContractAddress, + starknet::core::types::Felt, + )>::cairo_deserialize(__felts, __offset + 1)?)) + } + 3usize => Ok(Resource::Namespace(cainome::cairo_serde::ByteArray::cairo_deserialize( + __felts, + __offset + 1, + )?)), + 4usize => Ok(Resource::World), + 5usize => Ok(Resource::Unregistered), + _ => { + return Err(cainome::cairo_serde::Error::Deserialize(format!( + "Index not handle for enum {}", + "Resource" + ))); + } + } + } +} +impl WorldContract { + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn entity( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + layout: &Layout, + ) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Layout::cairo_serialize(layout)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("entity"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn is_owner( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("is_owner"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn is_writer( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("is_writer"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn metadata( + &self, + resource_selector: &starknet::core::types::Felt, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource_selector)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("metadata"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn resource( + &self, + selector: &starknet::core::types::Felt, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("resource"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn delete_entity_getcall( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + layout: &Layout, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Layout::cairo_serialize(layout)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("delete_entity"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn delete_entity( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + layout: &Layout, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Layout::cairo_serialize(layout)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("delete_entity"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn emit_event_getcall( + &self, + event_selector: &starknet::core::types::Felt, + keys: &Vec, + values: &Vec, + historical: &bool, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(event_selector)); + __calldata.extend(Vec::::cairo_serialize(keys)); + __calldata.extend(Vec::::cairo_serialize(values)); + __calldata.extend(bool::cairo_serialize(historical)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("emit_event"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn emit_event( + &self, + event_selector: &starknet::core::types::Felt, + keys: &Vec, + values: &Vec, + historical: &bool, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(event_selector)); + __calldata.extend(Vec::::cairo_serialize(keys)); + __calldata.extend(Vec::::cairo_serialize(values)); + __calldata.extend(bool::cairo_serialize(historical)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("emit_event"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn grant_owner_getcall( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("grant_owner"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn grant_owner( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("grant_owner"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn grant_writer_getcall( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("grant_writer"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn grant_writer( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("grant_writer"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn init_contract_getcall( + &self, + selector: &starknet::core::types::Felt, + init_calldata: &Vec, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + __calldata.extend(Vec::::cairo_serialize(init_calldata)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("init_contract"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn init_contract( + &self, + selector: &starknet::core::types::Felt, + init_calldata: &Vec, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + __calldata.extend(Vec::::cairo_serialize(init_calldata)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("init_contract"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_contract_getcall( + &self, + salt: &starknet::core::types::Felt, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(salt)); + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_contract"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_contract( + &self, + salt: &starknet::core::types::Felt, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(salt)); + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_contract"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_event_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_event"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_event( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_event"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_model_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_model"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_model( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_model"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_namespace_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_namespace"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn register_namespace( + &self, + namespace: &cainome::cairo_serde::ByteArray, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("register_namespace"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn revoke_owner_getcall( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("revoke_owner"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn revoke_owner( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("revoke_owner"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn revoke_writer_getcall( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("revoke_writer"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn revoke_writer( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("revoke_writer"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn set_entity_getcall( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + values: &Vec, + layout: &Layout, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Vec::::cairo_serialize(values)); + __calldata.extend(Layout::cairo_serialize(layout)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("set_entity"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn set_entity( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + values: &Vec, + layout: &Layout, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Vec::::cairo_serialize(values)); + __calldata.extend(Layout::cairo_serialize(layout)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("set_entity"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn set_metadata_getcall(&self, metadata: &ResourceMetadata) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadata::cairo_serialize(metadata)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("set_metadata"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn set_metadata(&self, metadata: &ResourceMetadata) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(ResourceMetadata::cairo_serialize(metadata)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("set_metadata"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_getcall( + &self, + new_class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(new_class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade( + &self, + new_class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(new_class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_contract_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_contract"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_contract( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_contract"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_event_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_event"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_event( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_event"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_model_getcall( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_model"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn upgrade_model( + &self, + namespace: &cainome::cairo_serde::ByteArray, + class_hash: &cainome::cairo_serde::ClassHash, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(cainome::cairo_serde::ByteArray::cairo_serialize(namespace)); + __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("upgrade_model"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn uuid_getcall(&self) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("uuid"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn uuid(&self) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("uuid"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } +} +impl WorldContractReader

{ + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn entity( + &self, + model_selector: &starknet::core::types::Felt, + index: &ModelIndex, + layout: &Layout, + ) -> cainome::cairo_serde::call::FCall> { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(model_selector)); + __calldata.extend(ModelIndex::cairo_serialize(index)); + __calldata.extend(Layout::cairo_serialize(layout)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("entity"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn is_owner( + &self, + resource: &starknet::core::types::Felt, + address: &cainome::cairo_serde::ContractAddress, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("is_owner"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn is_writer( + &self, + resource: &starknet::core::types::Felt, + contract: &cainome::cairo_serde::ContractAddress, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource)); + __calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(contract)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("is_writer"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn metadata( + &self, + resource_selector: &starknet::core::types::Felt, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(resource_selector)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("metadata"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn resource( + &self, + selector: &starknet::core::types::Felt, + ) -> cainome::cairo_serde::call::FCall { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + let __call = starknet::core::types::FunctionCall { + contract_address: self.address, + entry_point_selector: starknet::macros::selector!("resource"), + calldata: __calldata, + }; + cainome::cairo_serde::call::FCall::new(__call, self.provider()) + } +} diff --git a/crates/dojo-world/src/contracts/cairo_utils.rs b/crates/dojo/world/src/contracts/cairo_utils.rs similarity index 52% rename from crates/dojo-world/src/contracts/cairo_utils.rs rename to crates/dojo/world/src/contracts/cairo_utils.rs index d1afd89750..aa44e8ebed 100644 --- a/crates/dojo-world/src/contracts/cairo_utils.rs +++ b/crates/dojo/world/src/contracts/cairo_utils.rs @@ -1,5 +1,4 @@ use anyhow::{anyhow, Result}; -use http::uri::Uri; use starknet::core::types::Felt; use starknet::core::utils::cairo_short_string_to_felt; @@ -8,10 +7,3 @@ pub fn str_to_felt(string: &str) -> Result { anyhow!(format!("Failed to convert string `{}` to cairo short string: {}", string, e)) }) } - -pub fn encode_uri(uri: &str) -> Result { - let parsed: Uri = - uri.try_into().map_err(|e| anyhow!("Failed to encode URI `{}`: {}", uri, e))?; - - Ok(cainome::cairo_serde::ByteArray::from_string(parsed.to_string().as_str()).unwrap()) -} diff --git a/crates/dojo/world/src/contracts/mod.rs b/crates/dojo/world/src/contracts/mod.rs new file mode 100644 index 0000000000..42eebaf99f --- /dev/null +++ b/crates/dojo/world/src/contracts/mod.rs @@ -0,0 +1,13 @@ +pub mod cairo_utils; + +#[allow(rust_2018_idioms)] +#[allow(unused)] +pub mod abigen { + pub mod model; + pub mod world; +} +pub mod model; +pub mod naming; +pub mod world; + +pub use abigen::world::{WorldContract, WorldContractReader}; diff --git a/crates/dojo-world/src/contracts/model.rs b/crates/dojo/world/src/contracts/model.rs similarity index 93% rename from crates/dojo-world/src/contracts/model.rs rename to crates/dojo/world/src/contracts/model.rs index 132bd99b0a..78e4aee82c 100644 --- a/crates/dojo-world/src/contracts/model.rs +++ b/crates/dojo/world/src/contracts/model.rs @@ -1,6 +1,5 @@ use std::str::FromStr as _; -pub use abigen::model::ModelContractReader; use async_trait::async_trait; use cainome::cairo_serde::{CairoSerde as _, ContractAddress, Error as CainomeError}; use dojo_types::packing::{PackingError, ParseError}; @@ -13,22 +12,14 @@ use starknet::core::utils::{ }; use starknet::providers::{Provider, ProviderError}; -use super::abi::world::{Layout, ModelIndex}; -use super::naming; +pub use super::abigen::model::ModelContractReader; +use super::abigen::world::{Layout, ModelIndex}; +use super::{abigen, naming}; use crate::contracts::WorldContractReader; -#[cfg(test)] -#[path = "model_test.rs"] -mod model_test; - -pub mod abigen { - pub mod model { - pub use crate::contracts::abi::model::*; - } - pub mod world { - pub use crate::contracts::abi::world::*; - } -} +// #[cfg(test)] +// #[path = "model_test.rs"] +// mod model_test; #[derive(Debug, thiserror::Error)] pub enum ModelError { @@ -98,9 +89,12 @@ where ) -> Result, ModelError> { let model_selector = naming::compute_selector_from_names(namespace, name); - let (class_hash, contract_address) = + // Events are also considered like models from a off-chain perspective. They both have + // introspection and convey type information. + let (contract_address, class_hash) = match world.resource(&model_selector).block_id(world.block_id).call().await? { - abigen::world::Resource::Model((hash, address)) => (hash, address), + abigen::world::Resource::Model((address, hash)) => (address, hash), + abigen::world::Resource::Event((address, hash)) => (address, hash), _ => return Err(ModelError::ModelNotFound), }; @@ -116,7 +110,7 @@ where namespace: namespace.into(), name: name.into(), world_reader: world, - class_hash: class_hash.into(), + class_hash, contract_address: contract_address.into(), selector: model_selector, model_reader, diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo/world/src/contracts/model_test.rs similarity index 98% rename from crates/dojo-world/src/contracts/model_test.rs rename to crates/dojo/world/src/contracts/model_test.rs index 93a2955025..2f992a0038 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo/world/src/contracts/model_test.rs @@ -17,7 +17,7 @@ async fn test_model(sequencer: &RunnerCtx) { let account = sequencer.account(0); let provider = account.provider(); - let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let setup = CompilerTestSetup::from_examples("../dojo/core", "../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let manifest_dir = config.manifest_path().parent().unwrap(); diff --git a/crates/dojo-world/src/contracts/naming.rs b/crates/dojo/world/src/contracts/naming.rs similarity index 100% rename from crates/dojo-world/src/contracts/naming.rs rename to crates/dojo/world/src/contracts/naming.rs diff --git a/crates/dojo-world/src/contracts/world.rs b/crates/dojo/world/src/contracts/world.rs similarity index 73% rename from crates/dojo-world/src/contracts/world.rs rename to crates/dojo/world/src/contracts/world.rs index 4b017ef5ee..11224da756 100644 --- a/crates/dojo-world/src/contracts/world.rs +++ b/crates/dojo/world/src/contracts/world.rs @@ -1,23 +1,17 @@ use std::result::Result; -pub use abigen::world::{ - ContractDeployed, ContractUpgraded, Event as WorldEvent, ModelRegistered, WorldContract, - WorldContractReader, -}; use starknet::providers::Provider; +pub use super::abigen::world::{ + ContractRegistered, ContractUpgraded, Event as WorldEvent, ModelRegistered, WorldContract, + WorldContractReader, +}; use super::model::{ModelError, ModelRPCReader}; use super::naming; -#[cfg(test)] -#[path = "world_test.rs"] -pub(crate) mod test; - -pub mod abigen { - pub mod world { - pub use crate::contracts::abi::world::*; - } -} +// #[cfg(test)] +// #[path = "world_test.rs"] +// pub(crate) mod test; impl

WorldContractReader

where diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo/world/src/contracts/world_test.rs similarity index 94% rename from crates/dojo-world/src/contracts/world_test.rs rename to crates/dojo/world/src/contracts/world_test.rs index e9a6d8c88f..28440760c7 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo/world/src/contracts/world_test.rs @@ -10,7 +10,7 @@ use super::WorldContractReader; #[tokio::test(flavor = "multi_thread")] #[katana_runner::test(db_dir = copy_spawn_and_move_db().as_str())] async fn test_world_contract_reader(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let setup = CompilerTestSetup::from_examples("../dojo/core", "../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let manifest_dir = config.manifest_path().parent().unwrap(); diff --git a/crates/dojo/world/src/diff/compare.rs b/crates/dojo/world/src/diff/compare.rs new file mode 100644 index 0000000000..e60965b1a4 --- /dev/null +++ b/crates/dojo/world/src/diff/compare.rs @@ -0,0 +1,204 @@ +//! Implements the comparison between a local and a remote resource/world. +//! +//! The point of view is the local one. + +use super::ResourceDiff; +use crate::local::{ContractLocal, EventLocal, ModelLocal, NamespaceLocal, ResourceLocal}; +use crate::remote::ResourceRemote; + +/// A trait to compare a local resource with a remote one. +pub trait ComparableResource { + /// Compares a local resource with a remote one. + /// + /// Takes ownership since the [`ResourceDiff`] will contain one or both resources. + fn compare(self, remote: ResourceRemote) -> ResourceDiff; +} + +impl ComparableResource for ContractLocal { + fn compare(self, remote: ResourceRemote) -> ResourceDiff { + let remote_contract = remote.as_contract_or_panic(); + + if self.common.class_hash == remote_contract.common.current_class_hash() { + ResourceDiff::Synced(ResourceLocal::Contract(self), remote) + } else { + ResourceDiff::Updated(ResourceLocal::Contract(self), remote) + } + } +} + +impl ComparableResource for ModelLocal { + fn compare(self, remote: ResourceRemote) -> ResourceDiff { + let remote_model = remote.as_model_or_panic(); + + if self.common.class_hash == remote_model.common.current_class_hash() { + ResourceDiff::Synced(ResourceLocal::Model(self), remote) + } else { + ResourceDiff::Updated(ResourceLocal::Model(self), remote) + } + } +} + +impl ComparableResource for EventLocal { + fn compare(self, remote: ResourceRemote) -> ResourceDiff { + let remote_event = remote.as_event_or_panic(); + + if self.common.class_hash == remote_event.common.current_class_hash() { + ResourceDiff::Synced(ResourceLocal::Event(self), remote) + } else { + ResourceDiff::Updated(ResourceLocal::Event(self), remote) + } + } +} + +impl ComparableResource for NamespaceLocal { + fn compare(self, remote: ResourceRemote) -> ResourceDiff { + let remote_namespace = remote.as_namespace_or_panic(); + + if self.name == remote_namespace.name { + ResourceDiff::Synced(ResourceLocal::Namespace(self), remote) + } else { + unreachable!("Namespace should not be updated.") + } + } +} + +impl ComparableResource for ResourceLocal { + fn compare(self, remote: ResourceRemote) -> ResourceDiff { + match self { + ResourceLocal::Contract(contract) => contract.compare(remote), + ResourceLocal::Model(model) => model.compare(remote), + ResourceLocal::Event(event) => event.compare(remote), + ResourceLocal::Namespace(ns) => ns.compare(remote), + } + } +} + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + + use starknet::core::types::Felt; + + use super::*; + use crate::local::{CommonLocalInfo, ContractLocal, EventLocal, ModelLocal}; + use crate::remote::{ + CommonRemoteInfo, ContractRemote, EventRemote, ModelRemote, NamespaceRemote, + }; + use crate::test_utils::empty_sierra_class; + + #[test] + fn test_compare_model_local() { + let local_model = ModelLocal { + common: CommonLocalInfo { + name: "model1".to_string(), + namespace: "ns1".to_string(), + class: empty_sierra_class(), + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + }, + members: vec![], + }; + + let mut remote_model = ResourceRemote::Model(ModelRemote { + common: CommonRemoteInfo { + class_hashes: vec![Felt::ZERO], + name: "model1".to_string(), + namespace: "ns1".to_string(), + address: Felt::ZERO, + owners: HashSet::new(), + writers: HashSet::new(), + }, + }); + + let diff = local_model.clone().compare(remote_model.clone()); + assert!(matches!(diff, ResourceDiff::Synced(_, _))); + + // Upgrade the remote model. + remote_model.push_class_hash(Felt::ONE); + + let diff_updated = local_model.compare(remote_model.clone()); + assert!(matches!(diff_updated, ResourceDiff::Updated(_, _))); + } + + #[test] + fn test_compare_event_local() { + let local_event = EventLocal { + common: CommonLocalInfo { + name: "event1".to_string(), + namespace: "ns1".to_string(), + class: empty_sierra_class(), + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + }, + members: vec![], + }; + + let mut remote_event = ResourceRemote::Event(EventRemote { + common: CommonRemoteInfo { + class_hashes: vec![Felt::ZERO], + name: "event1".to_string(), + namespace: "ns1".to_string(), + address: Felt::ZERO, + owners: HashSet::new(), + writers: HashSet::new(), + }, + }); + + let diff = local_event.clone().compare(remote_event.clone()); + assert!(matches!(diff, ResourceDiff::Synced(_, _))); + + // Upgrade the remote event. + remote_event.push_class_hash(Felt::ONE); + + let diff_updated = local_event.compare(remote_event.clone()); + assert!(matches!(diff_updated, ResourceDiff::Updated(_, _))); + } + + #[test] + fn test_compare_namespace_local() { + let local_namespace = NamespaceLocal { name: "namespace1".to_string() }; + + let remote_namespace = ResourceRemote::Namespace(NamespaceRemote { + name: "namespace1".to_string(), + owners: HashSet::new(), + writers: HashSet::new(), + }); + + let diff = local_namespace.compare(remote_namespace.clone()); + assert!(matches!(diff, ResourceDiff::Synced(_, _))); + } + + #[test] + fn test_compare_contract_local() { + let local_contract = ContractLocal { + common: CommonLocalInfo { + name: "contract1".to_string(), + namespace: "ns1".to_string(), + class: empty_sierra_class(), + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + }, + systems: vec![], + }; + + let mut remote_contract = ResourceRemote::Contract(ContractRemote { + common: CommonRemoteInfo { + class_hashes: vec![Felt::ZERO], + name: "contract1".to_string(), + namespace: "ns1".to_string(), + address: Felt::ZERO, + owners: HashSet::new(), + writers: HashSet::new(), + }, + is_initialized: true, + }); + + let diff = local_contract.clone().compare(remote_contract.clone()); + assert!(matches!(diff, ResourceDiff::Synced(_, _))); + + remote_contract.push_class_hash(Felt::ONE); + + let diff_updated = local_contract.compare(remote_contract.clone()); + assert!(matches!(diff_updated, ResourceDiff::Updated(_, _))); + } +} diff --git a/crates/dojo/world/src/diff/manifest.rs b/crates/dojo/world/src/diff/manifest.rs new file mode 100644 index 0000000000..f4c7d03c6f --- /dev/null +++ b/crates/dojo/world/src/diff/manifest.rs @@ -0,0 +1,214 @@ +//! Manifest data to store the diff result in files. + +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; +use starknet::core::serde::unsigned_field_element::UfeHex; +use starknet::core::types::contract::AbiEntry; +use starknet::core::types::Felt; + +use super::{ResourceDiff, WorldDiff}; +use crate::local::ResourceLocal; +use crate::remote::ResourceRemote; +use crate::ResourceType; + +#[serde_as] +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct Manifest { + pub world: WorldContract, + pub contracts: Vec, + pub models: Vec, + pub events: Vec, +} + +#[serde_as] +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct WorldContract { + /// Class hash of the contract. + #[serde_as(as = "UfeHex")] + pub class_hash: Felt, + /// Address of the contract. + #[serde_as(as = "UfeHex")] + pub address: Felt, + /// Seed used to deploy the world. + pub seed: String, + /// Name of the world. + pub name: String, + /// Abi of the world. + pub abi: Vec, +} + +#[serde_as] +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct DojoContract { + /// Address of the contract. + #[serde_as(as = "UfeHex")] + pub address: Felt, + /// Class hash of the contract. + #[serde_as(as = "UfeHex")] + pub class_hash: Felt, + /// ABI of the contract. + pub abi: Vec, + /// Initialization call data. + #[serde(default)] + pub init_calldata: Vec, + /// Tag of the contract. + pub tag: String, + /// Systems of the contract. + pub systems: Vec, +} + +#[serde_as] +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +#[cfg_attr(test, derive(PartialEq))] +pub struct DojoModel { + /// Members of the model. + pub members: Vec, + /// Class hash of the model. + #[serde_as(as = "UfeHex")] + pub class_hash: Felt, + /// Tag of the model. + pub tag: String, +} + +#[serde_as] +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +#[cfg_attr(test, derive(PartialEq))] +pub struct DojoEvent { + /// Members of the event. + pub members: Vec, + /// Class hash of the event. + #[serde_as(as = "UfeHex")] + pub class_hash: Felt, + /// Tag of the event. + pub tag: String, +} + +/// Represents a model member. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Member { + /// Name of the member. + pub name: String, + /// Type of the member. + #[serde(rename = "type")] + pub ty: String, + /// Whether the member is a key. + pub key: bool, +} + +impl Manifest { + pub fn new(diff: &WorldDiff) -> Self { + let world = WorldContract { + class_hash: diff.world_info.class_hash, + address: diff.world_info.address, + seed: diff.profile_config.world.seed.clone(), + name: diff.profile_config.world.name.clone(), + abi: diff.world_info.class.abi.clone(), + }; + + let mut contracts = Vec::new(); + let mut models = Vec::new(); + let mut events = Vec::new(); + + for resource in diff.resources.values() { + match resource.resource_type() { + ResourceType::Contract => { + contracts.push(resource_diff_to_dojo_contract(diff, resource)) + } + ResourceType::Model => models.push(resource_diff_to_dojo_model(resource)), + ResourceType::Event => events.push(resource_diff_to_dojo_event(resource)), + ResourceType::Namespace => {} + ResourceType::StarknetContract => {} + } + } + + // Keep order to ensure deterministic output. + contracts.sort_by_key(|c| c.tag.clone()); + models.sort_by_key(|m| m.tag.clone()); + events.sort_by_key(|e| e.tag.clone()); + + Self { world, contracts, models, events } + } +} + +fn resource_diff_to_dojo_contract(diff: &WorldDiff, resource: &ResourceDiff) -> DojoContract { + let init_calldata = if let Some(init_call_args) = &diff.profile_config.init_call_args { + init_call_args.get(&resource.tag()).unwrap_or(&vec![]).clone() + } else { + vec![] + }; + + let tag = resource.tag(); + + match &resource { + ResourceDiff::Created(ResourceLocal::Contract(l)) => DojoContract { + address: diff.get_contract_address(resource.dojo_selector()).unwrap(), + class_hash: l.common.class_hash, + abi: l.common.class.abi.clone(), + init_calldata, + tag, + systems: l.systems.clone(), + }, + ResourceDiff::Updated(ResourceLocal::Contract(l), ResourceRemote::Contract(r)) + | ResourceDiff::Synced(ResourceLocal::Contract(l), ResourceRemote::Contract(r)) => { + DojoContract { + address: r.common.address, + class_hash: l.common.class_hash, + abi: l.common.class.abi.clone(), + init_calldata, + tag, + systems: l.systems.clone(), + } + } + _ => unreachable!(), + } +} + +fn resource_diff_to_dojo_model(resource: &ResourceDiff) -> DojoModel { + match &resource { + ResourceDiff::Created(ResourceLocal::Model(l)) => DojoModel { + members: l + .members + .iter() + .map(|m| Member { name: m.name.clone(), ty: m.ty.clone(), key: m.key }) + .collect(), + class_hash: l.common.class_hash, + tag: l.common.name.clone(), + }, + ResourceDiff::Updated(ResourceLocal::Model(l), _) + | ResourceDiff::Synced(ResourceLocal::Model(l), _) => DojoModel { + members: l + .members + .iter() + .map(|m| Member { name: m.name.clone(), ty: m.ty.clone(), key: m.key }) + .collect(), + class_hash: l.common.class_hash, + tag: l.common.name.clone(), + }, + _ => unreachable!(), + } +} + +fn resource_diff_to_dojo_event(resource: &ResourceDiff) -> DojoEvent { + match &resource { + ResourceDiff::Created(ResourceLocal::Event(l)) => DojoEvent { + members: l + .members + .iter() + .map(|m| Member { name: m.name.clone(), ty: m.ty.clone(), key: m.key }) + .collect(), + class_hash: l.common.class_hash, + tag: l.common.name.clone(), + }, + ResourceDiff::Updated(ResourceLocal::Event(l), _) + | ResourceDiff::Synced(ResourceLocal::Event(l), _) => DojoEvent { + members: l + .members + .iter() + .map(|m| Member { name: m.name.clone(), ty: m.ty.clone(), key: m.key }) + .collect(), + class_hash: l.common.class_hash, + tag: l.common.name.clone(), + }, + _ => unreachable!(), + } +} diff --git a/crates/dojo/world/src/diff/mod.rs b/crates/dojo/world/src/diff/mod.rs new file mode 100644 index 0000000000..f9693e7669 --- /dev/null +++ b/crates/dojo/world/src/diff/mod.rs @@ -0,0 +1,471 @@ +//! Represents the difference between a local and a remote world. +//! +//! The local and remote worlds are consumed to produce the diff, to avoid duplicating the +//! resources. + +use std::collections::{HashMap, HashSet}; + +use anyhow::Result; +use compare::ComparableResource; +use dojo_types::naming; +use starknet::core::types::contract::SierraClass; +use starknet::core::types::{BlockId, BlockTag, StarknetError}; +use starknet::providers::{Provider, ProviderError}; +use starknet_crypto::Felt; + +use super::local::{ResourceLocal, WorldLocal}; +use super::remote::{ResourceRemote, WorldRemote}; +use crate::config::ProfileConfig; +use crate::{utils, ContractAddress, DojoSelector, ResourceType}; + +mod compare; +mod manifest; +mod resource; + +pub use manifest::*; +pub use resource::*; + +#[derive(Debug)] +pub struct WorldStatusInfo { + /// The address of the world. + pub address: Felt, + /// The class hash of the world. + pub class_hash: Felt, + /// The casm class hash of the world. + pub casm_class_hash: Felt, + /// The sierra class of the world. + pub class: SierraClass, + /// The status of the world. + pub status: WorldStatus, +} + +#[derive(Debug, PartialEq)] +pub enum WorldStatus { + /// The world is not deployed, it's the first migration with the given seed. + NotDeployed, + /// The local world is a new version, and the remote world must be updated. + NewVersion, + /// The world is in sync with the remote world, same dojo version. + Synced, +} + +#[derive(Debug)] +pub struct WorldDiff { + /// The status of the world. + pub world_info: WorldStatusInfo, + /// The namespaces registered in the local world. A list of namespaces is kept + /// additionally to the resources to ensure they can be processed first, + /// since the all other resources are namespaced. + pub namespaces: Vec, + /// The resources registered in the local world, by dojo selector. + pub resources: HashMap, + /// The profile configuration for the world. + pub profile_config: ProfileConfig, +} + +impl WorldDiff { + /// Creates a new world diff from a local world. + /// + /// Consumes the local world to avoid duplicating the resources. + pub fn from_local(local: WorldLocal) -> Result { + let mut diff = Self { + world_info: WorldStatusInfo { + address: local.deterministic_world_address()?, + class_hash: local.class_hash, + casm_class_hash: local.casm_class_hash, + class: local.class, + status: WorldStatus::NotDeployed, + }, + namespaces: vec![], + resources: HashMap::new(), + profile_config: local.profile_config, + }; + + for (selector, resource) in local.resources { + // Namespaces are enumerated to be easily retrieved later. + if let ResourceLocal::Namespace(_) = &resource { + diff.namespaces.push(selector); + } + + diff.resources.insert(selector, ResourceDiff::Created(resource)); + } + + Ok(diff) + } + + /// Creates a new world diff from a local and a remote world. + /// + /// Consumes the local and remote worlds to avoid duplicating the resources, + /// since the [`ResourceDiff`] will contain one or both of the local and remote resources. + pub fn new(local: WorldLocal, mut remote: WorldRemote) -> Self { + let status = if local.class_hash == remote.current_class_hash() { + WorldStatus::Synced + } else { + WorldStatus::NewVersion + }; + + let mut diff = Self { + world_info: WorldStatusInfo { + // As the remote world was found, its address is always used. + address: remote.address, + class_hash: local.class_hash, + casm_class_hash: local.casm_class_hash, + class: local.class, + status, + }, + namespaces: vec![], + resources: HashMap::new(), + profile_config: local.profile_config, + }; + + for (local_selector, local_resource) in local.resources { + // Namespaces are enumerated to be easily retrieved later. + if let ResourceLocal::Namespace(_) = &local_resource { + diff.namespaces.push(local_selector); + } + + let remote_resource = remote.resources.remove(&local_selector); + + if let Some(remote_resource) = remote_resource { + diff.resources.insert(local_selector, local_resource.compare(remote_resource)); + } else { + diff.resources.insert(local_selector, ResourceDiff::Created(local_resource)); + } + } + + diff + } + + /// Creates a new world diff pulling events from the chain. + pub async fn new_from_chain

( + world_address: Felt, + world_local: WorldLocal, + provider: P, + ) -> Result + where + P: Provider, + { + let is_deployed = match provider + .get_class_hash_at(BlockId::Tag(BlockTag::Pending), world_address) + .await + { + Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Ok(false), + Ok(_) => { + tracing::trace!( + contract_address = format!("{:#066x}", world_address), + "World already deployed." + ); + Ok(true) + } + Err(e) => Err(e), + }?; + + if is_deployed { + let world_remote = WorldRemote::from_events(world_address, &provider).await?; + + Ok(Self::new(world_local, world_remote)) + } else { + Self::from_local(world_local) + } + } + + /// Returns whether the whole world is in sync. + /// + /// This only concerns the resources status, and not the initialization of contracts + /// or the permissions. + pub fn is_synced(&self) -> bool { + self.world_info.status == WorldStatus::Synced + && self + .resources + .values() + .all(|resource| matches!(resource, ResourceDiff::Synced(_, _))) + } + + /// Returns the writers of a resource. + pub fn get_writers(&self, selector: DojoSelector) -> DiffPermissions { + let resource = self.resources.get(&selector); + + if resource.is_none() { + return DiffPermissions { local: HashSet::new(), remote: HashSet::new() }; + } + + let resource = resource.unwrap(); + + let tag = resource.tag(); + + match resource { + ResourceDiff::Created(_) => { + let local_writers = self.profile_config.get_local_writers(&tag); + let local_grantees = + local_writers.iter().map(|w| self.resolve_local_grantee(w)).collect(); + + DiffPermissions { local: local_grantees, remote: HashSet::new() } + } + ResourceDiff::Updated(_, remote) | ResourceDiff::Synced(_, remote) => { + let local_writers = self.profile_config.get_local_writers(&tag); + let local_grantees = + local_writers.iter().map(|w| self.resolve_local_grantee(w)).collect(); + + let remote_writers = remote.get_writers(); + let remote_grantees = remote_writers + .1 + .iter() + .map(|addr| self.resolve_remote_grantee(*addr)) + .collect(); + + DiffPermissions { local: local_grantees, remote: remote_grantees } + } + } + } + + /// Returns the owners of a resource. + pub fn get_owners(&self, selector: DojoSelector) -> DiffPermissions { + let resource = self.resources.get(&selector); + if resource.is_none() { + return DiffPermissions { local: HashSet::new(), remote: HashSet::new() }; + } + + let resource = resource.unwrap(); + + let tag = resource.tag(); + + match resource { + ResourceDiff::Created(_) => { + let local_owners = self.profile_config.get_local_owners(&tag); + let local_grantees = + local_owners.iter().map(|w| self.resolve_local_grantee(w)).collect(); + + DiffPermissions { local: local_grantees, remote: HashSet::new() } + } + ResourceDiff::Updated(_, remote) | ResourceDiff::Synced(_, remote) => { + let local_owners = self.profile_config.get_local_owners(&tag); + let local_grantees = + local_owners.iter().map(|w| self.resolve_local_grantee(w)).collect(); + + let remote_owners = remote.get_owners(); + let remote_grantees = + remote_owners.1.iter().map(|addr| self.resolve_remote_grantee(*addr)).collect(); + + DiffPermissions { local: local_grantees, remote: remote_grantees } + } + } + } + + /// Attempts to resolve a local grantee from a tag, to have it's address. + fn resolve_local_grantee(&self, tag: &str) -> PermissionGrantee { + let selector = naming::compute_selector_from_tag(tag); + + // TODO: see how we can elegantly have an error from this deep resolve. + let address = self.get_contract_address(selector).unwrap_or_else(|| { + panic!( + "Tag `{}` is not found locally. Local grantee must be managed locally, it's not \ + supported to manage external resources permissions without a local resource.", + tag + ) + }); + + PermissionGrantee { tag: Some(tag.to_string()), address } + } + + /// Attempts to resolve a remote grantee to have it's tag. + fn resolve_remote_grantee(&self, contract_address: ContractAddress) -> PermissionGrantee { + let known_addresses = self.get_contracts_addresses(); + + let mut tag = None; + for (selector, address) in &known_addresses { + if address == &contract_address { + tag = Some(self.resources.get(selector).unwrap().tag()); + break; + } + } + + PermissionGrantee { tag, address: contract_address } + } + + /// Returns the class of the contract, if any. + pub fn get_class(&self, selector: DojoSelector) -> Option<&SierraClass> { + let resource = self.resources.get(&selector)?; + + match resource { + ResourceDiff::Created(ResourceLocal::Contract(c)) => Some(&c.common.class), + ResourceDiff::Updated(ResourceLocal::Contract(c), _) => Some(&c.common.class), + ResourceDiff::Synced(ResourceLocal::Contract(c), _) => Some(&c.common.class), + _ => None, + } + } + + /// Returns the deterministic addresses of the contracts based on the world address. + pub fn get_contracts_addresses(&self) -> HashMap { + let mut addresses = HashMap::new(); + + for (selector, _) in self.resources.iter() { + if let Some(address) = self.get_contract_address(*selector) { + addresses.insert(*selector, address); + } + } + + addresses + } + + /// Returns the deterministic address of a contract from it's tag. + /// + /// If the contract is not found or the tag is not valid, returns `None`. + pub fn get_contract_address_from_tag(&self, tag: &str) -> Option { + self.get_contract_address(naming::compute_selector_from_tag(tag)) + } + + /// Returns the deterministic address of the contract based on the world address. + pub fn get_contract_address(&self, selector: DojoSelector) -> Option { + let contract_resource = self.resources.get(&selector)?; + + if contract_resource.resource_type() == ResourceType::Contract { + match contract_resource { + ResourceDiff::Created(ResourceLocal::Contract(c)) => { + Some(utils::compute_dojo_contract_address( + selector, + c.common.class_hash, + self.world_info.address, + )) + } + ResourceDiff::Updated(_, ResourceRemote::Contract(c)) => Some(c.common.address), + ResourceDiff::Synced(_, ResourceRemote::Contract(c)) => Some(c.common.address), + _ => unreachable!(), + } + } else { + None + } + } +} + +#[cfg(test)] +mod tests { + use starknet::core::types::Felt; + + use super::*; + use crate::config::NamespaceConfig; + use crate::local::{CommonLocalInfo, ContractLocal, NamespaceLocal, ResourceLocal, WorldLocal}; + use crate::remote::{CommonRemoteInfo, ContractRemote, NamespaceRemote}; + use crate::test_utils::empty_sierra_class; + + #[test] + fn test_world_diff_new() { + let ns = "ns".to_string(); + let namespace_config = NamespaceConfig::new(&ns); + let profile_config = ProfileConfig::new("test", "seed", namespace_config.clone()); + let mut local = WorldLocal::new(profile_config.clone()); + let mut remote = WorldRemote::default(); + // Add one class to the default remote as we simulate it already has some migrations. + remote.class_hashes.push(Felt::ONE); + + let local_contract = ResourceLocal::Contract(ContractLocal { + common: CommonLocalInfo { + name: "c".to_string(), + namespace: ns.clone(), + class: empty_sierra_class(), + class_hash: Felt::ONE, + casm_class_hash: Felt::ZERO, + }, + systems: vec![], + }); + + local.add_resource(local_contract.clone()); + + let diff = WorldDiff::new(local.clone(), remote.clone()); + + assert_eq!(diff.resources.len(), 2); + assert!(matches!( + diff.resources.get(&local_contract.dojo_selector()).unwrap(), + ResourceDiff::Created(_) + )); + + let remote_contract = ResourceRemote::Contract(ContractRemote { + common: CommonRemoteInfo::new(Felt::ONE, &ns, "c", Felt::ONE), + is_initialized: false, + }); + + remote.add_resource(remote_contract.clone()); + + let diff = WorldDiff::new(local.clone(), remote.clone()); + + assert_eq!(diff.resources.len(), 2); + assert!(matches!( + diff.resources.get(&local_contract.dojo_selector()).unwrap(), + ResourceDiff::Synced(_, _) + )); + + let mut local = WorldLocal::new(profile_config.clone()); + + let local_contract = ResourceLocal::Contract(ContractLocal { + common: CommonLocalInfo { + name: "c".to_string(), + namespace: ns.clone(), + class: empty_sierra_class(), + class_hash: Felt::TWO, + casm_class_hash: Felt::ZERO, + }, + systems: vec![], + }); + + local.add_resource(local_contract.clone()); + + let diff = WorldDiff::new(local.clone(), remote.clone()); + + assert_eq!(diff.resources.len(), 2); + assert!(matches!( + diff.resources.get(&local_contract.dojo_selector()).unwrap(), + ResourceDiff::Updated(_, _) + )); + } + + #[test] + fn test_world_diff_namespace() { + let ns = "ns".to_string(); + let namespace_config = NamespaceConfig::new(&ns); + let profile_config = ProfileConfig::new("test", "seed", namespace_config.clone()); + let mut local = WorldLocal::new(profile_config.clone()); + let mut remote = WorldRemote::default(); + // Add one class to the default remote as we simulate it already has some migrations. + remote.class_hashes.push(Felt::ONE); + + let local_namespace = + ResourceLocal::Namespace(NamespaceLocal { name: "namespace1".to_string() }); + + local.add_resource(local_namespace.clone()); + + let diff = WorldDiff::new(local.clone(), remote.clone()); + + for r in diff.resources.values() { + println!("{:?} {:?}", r.resource_type(), r.tag()); + } + + assert_eq!(diff.namespaces.len(), 2); + assert!(matches!( + diff.resources.get(&naming::compute_bytearray_hash("ns")).unwrap(), + ResourceDiff::Created(_) + )); + assert!(matches!( + diff.resources.get(&local_namespace.dojo_selector()).unwrap(), + ResourceDiff::Created(_) + )); + + let remote_namespace = ResourceRemote::Namespace(NamespaceRemote { + name: "namespace1".to_string(), + owners: HashSet::new(), + writers: HashSet::new(), + }); + + remote.add_resource(remote_namespace.clone()); + + let diff = WorldDiff::new(local.clone(), remote.clone()); + + assert_eq!(diff.namespaces.len(), 2); + assert!(matches!( + diff.resources.get(&naming::compute_bytearray_hash("ns")).unwrap(), + ResourceDiff::Created(_) + )); + assert!(matches!( + diff.resources.get(&local_namespace.dojo_selector()).unwrap(), + ResourceDiff::Synced(_, _) + )); + } +} diff --git a/crates/dojo/world/src/diff/resource.rs b/crates/dojo/world/src/diff/resource.rs new file mode 100644 index 0000000000..fc16320b54 --- /dev/null +++ b/crates/dojo/world/src/diff/resource.rs @@ -0,0 +1,110 @@ +use std::collections::HashSet; + +use starknet_crypto::Felt; + +use crate::local::ResourceLocal; +use crate::remote::ResourceRemote; +use crate::{ContractAddress, DojoSelector, ResourceType}; + +/// The difference between a local and a remote resource. +/// +/// The point of view is the local one. +/// Currently, having the remote resources that are not registered by the current project is not +/// supported, since a world can be permissionlessly updated by anyone. +#[derive(Debug)] +pub enum ResourceDiff { + /// The resource has been created locally, and is not present in the remote world. + Created(ResourceLocal), + /// The resource has been updated locally, and is different from the remote world. + Updated(ResourceLocal, ResourceRemote), + /// The local resource is in sync with the remote world. + Synced(ResourceLocal, ResourceRemote), +} + +#[derive(Debug)] +pub struct DiffPermissions { + /// The local permissions. + pub local: HashSet, + /// The remote permissions. + pub remote: HashSet, +} + +#[derive(Debug, PartialEq, Eq, Hash, Clone)] +pub struct PermissionGrantee { + /// The tag of the resource to grant permissions to. + /// The tag may not be present if the resource is not managed by the local project. + pub tag: Option, + /// The address of the grantee. + pub address: ContractAddress, +} + +impl DiffPermissions { + /// Returns the permissions that are only present locally. + pub fn only_local(&self) -> HashSet { + self.local.difference(&self.remote).cloned().collect() + } + + pub fn only_remote(&self) -> HashSet { + self.remote.difference(&self.local).cloned().collect() + } + + pub fn synced(&self) -> HashSet { + self.local.intersection(&self.remote).cloned().collect() + } +} + +impl ResourceDiff { + /// Returns the name of the resource. + pub fn name(&self) -> String { + match self { + ResourceDiff::Created(local) => local.name(), + ResourceDiff::Updated(local, _) => local.name(), + ResourceDiff::Synced(local, _) => local.name(), + } + } + + /// Returns the namespace of the resource. + pub fn namespace(&self) -> String { + match self { + ResourceDiff::Created(local) => local.namespace(), + ResourceDiff::Updated(local, _) => local.namespace(), + ResourceDiff::Synced(local, _) => local.namespace(), + } + } + + /// Returns the tag of the resource. + pub fn tag(&self) -> String { + match self { + ResourceDiff::Created(local) => local.tag(), + ResourceDiff::Updated(local, _) => local.tag(), + ResourceDiff::Synced(local, _) => local.tag(), + } + } + + /// Returns the dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + match self { + ResourceDiff::Created(local) => local.dojo_selector(), + ResourceDiff::Updated(local, _) => local.dojo_selector(), + ResourceDiff::Synced(local, _) => local.dojo_selector(), + } + } + + /// Returns the type of the resource. + pub fn resource_type(&self) -> ResourceType { + match self { + ResourceDiff::Created(local) => local.resource_type(), + ResourceDiff::Updated(local, _) => local.resource_type(), + ResourceDiff::Synced(local, _) => local.resource_type(), + } + } + + /// Returns the current class hash of the resource. + pub fn current_class_hash(&self) -> Felt { + match self { + ResourceDiff::Created(local) => local.class_hash(), + ResourceDiff::Updated(_, remote) => remote.current_class_hash(), + ResourceDiff::Synced(_, remote) => remote.current_class_hash(), + } + } +} diff --git a/crates/dojo/world/src/lib.rs b/crates/dojo/world/src/lib.rs new file mode 100644 index 0000000000..1b7dbae2d8 --- /dev/null +++ b/crates/dojo/world/src/lib.rs @@ -0,0 +1,29 @@ +#![warn(unused_crate_dependencies)] + +#[cfg(feature = "metadata")] +pub mod metadata; + +pub mod config; +pub mod contracts; +pub mod diff; +pub mod local; +pub mod remote; +pub mod uri; +pub mod utils; + +#[cfg(test)] +pub mod test_utils; + +// To avoid depending on cainome types or other crate, +// those aliases are mostly for readability. +pub type DojoSelector = starknet::core::types::Felt; +pub type ContractAddress = starknet::core::types::Felt; + +#[derive(Debug, PartialEq)] +pub enum ResourceType { + Namespace, + Contract, + Model, + Event, + StarknetContract, +} diff --git a/crates/dojo/world/src/local/artifact_to_local.rs b/crates/dojo/world/src/local/artifact_to_local.rs new file mode 100644 index 0000000000..8e70fb5ba3 --- /dev/null +++ b/crates/dojo/world/src/local/artifact_to_local.rs @@ -0,0 +1,287 @@ +//! Converts Scarb artifacts to local resources. + +use std::fs; +use std::path::Path; + +use anyhow::Result; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; +use serde_json; +use starknet::core::types::contract::{AbiEntry, AbiImpl, SierraClass}; +use starknet::core::types::Felt; +use tracing::trace; + +use super::*; +use crate::config::ProfileConfig; + +const WORLD_INTF: &str = "dojo::world::iworld::IWorld"; +const CONTRACT_INTF: &str = "dojo::contract::interface::IContract"; +const MODEL_INTF: &str = "dojo::model::interface::IModel"; +const EVENT_INTF: &str = "dojo::event::interface::IEvent"; + +impl WorldLocal { + pub fn from_directory>(dir: P, profile_config: ProfileConfig) -> Result { + let mut resources = vec![]; + + let mut world_class = None; + let mut world_class_hash = None; + let mut world_casm_class_hash = None; + + for entry in fs::read_dir(dir)? { + let entry = entry?; + let path = entry.path(); + if path.is_file() { + if let Ok(sierra) = + serde_json::from_reader::<_, SierraClass>(std::fs::File::open(&path)?) + { + let abi = sierra.abi.clone(); + let class_hash = sierra.class_hash()?; + let casm_class_hash = casm_class_hash_from_sierra_file(&path)?; + + let impls = abi + .iter() + .filter_map(|e| if let AbiEntry::Impl(i) = e { Some(i) } else { None }) + .collect::>(); + + // As a resource may be registered in multiple namespaces, currently the + // sierra class is being cloned for each namespace. Not ideal but keeping it + // simple for now. + for i in impls { + match identify_resource_type(i) { + ResourceType::World => { + world_class = Some(sierra); + world_class_hash = Some(class_hash); + world_casm_class_hash = Some(casm_class_hash); + break; + } + ResourceType::Contract(name) => { + let namespaces = profile_config.namespace.get_namespaces(&name); + + for ns in namespaces { + trace!( + name, + namespace = ns, + "Adding local contract from artifact." + ); + + let resource = ResourceLocal::Contract(ContractLocal { + common: CommonLocalInfo { + namespace: ns, + name: name.clone(), + class: sierra.clone(), + class_hash, + casm_class_hash, + }, + systems: vec![], + }); + + resources.push(resource); + } + break; + } + ResourceType::Model(name) => { + let namespaces = profile_config.namespace.get_namespaces(&name); + + for ns in namespaces { + trace!( + name, + namespace = ns, + "Adding local model from artifact." + ); + + let resource = ResourceLocal::Model(ModelLocal { + common: CommonLocalInfo { + namespace: ns, + name: name.clone(), + class: sierra.clone(), + class_hash, + casm_class_hash, + }, + members: vec![], + }); + + resources.push(resource); + } + break; + } + ResourceType::Event(name) => { + let namespaces = profile_config.namespace.get_namespaces(&name); + + for ns in namespaces { + trace!( + name, + namespace = ns, + "Adding local event from artifact." + ); + + let resource = ResourceLocal::Event(EventLocal { + common: CommonLocalInfo { + namespace: ns, + name: name.clone(), + class: sierra.clone(), + class_hash, + casm_class_hash, + }, + members: vec![], + }); + + resources.push(resource); + } + break; + } + ResourceType::Other => {} + } + } + } + } + } + + resources.push(ResourceLocal::Namespace(NamespaceLocal { + name: profile_config.namespace.default.clone(), + })); + + // Ensures all namespaces used as mapping key are registered as resources, + // if it's not the default namespace. + if let Some(mappings) = &profile_config.namespace.mappings { + for ns in mappings.keys() { + if ns != &profile_config.namespace.default { + resources.push(ResourceLocal::Namespace(NamespaceLocal { name: ns.clone() })); + } + } + } + + let mut world = match (world_class, world_class_hash, world_casm_class_hash) { + (Some(class), Some(class_hash), Some(casm_class_hash)) => Self { + class, + class_hash, + casm_class_hash, + resources: HashMap::new(), + profile_config, + }, + _ => { + return Err(anyhow::anyhow!( + "World artifact is missing, and required to deploy the world. Ensure you have \ + added the contract to your Scarb.toml file:\n\n + + [[target.starknet-contract]]\n + sierra = true\n + build-external-contracts = [\"dojo::world::world_contract::world\"]\n + " + )); + } + }; + + for resource in resources { + world.add_resource(resource); + } + + Ok(world) + } +} + +/// Computes the casm class hash from a Sierra file path. +fn casm_class_hash_from_sierra_file>(path: P) -> Result { + let bytecode_max_size = usize::MAX; + let sierra_class: ContractClass = + serde_json::from_reader::<_, ContractClass>(std::fs::File::open(path)?)?; + let casm_class = + CasmContractClass::from_contract_class(sierra_class, false, bytecode_max_size)?; + Ok(casm_class.compiled_class_hash()) +} + +/// A simple enum to identify the type of resource with their name. +#[derive(Debug, PartialEq)] +enum ResourceType { + World, + Contract(String), + Model(String), + Event(String), + Other, +} + +/// Identifies the type of resource from the ABI implementation. +fn identify_resource_type(implem: &AbiImpl) -> ResourceType { + if implem.interface_name == WORLD_INTF { + ResourceType::World + } else if implem.interface_name == CONTRACT_INTF { + ResourceType::Contract(name_from_impl(&implem.name)) + } else if implem.interface_name == MODEL_INTF { + ResourceType::Model(name_from_impl(&implem.name)) + } else if implem.interface_name == EVENT_INTF { + ResourceType::Event(name_from_impl(&implem.name)) + } else { + ResourceType::Other + } +} + +/// Extract the contract name from the `IContract`/`IModel`/`IEvent` implementation. +/// +/// Dojo lang always output the implementation with the name of the contract itself, with +/// a double underscore as separator. +fn name_from_impl(impl_name: &str) -> String { + impl_name.split("__").collect::>()[0].to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::config::NamespaceConfig; + + #[test] + fn test_name_from_impl() { + assert_eq!(name_from_impl("contract__MyImpl"), "contract"); + assert_eq!(name_from_impl("Model__MyModel"), "Model"); + assert_eq!(name_from_impl("Event__MyEvent"), "Event"); + } + + #[test] + fn test_identify_resource_type() { + assert_eq!( + identify_resource_type(&AbiImpl { + interface_name: WORLD_INTF.to_string(), + name: "IWorld".to_string() + }), + ResourceType::World + ); + + assert_eq!( + identify_resource_type(&AbiImpl { + interface_name: CONTRACT_INTF.to_string(), + name: "contract__DojoModelImpl".to_string() + }), + ResourceType::Contract("contract".to_string()) + ); + + assert_eq!( + identify_resource_type(&AbiImpl { + interface_name: MODEL_INTF.to_string(), + name: "Model__DojoModelImpl".to_string() + }), + ResourceType::Model("Model".to_string()) + ); + + assert_eq!( + identify_resource_type(&AbiImpl { + interface_name: EVENT_INTF.to_string(), + name: "Event__DojoEventImpl".to_string() + }), + ResourceType::Event("Event".to_string()) + ); + } + + #[ignore = "The simple example must be stabilized first (and built for this test to work)"] + #[test] + fn test_load_world_from_directory() { + let namespace_config = NamespaceConfig::new("dojo"); + let profile_config = ProfileConfig::new("test", "seed", namespace_config); + + let world = WorldLocal::from_directory( + "/Users/glihm/cgg/dojo/examples/simple/target/dev", + profile_config, + ) + .unwrap(); + + assert!(world.class_hash != Felt::ZERO); + assert_eq!(world.resources.len(), 3); + } +} diff --git a/crates/dojo/world/src/local/mod.rs b/crates/dojo/world/src/local/mod.rs new file mode 100644 index 0000000000..d24acb4a95 --- /dev/null +++ b/crates/dojo/world/src/local/mod.rs @@ -0,0 +1,183 @@ +//! Local resources for the world, gathered from the Scarb generated artifacts. +//! +//! When resources are compiled, there's no namespace attached to them. +//! However, to be registered and used in the world, they need to be namespaced. +//! To link a local resource to its world representation, a namespace configuration +//! is needed. +//! +//! Class hashes are cached into the resource to avoid recomputing them when +//! requesting it. + +use std::collections::HashMap; + +use dojo_types::naming; +use starknet::core::types::contract::SierraClass; +use starknet::core::types::Felt; +use starknet::core::utils::CairoShortStringToFeltError; + +mod artifact_to_local; +mod resource; + +pub use resource::*; + +use crate::config::ProfileConfig; +use crate::utils::compute_world_address; +use crate::{ContractAddress, DojoSelector}; + +#[derive(Debug, Clone)] +pub struct WorldLocal { + /// The class of the world. + pub class: SierraClass, + /// The class hash of the world. + pub class_hash: Felt, + /// The casm class hash of the world. + pub casm_class_hash: Felt, + /// The resources of the world. + pub resources: HashMap, + /// The profile configuration of the local world. + pub profile_config: ProfileConfig, +} + +#[cfg(test)] +impl Default for WorldLocal { + fn default() -> Self { + use starknet::core::types::contract::{SierraClass, SierraClassDebugInfo}; + use starknet::core::types::EntryPointsByType; + + Self { + class: SierraClass { + sierra_program: Vec::new(), + sierra_program_debug_info: SierraClassDebugInfo { + type_names: Vec::new(), + libfunc_names: Vec::new(), + user_func_names: Vec::new(), + }, + contract_class_version: "".to_string(), + entry_points_by_type: EntryPointsByType { + constructor: Vec::new(), + external: Vec::new(), + l1_handler: Vec::new(), + }, + abi: Vec::new(), + }, + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + resources: HashMap::new(), + profile_config: ProfileConfig::default(), + } + } +} + +impl WorldLocal { + #[cfg(test)] + /// Initializes a new world with namespaces from the profile configuration. + pub fn new(profile_config: ProfileConfig) -> Self { + let mut world = Self { profile_config: profile_config.clone(), ..Default::default() }; + + world.add_resource(ResourceLocal::Namespace(NamespaceLocal { + name: profile_config.namespace.default, + })); + + if let Some(mappings) = &profile_config.namespace.mappings { + for ns in mappings.keys() { + world.add_resource(ResourceLocal::Namespace(NamespaceLocal { name: ns.clone() })); + } + } + + world + } + + /// Computes the deterministic address of the world contract. + pub fn deterministic_world_address(&self) -> Result { + let class_hash = self.class_hash; + compute_world_address(&self.profile_config.world.seed, class_hash) + } + + /// Adds a resource to the world local. + pub fn add_resource(&mut self, resource: ResourceLocal) { + if let ResourceLocal::Namespace(namespace) = &resource { + let selector = naming::compute_bytearray_hash(&namespace.name); + self.resources.insert(selector, resource); + return; + } + + self.resources.insert(resource.dojo_selector(), resource); + } + + /// Returns the contract resource, if any. + pub fn get_contract_resource(&self, selector: DojoSelector) -> Option<&ContractLocal> { + self.resources.get(&selector).and_then(|r| r.as_contract()) + } + + /// Gets the deterministic contract address only based on local information. + pub fn get_contract_address_local(&self, selector: DojoSelector) -> Option { + let contract = self.get_contract_resource(selector)?; + Some(crate::utils::compute_dojo_contract_address( + selector, + contract.common.class_hash, + self.deterministic_world_address().unwrap(), + )) + } + + /// Returns the resource from a name or tag. + pub fn resource_from_name_or_tag(&self, name_or_tag: &str) -> Option<&ResourceLocal> { + let selector = if naming::is_valid_tag(name_or_tag) { + naming::compute_selector_from_tag(name_or_tag) + } else { + naming::compute_bytearray_hash(name_or_tag) + }; + + self.resources.get(&selector) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::config::NamespaceConfig; + use crate::test_utils::empty_sierra_class; + + #[test] + fn test_add_resource() { + let profile_config = ProfileConfig::new("test", "seed", NamespaceConfig::new("dojo")); + let mut world = WorldLocal::new(profile_config); + + assert_eq!(world.resources.len(), 1); + + let n = world.resources.get(&naming::compute_bytearray_hash("dojo")).unwrap(); + assert_eq!(n.name(), "dojo"); + + world.add_resource(ResourceLocal::Contract(ContractLocal { + common: CommonLocalInfo { + name: "c1".to_string(), + namespace: "dojo".to_string(), + class: empty_sierra_class(), + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + }, + systems: vec![], + })); + + let selector = naming::compute_selector_from_names("dojo", "c1"); + + assert_eq!(world.resources.len(), 2); + assert!(world.get_contract_resource(selector).is_some()); + + world.add_resource(ResourceLocal::Contract(ContractLocal { + common: CommonLocalInfo { + name: "c2".to_string(), + namespace: "dojo".to_string(), + class: empty_sierra_class(), + class_hash: Felt::ZERO, + casm_class_hash: Felt::ZERO, + }, + systems: vec![], + })); + + let selector2 = naming::compute_selector_from_names("dojo", "c2"); + + assert_eq!(world.resources.len(), 3); + assert!(world.get_contract_resource(selector).is_some()); + assert!(world.get_contract_resource(selector2).is_some()); + } +} diff --git a/crates/dojo/world/src/local/resource.rs b/crates/dojo/world/src/local/resource.rs new file mode 100644 index 0000000000..f40b1fd54f --- /dev/null +++ b/crates/dojo/world/src/local/resource.rs @@ -0,0 +1,146 @@ +use dojo_types::naming; +use starknet::core::types::contract::SierraClass; +use starknet::core::types::Felt; + +use crate::{DojoSelector, ResourceType}; + +/// A local resource. +#[derive(Debug, Clone)] +pub enum ResourceLocal { + Namespace(NamespaceLocal), + Contract(ContractLocal), + Model(ModelLocal), + Event(EventLocal), +} + +/// Common information about a world's resource. +#[derive(Debug, Clone)] +pub struct CommonLocalInfo { + /// The name of the contract. + pub name: String, + /// The namespace used to register the resource remotely. + pub namespace: String, + /// The class of the resource. + pub class: SierraClass, + /// The class hash of the resource. + pub class_hash: Felt, + /// The casm class hash of the resource. + pub casm_class_hash: Felt, +} + +#[derive(Debug, Clone)] +pub struct ContractLocal { + /// Common information about the resource. + pub common: CommonLocalInfo, + /// The systems of the contract. + pub systems: Vec, +} + +#[derive(Debug, Clone)] +pub struct ModelLocal { + /// Common information about the resource. + pub common: CommonLocalInfo, + /// The members of the model. + pub members: Vec, +} + +#[derive(Debug, Clone)] +pub struct EventLocal { + /// Common information about the resource. + pub common: CommonLocalInfo, + /// The members of the event. + pub members: Vec, +} + +#[derive(Debug, Clone)] +pub struct NamespaceLocal { + /// The name of the namespace. + pub name: String, +} + +/// Represents a struct resource like member and event. +#[derive(Debug, Clone)] +pub struct Member { + /// Name of the member. + pub name: String, + /// Type of the member. + pub ty: String, + /// Whether the member is a key. + pub key: bool, +} + +impl ResourceLocal { + /// Returns the name of the resource. + pub fn name(&self) -> String { + match self { + ResourceLocal::Contract(c) => c.common.name.clone(), + ResourceLocal::Model(m) => m.common.name.clone(), + ResourceLocal::Event(e) => e.common.name.clone(), + ResourceLocal::Namespace(n) => n.name.clone(), + } + } + + /// Returns the namespace of the resource. + pub fn namespace(&self) -> String { + match self { + ResourceLocal::Namespace(n) => n.name.clone(), + ResourceLocal::Contract(c) => c.common.namespace.clone(), + ResourceLocal::Model(m) => m.common.namespace.clone(), + ResourceLocal::Event(e) => e.common.namespace.clone(), + } + } + + /// Returns the class hash of the resource. + pub fn class_hash(&self) -> Felt { + match self { + ResourceLocal::Contract(c) => c.common.class_hash, + ResourceLocal::Model(m) => m.common.class_hash, + ResourceLocal::Event(e) => e.common.class_hash, + _ => Felt::ZERO, + } + } + + /// Returns the dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + match self { + ResourceLocal::Namespace(n) => naming::compute_bytearray_hash(&n.name), + _ => naming::compute_selector_from_names(&self.namespace(), &self.name()), + } + } + + /// Returns the tag of the resource. + pub fn tag(&self) -> String { + match self { + ResourceLocal::Namespace(n) => n.name.clone(), + _ => naming::get_tag(&self.namespace(), &self.name()), + } + } + + /// Returns the contract resource. + /// + /// This function panics since it must only be used where the developer + /// can ensure that the resource is a contract. + pub fn as_contract(&self) -> Option<&ContractLocal> { + match self { + ResourceLocal::Contract(c) => Some(c), + _ => None, + } + } + + /// Returns the type of the resource. + pub fn resource_type(&self) -> ResourceType { + match self { + ResourceLocal::Contract(_) => ResourceType::Contract, + ResourceLocal::Model(_) => ResourceType::Model, + ResourceLocal::Event(_) => ResourceType::Event, + ResourceLocal::Namespace(_) => ResourceType::Namespace, + } + } +} + +impl ContractLocal { + /// Returns the dojo selector of the contract. + pub fn dojo_selector(&self) -> DojoSelector { + naming::compute_selector_from_names(&self.common.namespace, &self.common.name) + } +} diff --git a/crates/dojo/world/src/metadata/metadata_test.rs b/crates/dojo/world/src/metadata/metadata_test.rs new file mode 100644 index 0000000000..cfedcfe191 --- /dev/null +++ b/crates/dojo/world/src/metadata/metadata_test.rs @@ -0,0 +1,34 @@ +// use std::collections::HashMap; +// use std::fs; +// +// use camino::Utf8PathBuf; +// use dojo_test_utils::compiler; +// use scarb::compiler::Profile; +// use scarb::ops; +// use url::Url; +// +// use crate::contracts::naming::{get_filename_from_tag, TAG_SEPARATOR}; +// use crate::manifest::{CONTRACTS_DIR, MODELS_DIR, WORLD_CONTRACT_TAG}; +// use crate::metadata::{ +// dojo_metadata_from_workspace, ArtifactMetadata, Uri, WorldMetadata, ABIS_DIR, BASE_DIR, +// MANIFESTS_DIR, +// }; +// +// #[tokio::test] +// async fn world_metadata_hash_and_upload() { +// let meta = WorldMetadata { +// name: "Test World".to_string(), +// seed: String::from("dojo_examples"), +// description: Some("A world used for testing".to_string()), +// cover_uri: Some(Uri::File("src/metadata/metadata_test_data/cover.png".into())), +// icon_uri: Some(Uri::File("src/metadata/metadata_test_data/cover.png".into())), +// website: Some(Url::parse("https://dojoengine.org").unwrap()), +// socials: Some(HashMap::from([("x".to_string(), "https://x.com/dojostarknet".to_string())])), +// artifacts: ArtifactMetadata { +// abi: Some(Uri::File("src/metadata_test_data/abi.json".into())), +// source: Some(Uri::File("src/metadata_test_data/source.cairo".into())), +// }, +// }; +// +// let _ = meta.upload().await.unwrap(); +// } diff --git a/crates/dojo-world/src/metadata_test_data/abi.json b/crates/dojo/world/src/metadata/metadata_test_data/abi.json similarity index 100% rename from crates/dojo-world/src/metadata_test_data/abi.json rename to crates/dojo/world/src/metadata/metadata_test_data/abi.json diff --git a/crates/dojo-world/src/metadata_test_data/cover.png b/crates/dojo/world/src/metadata/metadata_test_data/cover.png similarity index 100% rename from crates/dojo-world/src/metadata_test_data/cover.png rename to crates/dojo/world/src/metadata/metadata_test_data/cover.png diff --git a/crates/dojo-world/src/metadata_test_data/source.cairo b/crates/dojo/world/src/metadata/metadata_test_data/source.cairo similarity index 100% rename from crates/dojo-world/src/metadata_test_data/source.cairo rename to crates/dojo/world/src/metadata/metadata_test_data/source.cairo diff --git a/crates/dojo/world/src/metadata/mod.rs b/crates/dojo/world/src/metadata/mod.rs new file mode 100644 index 0000000000..16a61c9701 --- /dev/null +++ b/crates/dojo/world/src/metadata/mod.rs @@ -0,0 +1,3 @@ +//! Metadata for the world. + +pub mod world; diff --git a/crates/dojo/world/src/metadata/world.rs b/crates/dojo/world/src/metadata/world.rs new file mode 100644 index 0000000000..be76c31f6a --- /dev/null +++ b/crates/dojo/world/src/metadata/world.rs @@ -0,0 +1,44 @@ +use std::io::Cursor; + +use anyhow::Result; +use ipfs_api_backend_hyper::{IpfsApi, IpfsClient, TryFromUri}; +use serde_json::json; + +use crate::config::metadata_config::WorldMetadata; +use crate::uri::Uri; + +#[cfg(test)] +#[path = "metadata_test.rs"] +mod test; + +pub const IPFS_CLIENT_URL: &str = "https://ipfs.infura.io:5001"; +pub const IPFS_USERNAME: &str = "2EBrzr7ZASQZKH32sl2xWauXPSA"; +pub const IPFS_PASSWORD: &str = "12290b883db9138a8ae3363b6739d220"; + +impl WorldMetadata { + pub async fn upload(&self) -> Result { + let mut meta = self.clone(); + let client = + IpfsClient::from_str(IPFS_CLIENT_URL)?.with_credentials(IPFS_USERNAME, IPFS_PASSWORD); + + if let Some(Uri::File(icon)) = &self.icon_uri { + let icon_data = std::fs::read(icon)?; + let reader = Cursor::new(icon_data); + let response = client.add(reader).await?; + meta.icon_uri = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) + }; + + if let Some(Uri::File(cover)) = &self.cover_uri { + let cover_data = std::fs::read(cover)?; + let reader = Cursor::new(cover_data); + let response = client.add(reader).await?; + meta.cover_uri = Some(Uri::Ipfs(format!("ipfs://{}", response.hash))) + }; + + let serialized = json!(meta).to_string(); + let reader = Cursor::new(serialized); + let response = client.add(reader).await?; + + Ok(response.hash) + } +} diff --git a/crates/dojo/world/src/remote/events_to_remote.rs b/crates/dojo/world/src/remote/events_to_remote.rs new file mode 100644 index 0000000000..c85834eefe --- /dev/null +++ b/crates/dojo/world/src/remote/events_to_remote.rs @@ -0,0 +1,498 @@ +//! Fetches the events for the given world address and converts them to remote resources. +//! +//! The world is responsible for managing the remote resources onchain. We are expected +//! to safely unwrap the resources lookup as they are supposed to exist. +//! +//! Events are also sequential, a resource is not expected to be upgraded before +//! being registered. We take advantage of this fact to optimize the data gathering. + +use anyhow::Result; +use starknet::core::types::{BlockId, BlockTag, EventFilter, Felt, StarknetError}; +use starknet::providers::{Provider, ProviderError}; +use tracing::trace; + +use super::permissions::PermissionsUpdateable; +use super::{ResourceRemote, WorldRemote}; +use crate::contracts::abigen::world::{self, Event as WorldEvent}; +use crate::remote::{CommonRemoteInfo, ContractRemote, EventRemote, ModelRemote, NamespaceRemote}; + +impl WorldRemote { + /// Fetch the events from the world and convert them to remote resources. + #[allow(clippy::field_reassign_with_default)] + pub async fn from_events(world_address: Felt, provider: &P) -> Result { + let mut world = Self::default(); + + world.address = world_address; + + match provider.get_class_hash_at(BlockId::Tag(BlockTag::Pending), world_address).await { + Ok(_) => { + // The world contract exists, we can continue and fetch the events. + } + Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { + tracing::trace!(%world_address, "No remote world contract found."); + return Ok(world); + } + Err(e) => return Err(e.into()), + }; + + // We only care about management events, not resource events (set, delete, emit). + let keys = vec![vec![ + world::WorldSpawned::event_selector(), + world::WorldUpgraded::event_selector(), + world::NamespaceRegistered::event_selector(), + world::ModelRegistered::event_selector(), + world::EventRegistered::event_selector(), + world::ContractRegistered::event_selector(), + world::ModelUpgraded::event_selector(), + world::EventUpgraded::event_selector(), + world::ContractUpgraded::event_selector(), + world::ContractInitialized::event_selector(), + world::WriterUpdated::event_selector(), + world::OwnerUpdated::event_selector(), + ]]; + + let filter = EventFilter { + from_block: None, + to_block: Some(BlockId::Tag(BlockTag::Pending)), + address: Some(world_address), + keys: Some(keys), + }; + + let chunk_size = 500; + + tracing::trace!( + world_address = format!("{:#066x}", world_address), + chunk_size, + ?filter, + "Fetching remote world events." + ); + + let mut events = Vec::new(); + + // Initial fetch. + let page = provider.get_events(filter.clone(), None, chunk_size).await?; + events.extend(page.events); + + let mut continuation_token = page.continuation_token; + + while continuation_token.is_some() { + let page = provider.get_events(filter.clone(), continuation_token, chunk_size).await?; + + // TODO: remove this once rebased with latest katana. + if page.events.is_empty() { + break; + } + + continuation_token = page.continuation_token; + events.extend(page.events); + } + + for event in &events { + match world::Event::try_from(event) { + Ok(ev) => { + tracing::trace!(?ev, "Processing world event."); + world.match_event(ev)?; + } + Err(e) => { + tracing::error!( + ?e, + "Failed to parse remote world event which is supposed to be valid." + ); + } + } + } + + Ok(world) + } + + /// Matches the given event to the corresponding remote resource and inserts it into the world. + fn match_event(&mut self, event: WorldEvent) -> Result<()> { + match event { + WorldEvent::WorldSpawned(e) => { + self.class_hashes.push(e.class_hash.into()); + + trace!(class_hash = format!("{:#066x}", e.class_hash.0), "World spawned."); + } + WorldEvent::WorldUpgraded(e) => { + self.class_hashes.push(e.class_hash.into()); + + trace!(class_hash = format!("{:#066x}", e.class_hash.0), "World upgraded."); + } + WorldEvent::NamespaceRegistered(e) => { + let r = ResourceRemote::Namespace(NamespaceRemote::new(e.namespace.to_string()?)); + trace!(?r, "Namespace registered."); + + self.add_resource(r); + } + WorldEvent::ModelRegistered(e) => { + let r = ResourceRemote::Model(ModelRemote { + common: CommonRemoteInfo::new( + e.class_hash.into(), + &e.namespace.to_string()?, + &e.name.to_string()?, + e.address.into(), + ), + }); + trace!(?r, "Model registered."); + + self.add_resource(r); + } + WorldEvent::EventRegistered(e) => { + let r = ResourceRemote::Event(EventRemote { + common: CommonRemoteInfo::new( + e.class_hash.into(), + &e.namespace.to_string()?, + &e.name.to_string()?, + e.address.into(), + ), + }); + trace!(?r, "Event registered."); + + self.add_resource(r); + } + WorldEvent::ContractRegistered(e) => { + let r = ResourceRemote::Contract(ContractRemote { + common: CommonRemoteInfo::new( + e.class_hash.into(), + &e.namespace.to_string()?, + &e.name.to_string()?, + e.address.into(), + ), + is_initialized: false, + }); + trace!(?r, "Contract registered."); + + self.add_resource(r); + } + WorldEvent::ModelUpgraded(e) => { + // Unwrap is safe because the model must exist in the world. + let resource = self.resources.get_mut(&e.selector).unwrap(); + trace!(?resource, "Model upgraded."); + + resource.push_class_hash(e.class_hash.into()); + } + WorldEvent::EventUpgraded(e) => { + // Unwrap is safe because the event must exist in the world. + let resource = self.resources.get_mut(&e.selector).unwrap(); + trace!(?resource, "Event upgraded."); + + resource.push_class_hash(e.class_hash.into()); + } + WorldEvent::ContractUpgraded(e) => { + // Unwrap is safe because the contract must exist in the world. + let resource = self.resources.get_mut(&e.selector).unwrap(); + trace!(?resource, "Contract upgraded."); + + resource.push_class_hash(e.class_hash.into()); + } + WorldEvent::ContractInitialized(e) => { + // Unwrap is safe bcause the contract must exist in the world. + let resource = self.resources.get_mut(&e.selector).unwrap(); + let contract = resource.as_contract_mut()?; + contract.is_initialized = true; + + trace!( + selector = format!("{:#066x}", e.selector), + init_calldata = format!("{:?}", e.init_calldata), + "Contract initialized." + ); + } + WorldEvent::WriterUpdated(e) => { + // The resource may not be managed by the local project. + if let Some(resource) = self.resources.get_mut(&e.resource) { + resource.update_writer(e.contract.into(), e.value)?; + } else { + let entry = self.external_writers.entry(e.resource).or_default(); + + if e.value { + entry.insert(e.contract.into()); + } else { + entry.remove(&e.contract.into()); + } + } + + trace!(?e, "Writer updated."); + } + WorldEvent::OwnerUpdated(e) => { + // The resource may not be managed by the local project. + if let Some(resource) = self.resources.get_mut(&e.resource) { + resource.update_owner(e.contract.into(), e.value)?; + } else { + let entry = self.external_owners.entry(e.resource).or_default(); + + if e.value { + entry.insert(e.contract.into()); + } else { + entry.remove(&e.contract.into()); + } + } + + trace!(?e, "Owner updated."); + } + _ => { + // Ignore events filtered out by the event filter. + } + } + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + + use cainome::cairo_serde::ByteArray; + use dojo_types::naming; + + use super::*; + + #[tokio::test] + async fn test_world_spawned_event() { + let mut world_remote = WorldRemote::default(); + let event = WorldEvent::WorldSpawned(world::WorldSpawned { + class_hash: Felt::ONE.into(), + creator: Felt::ONE.into(), + }); + + world_remote.match_event(event).unwrap(); + assert_eq!(world_remote.class_hashes.len(), 1); + } + + #[tokio::test] + async fn test_world_upgraded_event() { + let mut world_remote = WorldRemote::default(); + let event = + WorldEvent::WorldUpgraded(world::WorldUpgraded { class_hash: Felt::ONE.into() }); + + world_remote.match_event(event).unwrap(); + assert_eq!(world_remote.class_hashes.len(), 1); + } + + #[tokio::test] + async fn test_namespace_registered_event() { + let mut world_remote = WorldRemote::default(); + let event = WorldEvent::NamespaceRegistered(world::NamespaceRegistered { + namespace: ByteArray::from_string("ns").unwrap(), + hash: 123.into(), + }); + + world_remote.match_event(event).unwrap(); + + let selector = naming::compute_bytearray_hash("ns"); + assert!(world_remote.resources.contains_key(&selector)); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert!(matches!(resource, ResourceRemote::Namespace(_))); + } + + #[tokio::test] + async fn test_model_registered_event() { + let mut world_remote = WorldRemote::default(); + let event = WorldEvent::ModelRegistered(world::ModelRegistered { + class_hash: Felt::ONE.into(), + name: ByteArray::from_string("m").unwrap(), + address: Felt::ONE.into(), + namespace: ByteArray::from_string("ns").unwrap(), + }); + + world_remote.match_event(event).unwrap(); + let selector = naming::compute_selector_from_names("ns", "m"); + assert!(world_remote.resources.contains_key(&selector)); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert!(matches!(resource, ResourceRemote::Model(_))); + } + + #[tokio::test] + async fn test_event_registered_event() { + let mut world_remote = WorldRemote::default(); + let event = WorldEvent::EventRegistered(world::EventRegistered { + class_hash: Felt::ONE.into(), + name: ByteArray::from_string("e").unwrap(), + address: Felt::ONE.into(), + namespace: ByteArray::from_string("ns").unwrap(), + }); + + world_remote.match_event(event).unwrap(); + let selector = naming::compute_selector_from_names("ns", "e"); + assert!(world_remote.resources.contains_key(&selector)); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert!(matches!(resource, ResourceRemote::Event(_))); + } + + #[tokio::test] + async fn test_contract_registered_event() { + let mut world_remote = WorldRemote::default(); + let event = WorldEvent::ContractRegistered(world::ContractRegistered { + class_hash: Felt::ONE.into(), + name: ByteArray::from_string("c").unwrap(), + address: Felt::ONE.into(), + namespace: ByteArray::from_string("ns").unwrap(), + salt: Felt::ONE, + }); + + world_remote.match_event(event).unwrap(); + let selector = naming::compute_selector_from_names("ns", "c"); + assert!(world_remote.resources.contains_key(&selector)); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert!(matches!(resource, ResourceRemote::Contract(_))); + } + + #[tokio::test] + async fn test_model_upgraded_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_selector_from_names("ns", "m"); + + let resource = ResourceRemote::Model(ModelRemote { + common: CommonRemoteInfo::new(Felt::ONE, "ns", "m", Felt::ONE), + }); + + world_remote.add_resource(resource); + + let event = WorldEvent::ModelUpgraded(world::ModelUpgraded { + selector, + class_hash: Felt::TWO.into(), + address: Felt::ONE.into(), + prev_address: Felt::ONE.into(), + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_model_or_panic().common.class_hashes, vec![Felt::ONE, Felt::TWO]); + } + + #[tokio::test] + async fn test_event_upgraded_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_selector_from_names("ns", "e"); + + let resource = ResourceRemote::Event(EventRemote { + common: CommonRemoteInfo::new(Felt::ONE, "ns", "e", Felt::ONE), + }); + + world_remote.add_resource(resource); + + let event = WorldEvent::EventUpgraded(world::EventUpgraded { + selector, + class_hash: Felt::TWO.into(), + address: Felt::ONE.into(), + prev_address: Felt::ONE.into(), + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_event_or_panic().common.class_hashes, vec![Felt::ONE, Felt::TWO]); + } + + #[tokio::test] + async fn test_contract_upgraded_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_selector_from_names("ns", "c"); + + let resource = ResourceRemote::Contract(ContractRemote { + common: CommonRemoteInfo::new(Felt::ONE, "ns", "c", Felt::ONE), + is_initialized: false, + }); + + world_remote.add_resource(resource); + + let event = WorldEvent::ContractUpgraded(world::ContractUpgraded { + selector, + class_hash: Felt::TWO.into(), + }); + + world_remote.match_event(event).unwrap(); + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_contract_or_panic().common.class_hashes, vec![Felt::ONE, Felt::TWO]); + } + + #[tokio::test] + async fn test_contract_initialized_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_selector_from_names("ns", "c"); + + let resource = ResourceRemote::Contract(ContractRemote { + common: CommonRemoteInfo::new(Felt::ONE, "ns", "c", Felt::ONE), + is_initialized: false, + }); + + world_remote.add_resource(resource); + + let event = WorldEvent::ContractInitialized(world::ContractInitialized { + selector, + init_calldata: vec![], + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert!(resource.as_contract_or_panic().is_initialized); + } + + #[tokio::test] + async fn test_writer_updated_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_bytearray_hash("ns"); + + let resource = ResourceRemote::Namespace(NamespaceRemote::new("ns".to_string())); + world_remote.add_resource(resource); + + let event = WorldEvent::WriterUpdated(world::WriterUpdated { + resource: selector, + contract: Felt::ONE.into(), + value: true, + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_namespace_or_panic().writers, HashSet::from([Felt::ONE])); + + let event = WorldEvent::WriterUpdated(world::WriterUpdated { + resource: selector, + contract: Felt::ONE.into(), + value: false, + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_namespace_or_panic().writers, HashSet::from([])); + } + + #[tokio::test] + async fn test_owner_updated_event() { + let mut world_remote = WorldRemote::default(); + let selector = naming::compute_bytearray_hash("ns"); + + let resource = ResourceRemote::Namespace(NamespaceRemote::new("ns".to_string())); + world_remote.add_resource(resource); + + let event = WorldEvent::OwnerUpdated(world::OwnerUpdated { + resource: selector, + contract: Felt::ONE.into(), + value: true, + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_namespace_or_panic().owners, HashSet::from([Felt::ONE])); + + let event = WorldEvent::OwnerUpdated(world::OwnerUpdated { + resource: selector, + contract: Felt::ONE.into(), + value: false, + }); + + world_remote.match_event(event).unwrap(); + + let resource = world_remote.resources.get(&selector).unwrap(); + assert_eq!(resource.as_namespace_or_panic().owners, HashSet::from([])); + } +} diff --git a/crates/dojo/world/src/remote/mod.rs b/crates/dojo/world/src/remote/mod.rs new file mode 100644 index 0000000000..8a6dc15405 --- /dev/null +++ b/crates/dojo/world/src/remote/mod.rs @@ -0,0 +1,112 @@ +//! Remote resources for the world, gathered from events emitted by the world at the given address. +//! +//! A remote resource must be reconstructible form the onchain world without any additional +//! information. +//! +//! Remote resources are coupled to the namespace used to register them. No resource can be +//! registered without a namespace (excepting namespaces themselves). + +use std::collections::{HashMap, HashSet}; + +use starknet::core::types::Felt; + +mod events_to_remote; +mod permissions; +mod resource; + +pub use resource::*; + +use crate::{ContractAddress, DojoSelector}; + +/// The remote world representation. +#[derive(Debug, Default, Clone)] +pub struct WorldRemote { + /// The world's address used to build the remote world. + pub address: Felt, + /// The class hashes of the world. + pub class_hashes: Vec, + /// The resources of the world, by dojo selector. + pub resources: HashMap, + /// Writers to resources that are not managed by the local project. + pub external_writers: HashMap>, + /// Owners of resources that are not managed by the local project. + pub external_owners: HashMap>, +} + +impl WorldRemote { + /// Adds a resource to the world. + pub fn add_resource(&mut self, resource: ResourceRemote) { + self.resources.insert(resource.dojo_selector(), resource); + } + + /// Returns the current class hash of the world. + pub fn current_class_hash(&self) -> Felt { + *self.class_hashes.last().expect("Remote world must have at least one class hash.") + } +} + +#[cfg(test)] +mod tests { + use dojo_types::naming; + + use super::*; + + #[test] + fn test_add_contract_resource() { + let mut world_remote = WorldRemote::default(); + let namespace = "ns".to_string(); + + let contract = ContractRemote { + common: CommonRemoteInfo::new(Felt::ONE, &namespace, "c", Felt::ONE), + is_initialized: false, + }; + let resource = ResourceRemote::Contract(contract); + + world_remote.add_resource(resource); + + let selector = naming::compute_selector_from_names("ns", "c"); + assert!(world_remote.resources.contains_key(&selector)); + } + + #[test] + fn test_add_model_resource() { + let mut world_remote = WorldRemote::default(); + let namespace = "ns".to_string(); + + let model = + ModelRemote { common: CommonRemoteInfo::new(Felt::ONE, &namespace, "m", Felt::ONE) }; + let resource = ResourceRemote::Model(model); + + world_remote.add_resource(resource); + + let selector = naming::compute_selector_from_names("ns", "m"); + assert!(world_remote.resources.contains_key(&selector)); + } + + #[test] + fn test_add_event_resource() { + let mut world_remote = WorldRemote::default(); + let namespace = "ns".to_string(); + + let event = + EventRemote { common: CommonRemoteInfo::new(Felt::ONE, &namespace, "e", Felt::ONE) }; + let resource = ResourceRemote::Event(event); + + world_remote.add_resource(resource); + + let selector = naming::compute_selector_from_names("ns", "e"); + assert!(world_remote.resources.contains_key(&selector)); + } + + #[test] + fn test_add_namespace_resource() { + let mut world_remote = WorldRemote::default(); + let namespace = NamespaceRemote::new("ns".to_string()); + let resource = ResourceRemote::Namespace(namespace); + + world_remote.add_resource(resource); + + let selector = naming::compute_bytearray_hash("ns"); + assert!(world_remote.resources.contains_key(&selector)); + } +} diff --git a/crates/dojo/world/src/remote/permissions.rs b/crates/dojo/world/src/remote/permissions.rs new file mode 100644 index 0000000000..8ac6ecafc8 --- /dev/null +++ b/crates/dojo/world/src/remote/permissions.rs @@ -0,0 +1,113 @@ +//! Manages the permissions loaded from the remote world. + +use anyhow::Result; + +use super::{ + CommonRemoteInfo, ContractRemote, EventRemote, ModelRemote, NamespaceRemote, ResourceRemote, +}; +use crate::ContractAddress; + +pub trait PermissionsUpdateable { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()>; + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()>; +} + +impl PermissionsUpdateable for CommonRemoteInfo { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + if is_writer { + self.writers.insert(contract_address); + } else { + self.writers.remove(&contract_address); + } + + Ok(()) + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + if is_owner { + self.owners.insert(contract_address); + } else { + self.owners.remove(&contract_address); + } + + Ok(()) + } +} + +impl PermissionsUpdateable for ContractRemote { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + self.common.update_writer(contract_address, is_writer) + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + self.common.update_owner(contract_address, is_owner) + } +} + +impl PermissionsUpdateable for ModelRemote { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + self.common.update_writer(contract_address, is_writer) + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + self.common.update_owner(contract_address, is_owner) + } +} + +impl PermissionsUpdateable for EventRemote { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + self.common.update_writer(contract_address, is_writer) + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + self.common.update_owner(contract_address, is_owner) + } +} + +impl PermissionsUpdateable for NamespaceRemote { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + if is_writer { + self.writers.insert(contract_address); + } else { + self.writers.remove(&contract_address); + } + + Ok(()) + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + if is_owner { + self.owners.insert(contract_address); + } else { + self.owners.remove(&contract_address); + } + + Ok(()) + } +} + +impl PermissionsUpdateable for ResourceRemote { + fn update_writer(&mut self, contract_address: ContractAddress, is_writer: bool) -> Result<()> { + match self { + ResourceRemote::Contract(contract) => { + contract.update_writer(contract_address, is_writer) + } + ResourceRemote::Model(model) => model.update_writer(contract_address, is_writer), + ResourceRemote::Event(event) => event.update_writer(contract_address, is_writer), + ResourceRemote::Namespace(namespace) => { + namespace.update_writer(contract_address, is_writer) + } + } + } + + fn update_owner(&mut self, contract_address: ContractAddress, is_owner: bool) -> Result<()> { + match self { + ResourceRemote::Contract(contract) => contract.update_owner(contract_address, is_owner), + ResourceRemote::Model(model) => model.update_owner(contract_address, is_owner), + ResourceRemote::Event(event) => event.update_owner(contract_address, is_owner), + ResourceRemote::Namespace(namespace) => { + namespace.update_owner(contract_address, is_owner) + } + } + } +} diff --git a/crates/dojo/world/src/remote/resource.rs b/crates/dojo/world/src/remote/resource.rs new file mode 100644 index 0000000000..b44e217db5 --- /dev/null +++ b/crates/dojo/world/src/remote/resource.rs @@ -0,0 +1,269 @@ +use std::collections::HashSet; + +use anyhow::Result; +use dojo_types::naming; +use starknet::core::types::Felt; + +use crate::{ContractAddress, DojoSelector, ResourceType}; + +/// A remote resource that can be fetched from the world. +#[derive(Debug, Clone)] +pub enum ResourceRemote { + Namespace(NamespaceRemote), + Contract(ContractRemote), + Model(ModelRemote), + Event(EventRemote), + // TODO: add starknet contract remote. Sozo needs a way to keep track of the address of this + // contract once deployed. +} + +/// Common information about a world's resource. +#[derive(Debug, Clone)] +pub struct CommonRemoteInfo { + /// The class hashes of the resource during its lifecycle, + /// always at least one if the resource has been registered. + /// Then for each upgrade, a new class hash is appended to the vector. + pub class_hashes: Vec, + /// The name of the contract. + pub name: String, + /// The namespace used to register the resource remotely. + pub namespace: String, + /// The address of the resource. + pub address: ContractAddress, + /// The contract addresses that have owner permission on the resource. + pub owners: HashSet, + /// The contract addresses that have writer permission on the resource. + pub writers: HashSet, +} + +#[derive(Debug, Clone)] +pub struct ContractRemote { + /// Common information about the resource. + pub common: CommonRemoteInfo, + /// Whether the contract has been initialized. + pub is_initialized: bool, +} + +#[derive(Debug, Clone)] +pub struct ModelRemote { + /// Common information about the resource. + pub common: CommonRemoteInfo, +} + +#[derive(Debug, Clone)] +pub struct EventRemote { + /// Common information about the resource. + pub common: CommonRemoteInfo, +} + +#[derive(Debug, Clone)] +pub struct NamespaceRemote { + pub name: String, + /// The contract addresses that have owner permission on the contract. + pub owners: HashSet, + /// The contract addresses that have writer permission on the contract. + pub writers: HashSet, +} + +impl NamespaceRemote { + /// Create a new namespace remote. + pub fn new(name: String) -> Self { + Self { name, owners: HashSet::new(), writers: HashSet::new() } + } +} + +impl CommonRemoteInfo { + /// Create a new common resource remote info. + pub fn new(original_class_hash: Felt, namespace: &str, name: &str, address: Felt) -> Self { + Self { + class_hashes: vec![original_class_hash], + name: name.to_string(), + namespace: namespace.to_string(), + address, + owners: HashSet::new(), + writers: HashSet::new(), + } + } + + /// The dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + naming::compute_selector_from_names(&self.namespace, &self.name) + } + + /// The class hash of the resource after its latest upgrade. + pub fn current_class_hash(&self) -> Felt { + *self.class_hashes.last().expect("Remote resources must have at least one class hash.") + } + + /// The class hash of the resource when it was first registered. + pub fn original_class_hash(&self) -> Felt { + *self.class_hashes.first().expect("Remote resources must have at least one class hash.") + } + + /// Push a new class hash to the resource meaning it has been upgraded. + pub fn push_class_hash(&mut self, class_hash: Felt) { + self.class_hashes.push(class_hash); + } +} + +impl ContractRemote { + /// The dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + self.common.dojo_selector() + } +} + +impl ModelRemote { + /// The dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + self.common.dojo_selector() + } +} + +impl EventRemote { + /// The dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + self.common.dojo_selector() + } +} + +impl ResourceRemote { + /// The dojo selector of the resource. + pub fn dojo_selector(&self) -> DojoSelector { + match self { + // The namespace doesn't apply to have the dojo selector of a namespace resource. + ResourceRemote::Namespace(ns) => naming::compute_bytearray_hash(&ns.name), + ResourceRemote::Contract(contract) => contract.dojo_selector(), + ResourceRemote::Model(model) => model.dojo_selector(), + ResourceRemote::Event(event) => event.dojo_selector(), + } + } + /// The name of the resource. + pub fn name(&self) -> String { + match self { + ResourceRemote::Contract(c) => c.common.name.clone(), + ResourceRemote::Model(m) => m.common.name.clone(), + ResourceRemote::Event(e) => e.common.name.clone(), + ResourceRemote::Namespace(ns) => ns.name.clone(), + } + } + + /// The namespace of the resource. + pub fn namespace(&self) -> String { + match self { + ResourceRemote::Contract(c) => c.common.namespace.clone(), + ResourceRemote::Model(m) => m.common.namespace.clone(), + ResourceRemote::Event(e) => e.common.namespace.clone(), + ResourceRemote::Namespace(ns) => ns.name.clone(), + } + } + + /// Returns the tag of the resource. + pub fn tag(&self) -> String { + naming::get_tag(&self.namespace(), &self.name()) + } + + /// The address of the resource. + pub fn address(&self) -> Felt { + match self { + ResourceRemote::Contract(c) => c.common.address, + ResourceRemote::Model(m) => m.common.address, + ResourceRemote::Event(e) => e.common.address, + ResourceRemote::Namespace(_) => Felt::ZERO, + } + } + + /// Push a new class hash to the resource meaning it has been upgraded. + pub fn push_class_hash(&mut self, class_hash: Felt) { + match self { + ResourceRemote::Namespace(_) => {} + ResourceRemote::Contract(contract) => contract.common.push_class_hash(class_hash), + ResourceRemote::Model(model) => model.common.push_class_hash(class_hash), + ResourceRemote::Event(event) => event.common.push_class_hash(class_hash), + } + } + + /// The class hash of the resource after its latest upgrade. + pub fn current_class_hash(&self) -> Felt { + match self { + ResourceRemote::Contract(contract) => contract.common.current_class_hash(), + ResourceRemote::Model(model) => model.common.current_class_hash(), + ResourceRemote::Event(event) => event.common.current_class_hash(), + ResourceRemote::Namespace(_) => Felt::ZERO, + } + } + + /// Get the writers of the resource and it's dojo selector. + pub fn get_writers(&self) -> (DojoSelector, HashSet) { + match self { + ResourceRemote::Contract(contract) => { + (self.dojo_selector(), contract.common.writers.clone()) + } + ResourceRemote::Model(model) => (self.dojo_selector(), model.common.writers.clone()), + ResourceRemote::Event(event) => (self.dojo_selector(), event.common.writers.clone()), + ResourceRemote::Namespace(ns) => (self.dojo_selector(), ns.writers.clone()), + } + } + + /// Get the owners of the resource and it's dojo selector. + pub fn get_owners(&self) -> (DojoSelector, HashSet) { + match self { + ResourceRemote::Contract(contract) => { + (self.dojo_selector(), contract.common.owners.clone()) + } + ResourceRemote::Model(model) => (self.dojo_selector(), model.common.owners.clone()), + ResourceRemote::Event(event) => (self.dojo_selector(), event.common.owners.clone()), + ResourceRemote::Namespace(ns) => (self.dojo_selector(), ns.owners.clone()), + } + } + + /// Returns the type of the resource. + pub fn resource_type(&self) -> ResourceType { + match self { + ResourceRemote::Contract(_) => ResourceType::Contract, + ResourceRemote::Model(_) => ResourceType::Model, + ResourceRemote::Event(_) => ResourceType::Event, + ResourceRemote::Namespace(_) => ResourceType::Namespace, + } + } + + /// Get the contract remote if the resource is a contract, otherwise return an error. + pub fn as_contract_mut(&mut self) -> Result<&mut ContractRemote> { + match self { + ResourceRemote::Contract(contract) => Ok(contract), + _ => anyhow::bail!("Resource is expected to be a contract: {:?}.", self), + } + } + + /// Get the contract remote if the resource is a contract, otherwise panic. + pub fn as_contract_or_panic(&self) -> &ContractRemote { + match self { + ResourceRemote::Contract(contract) => contract, + _ => panic!("Resource is expected to be a contract: {:?}.", self), + } + } + + /// Get the model remote if the resource is a model, otherwise panic. + pub fn as_model_or_panic(&self) -> &ModelRemote { + match self { + ResourceRemote::Model(model) => model, + _ => panic!("Resource is expected to be a model: {:?}.", self), + } + } + + /// Get the event remote if the resource is an event, otherwise panic. + pub fn as_event_or_panic(&self) -> &EventRemote { + match self { + ResourceRemote::Event(event) => event, + _ => panic!("Resource is expected to be an event: {:?}.", self), + } + } + + /// Get the namespace remote if the resource is a namespace, otherwise panic. + pub fn as_namespace_or_panic(&self) -> &NamespaceRemote { + match self { + ResourceRemote::Namespace(namespace) => namespace, + _ => panic!("Resource is expected to be a namespace: {:?}.", self), + } + } +} diff --git a/crates/dojo/world/src/test_utils.rs b/crates/dojo/world/src/test_utils.rs new file mode 100644 index 0000000000..dc1081c9e7 --- /dev/null +++ b/crates/dojo/world/src/test_utils.rs @@ -0,0 +1,20 @@ +use starknet::core::types::contract::{SierraClass, SierraClassDebugInfo}; +use starknet::core::types::EntryPointsByType; + +pub fn empty_sierra_class() -> SierraClass { + SierraClass { + abi: vec![], + sierra_program: vec![], + sierra_program_debug_info: SierraClassDebugInfo { + type_names: vec![], + libfunc_names: vec![], + user_func_names: vec![], + }, + contract_class_version: "0".to_string(), + entry_points_by_type: EntryPointsByType { + constructor: vec![], + external: vec![], + l1_handler: vec![], + }, + } +} diff --git a/crates/dojo-world/src/uri.rs b/crates/dojo/world/src/uri.rs similarity index 100% rename from crates/dojo-world/src/uri.rs rename to crates/dojo/world/src/uri.rs diff --git a/crates/dojo/world/src/utils.rs b/crates/dojo/world/src/utils.rs new file mode 100644 index 0000000000..9f1d7cae0d --- /dev/null +++ b/crates/dojo/world/src/utils.rs @@ -0,0 +1,29 @@ +//! Utility functions for the world. + +use starknet::core::types::Felt; +use starknet::core::utils::{self as snutils, CairoShortStringToFeltError}; +use starknet_crypto::poseidon_hash_single; + +/// Computes the deterministic address of the world contract based on the given seed. +pub fn compute_world_address( + seed: &str, + world_class_hash: Felt, +) -> Result { + let salt = world_salt(seed)?; + Ok(snutils::get_contract_address(salt, world_class_hash, &[world_class_hash], Felt::ZERO)) +} + +/// Computes the deterministic address of a Dojo contract based on the given selector, class hash +/// and world address. +pub fn compute_dojo_contract_address( + dojo_selector: Felt, + class_hash: Felt, + world_address: Felt, +) -> Felt { + snutils::get_contract_address(dojo_selector, class_hash, &[], world_address) +} + +/// Computes the salt for the world contract based on the given seed. +pub fn world_salt(seed: &str) -> Result { + Ok(poseidon_hash_single(snutils::cairo_short_string_to_felt(seed)?)) +} diff --git a/crates/katana/runner/macro/src/lib.rs b/crates/katana/runner/macro/src/lib.rs index 3ee2c73b37..7783befc1b 100644 --- a/crates/katana/runner/macro/src/lib.rs +++ b/crates/katana/runner/macro/src/lib.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] //! Implementation of the proc macro in this module is highly adapted from `tokio-macros` crate. -//! `tokio-macro`: https://docs.rs/tokio-macros/2.4.0/tokio_macros/ +//! `tokio-macro`: pub(crate) mod config; mod entry; diff --git a/crates/katana/tasks/src/task.rs b/crates/katana/tasks/src/task.rs index 22f8a24301..c59f147584 100644 --- a/crates/katana/tasks/src/task.rs +++ b/crates/katana/tasks/src/task.rs @@ -29,7 +29,7 @@ impl TaskResult { /// A builder for building tasks to be spawned on the associated task manager. /// -/// Can only be created using [`TaskManager::build_task`]. +/// Can only be created using [`super::TaskSpawner::build_task`]. #[derive(Debug)] pub struct TaskBuilder<'a> { /// The task manager that the task will be spawned on. diff --git a/crates/sozo/ops/Cargo.toml b/crates/sozo/ops/Cargo.toml index 0204596429..24dc70eb32 100644 --- a/crates/sozo/ops/Cargo.toml +++ b/crates/sozo/ops/Cargo.toml @@ -10,47 +10,22 @@ anyhow.workspace = true async-trait.workspace = true bigdecimal = "0.4.5" cainome.workspace = true -cairo-lang-compiler.workspace = true -cairo-lang-defs.workspace = true -cairo-lang-filesystem.workspace = true -cairo-lang-plugins.workspace = true -cairo-lang-project.workspace = true -cairo-lang-sierra.workspace = true -cairo-lang-sierra-to-casm.workspace = true -cairo-lang-starknet.workspace = true -cairo-lang-starknet-classes.workspace = true -cairo-lang-test-plugin.workspace = true -cairo-lang-utils.workspace = true -camino.workspace = true -clap.workspace = true -colored = "2.0.0" -colored_json = "3.2.0" -console.workspace = true -dojo-lang.workspace = true -dojo-types.workspace = true +colored.workspace = true +colored_json.workspace = true dojo-utils.workspace = true -dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } +dojo-world.workspace = true futures.workspace = true -itertools.workspace = true -num-bigint = "0.4.6" num-traits.workspace = true -reqwest.workspace = true -rpassword.workspace = true -scarb.workspace = true -scarb-ui.workspace = true -semver.workspace = true serde.workspace = true serde_json.workspace = true serde_with.workspace = true -smol_str.workspace = true sozo-walnut = { workspace = true, optional = true } +spinoff.workspace = true starknet.workspace = true starknet-crypto.workspace = true thiserror.workspace = true -tokio.workspace = true toml.workspace = true tracing.workspace = true -url.workspace = true dojo-test-utils = { workspace = true, features = [ "build-examples" ], optional = true } katana-runner = { workspace = true, optional = true } @@ -60,6 +35,7 @@ assert_fs.workspace = true dojo-test-utils = { workspace = true, features = [ "build-examples" ] } ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ] } katana-runner.workspace = true +dojo-types.workspace = true [features] test-utils = [ "dep:dojo-test-utils", "dep:katana-runner" ] diff --git a/crates/sozo/ops/src/account.rs b/crates/sozo/ops/src/account.rs index 9508dfc966..554d8159bb 100644 --- a/crates/sozo/ops/src/account.rs +++ b/crates/sozo/ops/src/account.rs @@ -3,6 +3,7 @@ use std::io::Write; use std::path::PathBuf; use anyhow::{Context, Result}; +use bigdecimal::BigDecimal; use colored::Colorize; use colored_json::{ColorMode, Output}; use dojo_utils::{TransactionExt, TransactionWaiter, TxnAction, TxnConfig}; @@ -21,7 +22,14 @@ use starknet::providers::{JsonRpcClient, Provider, ProviderError}; use starknet::signers::{LocalWallet, Signer, SigningKey}; use starknet_crypto::Felt; -use crate::utils; +/// Convert a [`Felt`] into a [`BigDecimal`] with a given number of decimals. +pub fn felt_to_bigdecimal(felt: F, decimals: D) -> BigDecimal +where + F: AsRef, + D: Into, +{ + BigDecimal::from((felt.as_ref().to_bigint(), decimals.into())) +} /// The canonical hash of a contract class. This is the class hash value of a contract instance. pub type ClassHash = Felt; @@ -248,7 +256,14 @@ pub async fn deploy( }; match txn_action { - TxnAction::Send { wait, receipt, max_fee_raw, fee_estimate_multiplier, walnut } => { + TxnAction::Send { + wait, + receipt, + max_fee_raw, + fee_estimate_multiplier, + walnut, + timeout_ms, + } => { let max_fee = if let Some(max_fee_raw) = max_fee_raw { MaxFeeType::Manual { max_fee: max_fee_raw } } else { @@ -277,8 +292,14 @@ pub async fn deploy( }; let account_deployment = account_deployment.max_fee(max_fee.max_fee()); - let txn_config = - TxnConfig { fee_estimate_multiplier, wait, receipt, max_fee_raw, walnut }; + let txn_config = TxnConfig { + fee_estimate_multiplier, + wait, + receipt, + max_fee_raw, + walnut, + timeout_ms, + }; do_account_deploy( max_fee, txn_config, @@ -306,7 +327,7 @@ pub async fn deploy( })? .overall_fee; - let decimal = utils::felt_to_bigdecimal(estimated_fee, 18); + let decimal = felt_to_bigdecimal(estimated_fee, 18); println!("{} ETH", format!("{decimal}").bright_yellow()); Ok(()) @@ -337,17 +358,16 @@ async fn do_account_deploy( eprintln!( "You've manually specified the account deployment fee to be {}. Therefore, fund \ at least:\n {}", - format!("{} ETH", utils::felt_to_bigdecimal(max_fee, 18)).bright_yellow(), - format!("{} ETH", utils::felt_to_bigdecimal(max_fee, 18)).bright_yellow(), + format!("{} ETH", felt_to_bigdecimal(max_fee, 18)).bright_yellow(), + format!("{} ETH", felt_to_bigdecimal(max_fee, 18)).bright_yellow(), ); } MaxFeeType::Estimated { estimate, estimate_with_buffer } => { eprintln!( "The estimated account deployment fee is {}. However, to avoid failure, fund at \ least:\n {}", - format!("{} ETH", utils::felt_to_bigdecimal(estimate, 18)).bright_yellow(), - format!("{} ETH", utils::felt_to_bigdecimal(estimate_with_buffer, 18)) - .bright_yellow() + format!("{} ETH", felt_to_bigdecimal(estimate, 18)).bright_yellow(), + format!("{} ETH", felt_to_bigdecimal(estimate_with_buffer, 18)).bright_yellow() ); } } diff --git a/crates/sozo/ops/src/auth.rs b/crates/sozo/ops/src/auth.rs index 899540aefa..76e0a07b2f 100644 --- a/crates/sozo/ops/src/auth.rs +++ b/crates/sozo/ops/src/auth.rs @@ -14,7 +14,7 @@ use sozo_walnut::WalnutDebugger; use starknet::accounts::{Account, ConnectedAccount}; use starknet::core::types::{BlockId, BlockTag, Felt}; -use crate::migration::ui::MigrationUi; +//use crate::migration::ui::MigrationUi; use crate::utils; #[derive(Debug, Clone, PartialEq)] @@ -312,7 +312,7 @@ where // be sure that the model exists match world_reader.model_reader_with_tag(&tag).await { Err(ModelError::ModelNotFound) => { - ui.print_sub(format!("Unknown model '{}' => IGNORED", tag)); + //ui.print_sub(format!("Unknown model '{}' => IGNORED", tag)); } Err(err) => { return Err(err.into()); diff --git a/crates/sozo/ops/src/call.rs b/crates/sozo/ops/src/call.rs index 12bc197ce6..111d906736 100644 --- a/crates/sozo/ops/src/call.rs +++ b/crates/sozo/ops/src/call.rs @@ -5,7 +5,7 @@ use starknet::core::types::{BlockId, BlockTag, Felt, FunctionCall}; use starknet::core::utils::get_selector_from_name; use starknet::providers::Provider; -use crate::migration::ui::MigrationUi; +// use crate::migration::ui::MigrationUi; use crate::utils::{get_contract_address_from_reader, parse_block_id}; pub async fn call( @@ -43,7 +43,7 @@ pub async fn call( ); } Err(e) => { - ui.print_hidden_sub(format!("{:?}", e)); + //ui.print_hidden_sub(format!("{:?}", e)); anyhow::bail!(format!( "Error calling entrypoint `{}` on address: {:#066x}", entrypoint, contract_address diff --git a/crates/dojo-lang/src/manifest_test_data/simple_crate/src/lib.cairo b/crates/sozo/ops/src/clean.rs similarity index 100% rename from crates/dojo-lang/src/manifest_test_data/simple_crate/src/lib.cairo rename to crates/sozo/ops/src/clean.rs diff --git a/crates/sozo/ops/src/lib.rs b/crates/sozo/ops/src/lib.rs index 57952881a4..aa256c6c00 100644 --- a/crates/sozo/ops/src/lib.rs +++ b/crates/sozo/ops/src/lib.rs @@ -1,17 +1,7 @@ -pub mod account; -pub mod auth; -pub mod call; -pub mod events; -pub mod execute; -pub mod keystore; -pub mod migration; -pub mod model; -pub mod register; -pub mod statistics; -pub mod utils; +// #![cfg_attr(not(test), warn(unused_crate_dependencies))] -#[cfg(any(test, feature = "test-utils"))] -pub mod test_utils; +pub mod account; +pub mod migrate; #[cfg(test)] pub mod tests; diff --git a/crates/sozo/ops/src/migrate/error.rs b/crates/sozo/ops/src/migrate/error.rs new file mode 100644 index 0000000000..d70c291db9 --- /dev/null +++ b/crates/sozo/ops/src/migrate/error.rs @@ -0,0 +1,39 @@ +//! The migration related errors. + +use dojo_utils::{TransactionError, TransactionWaitingError}; +use starknet::core::types::FromStrError; +use starknet::core::utils::CairoShortStringToFeltError; +use starknet::providers::ProviderError; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum MigrationError +where + S: std::error::Error, +{ + #[error(transparent)] + CairoSerde(#[from] cainome::cairo_serde::Error), + #[error(transparent)] + Provider(ProviderError), + #[error(transparent)] + StarknetJson(#[from] starknet::core::types::contract::JsonError), + #[error( + "The contract `{0}` has no valid address, ensure this resource is known locally, or \ + remove it from the profile config writers/owners." + )] + OrphanSelectorAddress(String), + #[error(transparent)] + FromStr(#[from] FromStrError), + #[error(transparent)] + TransactionWaiting(#[from] TransactionWaitingError), + #[error(transparent)] + CairoShortStringToFelt(#[from] CairoShortStringToFeltError), + #[error( + "Failed to initialize contracts, verify the init call arguments in the profile config." + )] + InitCallArgs, + #[error(transparent)] + TransactionError(#[from] TransactionError), + #[error("Declaration of class failed: {0}")] + DeclareClassError(String), +} diff --git a/crates/sozo/ops/src/migrate/mod.rs b/crates/sozo/ops/src/migrate/mod.rs new file mode 100644 index 0000000000..6d927372b5 --- /dev/null +++ b/crates/sozo/ops/src/migrate/mod.rs @@ -0,0 +1,668 @@ +//! The migration module contains the logic for migrating the world. +//! +//! A migration is a sequence of steps that are executed in a specific order, +//! based on the [`WorldDiff`] that is computed from the local and remote world. +//! +//! Migrating a world can be sequenced as follows: +//! +//! 1. First the namespaces are synced. +//! 2. Then, all the resources (Contract, Models, Events) are synced, which can consist of: +//! - Declaring the classes. +//! - Registering the resources. +//! - Upgrading the resources. +//! 3. Once resources are synced, the permissions are synced. Permissions can be in different +//! states: +//! - For newly registered resources, the permissions are applied. +//! - For existing resources, the permissions are compared to the onchain state and the necessary +//! changes are applied. +//! 4. All contracts that are not initialized are initialized, since permissions are applied, +//! initialization of contracts can mutate resources. + +use std::collections::HashMap; +use std::fmt; +use std::str::FromStr; + +use cainome::cairo_serde::{ByteArray, ClassHash, ContractAddress}; +use dojo_utils::{Declarer, Deployer, Invoker, TxnConfig}; +use dojo_world::config::ProfileConfig; +use dojo_world::contracts::WorldContract; +use dojo_world::diff::{Manifest, ResourceDiff, WorldDiff, WorldStatus}; +use dojo_world::local::ResourceLocal; +use dojo_world::remote::ResourceRemote; +use dojo_world::{utils, ResourceType}; +use spinoff::Spinner; +use starknet::accounts::{ConnectedAccount, SingleOwnerAccount}; +use starknet::core::types::{Call, FlattenedSierraClass}; +use starknet::providers::AnyProvider; +use starknet::signers::LocalWallet; +use starknet_crypto::Felt; +use tracing::trace; + +pub mod error; +pub use error::MigrationError; + +#[derive(Debug)] +pub struct Migration +where + A: ConnectedAccount + Sync + Send, +{ + diff: WorldDiff, + world: WorldContract, + txn_config: TxnConfig, + profile_config: ProfileConfig, + // This is only to retrieve the declarers or make custom calls. + // Ideally, we want this rpc url to be exposed from the world.account.provider(). + rpc_url: String, +} + +#[derive(Debug)] +pub struct MigrationResult { + pub has_changes: bool, + pub manifest: Manifest, +} + +pub enum MigrationUi { + Spinner(Spinner), + None, +} + +impl fmt::Debug for MigrationUi { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Spinner(_) => write!(f, "Spinner"), + Self::None => write!(f, "None"), + } + } +} + +impl MigrationUi { + pub fn update_text(&mut self, text: &'static str) { + match self { + Self::Spinner(s) => s.update_text(text), + Self::None => (), + } + } + + pub fn stop_and_persist(&mut self, symbol: &'static str, text: &'static str) { + match self { + Self::Spinner(s) => s.stop_and_persist(symbol, text), + Self::None => (), + } + } +} + +impl Migration +where + A: ConnectedAccount + Sync + Send, +{ + /// Creates a new migration. + pub fn new( + diff: WorldDiff, + world: WorldContract, + txn_config: TxnConfig, + profile_config: ProfileConfig, + rpc_url: String, + ) -> Self { + Self { diff, world, txn_config, profile_config, rpc_url } + } + + /// Migrates the world by syncing the namespaces, resources, permissions and initializing the + /// contracts. + /// + /// TODO: find a more elegant way to pass an UI printer to the ops library than a hard coded + /// spinner. + pub async fn migrate( + &self, + spinner: &mut MigrationUi, + ) -> Result> { + spinner.update_text("Deploying world..."); + let world_has_changed = self.ensure_world().await?; + + let resources_have_changed = if !self.diff.is_synced() { + spinner.update_text("Syncing resources..."); + self.sync_resources().await? + } else { + false + }; + + spinner.update_text("Syncing permissions..."); + let permissions_have_changed = self.sync_permissions().await?; + + spinner.update_text("Initializing contracts..."); + let contracts_have_changed = self.initialize_contracts().await?; + + Ok(MigrationResult { + has_changes: world_has_changed + || resources_have_changed + || permissions_have_changed + || contracts_have_changed, + manifest: Manifest::new(&self.diff), + }) + } + + /// Returns whether multicall should be used. By default, it is enabled. + fn do_multicall(&self) -> bool { + self.profile_config + .migration + .as_ref() + .map_or(true, |m| !m.disable_multicall.unwrap_or(false)) + } + + /// For all contracts that are not initialized, initialize them by using the init call arguments + /// found in the [`ProfileConfig`]. + /// + /// Returns true if at least one contract has been initialized, false otherwise. + async fn initialize_contracts(&self) -> Result> { + let mut invoker = Invoker::new(&self.world.account, self.txn_config); + + let init_call_args = if let Some(init_call_args) = &self.profile_config.init_call_args { + init_call_args.clone() + } else { + HashMap::new() + }; + + // Ensure we can order the contracts to initialize, if specified. + // Keeps the tag matched to the call to initialize. + let ordered_init_tags = self + .profile_config + .migration + .as_ref() + .map_or(vec![], |m| m.order_inits.clone().unwrap_or_default()); + + // Keeps map between the order index and the call to initialize. + let mut ordered_init_calls = HashMap::new(); + + for (selector, resource) in &self.diff.resources { + if resource.resource_type() == ResourceType::Contract { + let tag = resource.tag(); + + // TODO: maybe we want a resource diff with a new variant. Where the migration + // is skipped, but we still have the local resource. + if self.profile_config.is_skipped(&tag) { + continue; + } + + let (do_init, init_call_args) = match resource { + ResourceDiff::Created(ResourceLocal::Contract(_)) => { + (true, init_call_args.get(&tag)) + } + ResourceDiff::Updated(_, ResourceRemote::Contract(contract)) => { + (!contract.is_initialized, init_call_args.get(&tag)) + } + ResourceDiff::Synced(_, ResourceRemote::Contract(contract)) => { + (!contract.is_initialized, init_call_args.get(&tag)) + } + _ => (false, None), + }; + + if do_init { + // Currently, only felts are supported in the init call data. + // The injection of class hash and addresses is no longer supported since the + // world contains an internal DNS. + let args = if let Some(args) = init_call_args { + let mut parsed_args = vec![]; + for arg in args { + parsed_args.push(Felt::from_str(arg)?); + } + parsed_args + } else { + vec![] + }; + + trace!(tag, ?args, "Initializing contract."); + + if let Some(order_index) = ordered_init_tags.iter().position(|t| *t == tag) { + ordered_init_calls + .insert(order_index, self.world.init_contract_getcall(selector, &args)); + } else { + invoker.add_call(self.world.init_contract_getcall(selector, &args)); + } + } + } + } + + if !ordered_init_calls.is_empty() { + let mut ordered_keys: Vec<_> = ordered_init_calls.keys().cloned().collect(); + ordered_keys.sort(); + + let ordered_calls: Vec<_> = ordered_keys + .into_iter() + .map(|k| ordered_init_calls.get(&k).expect("Ordered call must exist.").clone()) + .collect(); + + invoker.extends_ordered(ordered_calls); + } + + let has_changed = !invoker.calls.is_empty(); + + if self.do_multicall() { + invoker.multicall().await?; + } else { + invoker.invoke_all_sequentially().await?; + } + + Ok(has_changed) + } + + /// Syncs the permissions. + /// + /// This first version is naive, and only applies the local permissions to the resources, if the + /// permission is not already set onchain. + /// + /// TODO: An other function must be added to sync the remote permissions to the local ones, + /// and allow the user to reset the permissions onchain to the local ones. + /// + /// TODO: for error message, we need the name + namespace (or the tag for non-namespace + /// resources). Change `DojoSelector` with a struct containing the local definition of an + /// overlay resource, which can contain also writers. + /// + /// Returns true if at least one permission has changed, false otherwise. + async fn sync_permissions(&self) -> Result> { + let mut invoker = Invoker::new(&self.world.account, self.txn_config); + + // Only takes the local permissions that are not already set onchain to apply them. + for (selector, resource) in &self.diff.resources { + if self.profile_config.is_skipped(&resource.tag()) { + continue; + } + + for pdiff in self.diff.get_writers(*selector).only_local() { + trace!( + target = resource.tag(), + grantee_tag = pdiff.tag.unwrap_or_default(), + grantee_address = format!("{:#066x}", pdiff.address), + "Granting writer permission." + ); + + invoker.add_call( + self.world.grant_writer_getcall(selector, &ContractAddress(pdiff.address)), + ); + } + + for pdiff in self.diff.get_owners(*selector).only_local() { + trace!( + target = resource.tag(), + grantee_tag = pdiff.tag.unwrap_or_default(), + grantee_address = format!("{:#066x}", pdiff.address), + "Granting owner permission." + ); + + invoker.add_call( + self.world.grant_owner_getcall(selector, &ContractAddress(pdiff.address)), + ); + } + } + + let has_changed = !invoker.calls.is_empty(); + + if self.do_multicall() { + invoker.multicall().await?; + } else { + invoker.invoke_all_sequentially().await?; + } + + Ok(has_changed) + } + + /// Syncs the resources by declaring the classes and registering/upgrading the resources. + /// + /// Returns true if at least one resource has changed, false otherwise. + async fn sync_resources(&self) -> Result> { + let mut invoker = Invoker::new(&self.world.account, self.txn_config); + + // Namespaces must be synced first, since contracts, models and events are namespaced. + self.namespaces_getcalls(&mut invoker).await?; + + let mut classes: HashMap = HashMap::new(); + + // Collects the calls and classes to be declared to sync the resources. + for resource in self.diff.resources.values() { + if self.profile_config.is_skipped(&resource.tag()) { + continue; + } + + match resource.resource_type() { + ResourceType::Contract => { + let (contract_calls, contract_classes) = + self.contracts_calls_classes(resource).await?; + invoker.extend_calls(contract_calls); + classes.extend(contract_classes); + } + ResourceType::Model => { + let (model_calls, model_classes) = self.models_calls_classes(resource).await?; + invoker.extend_calls(model_calls); + classes.extend(model_classes); + } + ResourceType::Event => { + let (event_calls, event_classes) = self.events_calls_classes(resource).await?; + invoker.extend_calls(event_calls); + classes.extend(event_classes); + } + _ => continue, + } + } + + let has_classes = !classes.is_empty(); + let has_calls = !invoker.calls.is_empty(); + let has_changed = has_classes || has_calls; + + // Declaration can be slow, and can be speed up by using multiple accounts. + // Since migrator account from `self.world.account` is under the [`ConnectedAccount`] trait, + // we can group it with the predeployed accounts which are concrete types. + let accounts = self.get_accounts().await; + + if accounts.is_empty() { + trace!("Declaring classes with migrator account."); + let mut declarer = Declarer::new(&self.world.account, self.txn_config); + declarer.extend_classes(classes.into_iter().collect()); + declarer.declare_all().await?; + } else { + trace!("Declaring classes with {} accounts.", accounts.len()); + let mut declarers = vec![]; + for account in accounts { + declarers.push(Declarer::new(account, self.txn_config)); + } + + for (idx, (casm_class_hash, class)) in classes.into_iter().enumerate() { + let declarer_idx = idx % declarers.len(); + declarers[declarer_idx].add_class(casm_class_hash, class); + } + + let declarers_futures = + futures::future::join_all(declarers.into_iter().map(|d| d.declare_all())).await; + + for declarer_results in declarers_futures { + if let Err(e) = declarer_results { + // The issue is that `e` is bound to concrete type `SingleOwnerAccount`. + // Thus, we can't return `e` directly. + // Might have a better solution by addind a new variant? + if e.to_string().contains("Class already declared") { + // If the class is already declared, it might be because it was already + // declared in a previous run or an other declarer. + continue; + } + + return Err(MigrationError::DeclareClassError(e.to_string())); + } + } + } + + if self.do_multicall() { + invoker.multicall().await?; + } else { + invoker.invoke_all_sequentially().await?; + } + + Ok(has_changed) + } + + /// Returns the calls required to sync the namespaces. + async fn namespaces_getcalls( + &self, + invoker: &mut Invoker<&A>, + ) -> Result<(), MigrationError> { + for namespace_selector in &self.diff.namespaces { + // TODO: abstract this expect by having a function exposed in the diff. + let resource = + self.diff.resources.get(namespace_selector).expect("Namespace not found in diff."); + + if let ResourceDiff::Created(ResourceLocal::Namespace(namespace)) = resource { + trace!(name = namespace.name, "Registering namespace."); + + invoker.add_call( + self.world + .register_namespace_getcall(&ByteArray::from_string(&namespace.name)?), + ); + } + } + + Ok(()) + } + + /// Gathers the calls required to sync the contracts and classes to be declared. + /// + /// Currently, classes are cloned to be flattened, this is not ideal but the [`WorldDiff`] + /// will be required later. + /// If we could extract the info before syncing the resources, then we could avoid cloning the + /// classes. + /// + /// Returns a tuple of calls and (casm_class_hash, class) to be declared. + async fn contracts_calls_classes( + &self, + resource: &ResourceDiff, + ) -> Result<(Vec, HashMap), MigrationError> + { + let mut calls = vec![]; + let mut classes = HashMap::new(); + + let namespace = resource.namespace(); + let ns_bytearray = ByteArray::from_string(&namespace)?; + + if let ResourceDiff::Created(ResourceLocal::Contract(contract)) = resource { + trace!( + namespace, + name = contract.common.name, + class_hash = format!("{:#066x}", contract.common.class_hash), + "Registering contract." + ); + + classes + .insert(contract.common.casm_class_hash, contract.common.class.clone().flatten()?); + + calls.push(self.world.register_contract_getcall( + &contract.dojo_selector(), + &ns_bytearray, + &ClassHash(contract.common.class_hash), + )); + } + + if let ResourceDiff::Updated( + ResourceLocal::Contract(contract_local), + ResourceRemote::Contract(_contract_remote), + ) = resource + { + trace!( + namespace, + name = contract_local.common.name, + class_hash = format!("{:#066x}", contract_local.common.class_hash), + "Upgrading contract." + ); + + classes.insert( + contract_local.common.casm_class_hash, + contract_local.common.class.clone().flatten()?, + ); + + calls.push(self.world.upgrade_contract_getcall( + &ns_bytearray, + &ClassHash(contract_local.common.class_hash), + )); + } + + Ok((calls, classes)) + } + + /// Returns the calls required to sync the models and gather the classes to be declared. + /// + /// Returns a tuple of calls and (casm_class_hash, class) to be declared. + async fn models_calls_classes( + &self, + resource: &ResourceDiff, + ) -> Result<(Vec, HashMap), MigrationError> + { + let mut calls = vec![]; + let mut classes = HashMap::new(); + + let namespace = resource.namespace(); + let ns_bytearray = ByteArray::from_string(&namespace)?; + + if let ResourceDiff::Created(ResourceLocal::Model(model)) = resource { + trace!( + namespace, + name = model.common.name, + class_hash = format!("{:#066x}", model.common.class_hash), + "Registering model." + ); + + classes.insert(model.common.casm_class_hash, model.common.class.clone().flatten()?); + + calls.push( + self.world + .register_model_getcall(&ns_bytearray, &ClassHash(model.common.class_hash)), + ); + } + + if let ResourceDiff::Updated( + ResourceLocal::Model(model_local), + ResourceRemote::Model(_model_remote), + ) = resource + { + trace!( + namespace, + name = model_local.common.name, + class_hash = format!("{:#066x}", model_local.common.class_hash), + "Upgrading model." + ); + + classes.insert( + model_local.common.casm_class_hash, + model_local.common.class.clone().flatten()?, + ); + + calls.push( + self.world.upgrade_model_getcall( + &ns_bytearray, + &ClassHash(model_local.common.class_hash), + ), + ); + } + + Ok((calls, classes)) + } + + /// Returns the calls required to sync the events and gather the classes to be declared. + /// + /// Returns a tuple of calls and (casm_class_hash, class) to be declared. + async fn events_calls_classes( + &self, + resource: &ResourceDiff, + ) -> Result<(Vec, HashMap), MigrationError> + { + let mut calls = vec![]; + let mut classes = HashMap::new(); + + let namespace = resource.namespace(); + let ns_bytearray = ByteArray::from_string(&namespace)?; + + if let ResourceDiff::Created(ResourceLocal::Event(event)) = resource { + trace!( + namespace, + name = event.common.name, + class_hash = format!("{:#066x}", event.common.class_hash), + "Registering event." + ); + + classes.insert(event.common.casm_class_hash, event.common.class.clone().flatten()?); + + calls.push( + self.world + .register_event_getcall(&ns_bytearray, &ClassHash(event.common.class_hash)), + ); + } + + if let ResourceDiff::Updated( + ResourceLocal::Event(event_local), + ResourceRemote::Event(_event_remote), + ) = resource + { + trace!( + namespace, + name = event_local.common.name, + class_hash = format!("{:#066x}", event_local.common.class_hash), + "Upgrading event." + ); + + classes.insert( + event_local.common.casm_class_hash, + event_local.common.class.clone().flatten()?, + ); + + calls.push( + self.world.upgrade_event_getcall( + &ns_bytearray, + &ClassHash(event_local.common.class_hash), + ), + ); + } + + Ok((calls, classes)) + } + + /// Ensures the world is declared and deployed if necessary. + /// + /// Returns true if the world has to be deployed/updated, false otherwise. + async fn ensure_world(&self) -> Result> { + match &self.diff.world_info.status { + WorldStatus::Synced => return Ok(false), + WorldStatus::NotDeployed => { + trace!("Deploying the first world."); + + Declarer::declare( + self.diff.world_info.casm_class_hash, + self.diff.world_info.class.clone().flatten()?, + &self.world.account, + &self.txn_config, + ) + .await?; + + let deployer = Deployer::new(&self.world.account, self.txn_config); + + deployer + .deploy_via_udc( + self.diff.world_info.class_hash, + utils::world_salt(&self.profile_config.world.seed)?, + &[self.diff.world_info.class_hash], + Felt::ZERO, + ) + .await?; + } + WorldStatus::NewVersion => { + trace!("Upgrading the world."); + + Declarer::declare( + self.diff.world_info.casm_class_hash, + self.diff.world_info.class.clone().flatten()?, + &self.world.account, + &self.txn_config, + ) + .await?; + + let mut invoker = Invoker::new(&self.world.account, self.txn_config); + + invoker.add_call( + self.world.upgrade_getcall(&ClassHash(self.diff.world_info.class_hash)), + ); + + invoker.multicall().await?; + } + }; + + Ok(true) + } + + /// Returns the accounts to use for the migration. + /// + /// This is useful to use multiple accounts since the declare transaction is nonce-based, + /// and can only be parallelized by using different accounts. + /// + /// Accounts can come from the profile config, otherwise we fallback to the predeployed + /// accounts. + async fn get_accounts(&self) -> Vec> { + // TODO: if profile config have some migrators, use them instead. + + // If the RPC provider does not support the predeployed accounts, this will fail silently. + dojo_utils::get_predeployed_accounts(&self.world.account, &self.rpc_url) + .await + .unwrap_or_default() + } +} diff --git a/crates/sozo/ops/src/migration/auto_auth.rs b/crates/sozo/ops/src/migration/auto_auth.rs deleted file mode 100644 index 7e06d76603..0000000000 --- a/crates/sozo/ops/src/migration/auto_auth.rs +++ /dev/null @@ -1,48 +0,0 @@ -use anyhow::Result; -use dojo_utils::TxnConfig; -use dojo_world::contracts::WorldContract; -use scarb::core::Workspace; -#[cfg(feature = "walnut")] -use sozo_walnut::WalnutDebugger; -use starknet::accounts::ConnectedAccount; - -use crate::auth::{grant_writer, revoke_writer, ResourceWriter}; - -pub async fn auto_authorize( - ws: &Workspace<'_>, - world: &WorldContract, - txn_config: &TxnConfig, - default_namespace: &str, - grant: &[ResourceWriter], - revoke: &[ResourceWriter], - #[cfg(feature = "walnut")] walnut_debugger: &Option, -) -> Result<()> -where - A: ConnectedAccount + Sync + Send + 'static, - A::SignError: 'static, -{ - let ui = ws.config().ui(); - - grant_writer( - &ui, - world, - grant, - txn_config, - default_namespace, - #[cfg(feature = "walnut")] - walnut_debugger, - ) - .await?; - revoke_writer( - &ui, - world, - revoke, - txn_config, - default_namespace, - #[cfg(feature = "walnut")] - walnut_debugger, - ) - .await?; - - Ok(()) -} diff --git a/crates/sozo/ops/src/migration/migrate.rs b/crates/sozo/ops/src/migration/migrate.rs deleted file mode 100644 index c4ffaf6e69..0000000000 --- a/crates/sozo/ops/src/migration/migrate.rs +++ /dev/null @@ -1,1402 +0,0 @@ -use std::collections::{HashMap, HashSet}; -use std::path::Path; -use std::str::FromStr; - -use anyhow::{anyhow, bail, Context, Result}; -use cainome::cairo_serde::ByteArray; -use camino::Utf8PathBuf; -use dojo_utils::{TransactionExt, TransactionWaiter, TxnConfig}; -use dojo_world::contracts::abi::world::{self, Resource}; -use dojo_world::contracts::naming::{ - self, compute_selector_from_tag, get_name_from_tag, get_namespace_from_tag, -}; -use dojo_world::contracts::{cairo_utils, WorldContract}; -use dojo_world::manifest::{ - AbiFormat, BaseManifest, Class, DeploymentManifest, DojoContract, DojoModel, Manifest, - ManifestMethods, WorldContract as ManifestWorldContract, WorldMetadata, ABIS_DIR, BASE_DIR, - DEPLOYMENT_DIR, MANIFESTS_DIR, -}; -use dojo_world::metadata::{dojo_metadata_from_workspace, ResourceMetadata}; -use dojo_world::migration::class::ClassMigration; -use dojo_world::migration::contract::ContractMigration; -use dojo_world::migration::strategy::{generate_salt, prepare_for_migration, MigrationStrategy}; -use dojo_world::migration::world::WorldDiff; -use dojo_world::migration::{Declarable, Deployable, MigrationError, RegisterOutput, Upgradable}; -use futures::future; -use itertools::Itertools; -use scarb::core::Workspace; -use scarb_ui::Ui; -use starknet::accounts::{Account, ConnectedAccount, SingleOwnerAccount}; -use starknet::core::types::{ - BlockId, BlockTag, Felt, FunctionCall, InvokeTransactionResult, StarknetError, -}; -use starknet::core::utils::{ - cairo_short_string_to_felt, get_contract_address, get_selector_from_name, -}; -use starknet::providers::{AnyProvider, Provider, ProviderError}; -use starknet::signers::LocalWallet; -use tokio::fs; - -use super::ui::{bold_message, italic_message, MigrationUi}; -use super::utils::generate_resource_map; -use super::{ - ContractDeploymentOutput, ContractMigrationOutput, ContractUpgradeOutput, MigrationOutput, -}; -use crate::auth::{get_resource_selector, ResourceType, ResourceWriter}; - -pub fn prepare_migration( - target_dir: &Utf8PathBuf, - diff: WorldDiff, - name: &str, - world_address: Option, - ui: &Ui, -) -> Result { - ui.print_step(3, "📦", "Preparing for migration..."); - - let name = cairo_short_string_to_felt(name).with_context(|| "Failed to parse World name.")?; - - let migration = prepare_for_migration(world_address, name, target_dir, diff) - .with_context(|| "Problem preparing for migration.")?; - - let info = migration.info(); - - ui.print_sub(format!( - "Total items to be migrated ({}): New {} Update {}", - info.new + info.update, - info.new, - info.update - )); - - Ok(migration) -} - -pub async fn apply_diff( - ws: &Workspace<'_>, - account: A, - txn_config: TxnConfig, - strategy: &MigrationStrategy, - declarers: &[SingleOwnerAccount], -) -> Result -where - A: ConnectedAccount + Sync + Send, - ::Provider: Send, - A::SignError: 'static, -{ - let ui = ws.config().ui(); - - ui.print_step(4, "🛠", "Migrating..."); - ui.print(" "); - - let migration_output = execute_strategy(ws, strategy, account, txn_config, declarers) - .await - .map_err(|e| anyhow!(e)) - .with_context(|| "Problem trying to migrate.")?; - - if migration_output.full { - if let Some(block_number) = migration_output.world_block_number { - ui.print(format!( - "\n🎉 Successfully migrated World on block #{} at address {}\n", - block_number, - bold_message(format!("{:#x}", strategy.world_address)) - )); - } else { - ui.print(format!( - "\n🎉 Successfully migrated World at address {}\n", - bold_message(format!("{:#x}", strategy.world_address)) - )); - } - } else { - ui.print(format!( - "\n🚨 Partially migrated World at address {}", - bold_message(format!("{:#x}", strategy.world_address)) - )); - } - - Ok(migration_output) -} - -pub async fn execute_strategy( - ws: &Workspace<'_>, - strategy: &MigrationStrategy, - migrator: A, - txn_config: TxnConfig, - declarers: &[SingleOwnerAccount], -) -> Result -where - A: ConnectedAccount + Sync + Send, - A::Provider: Send, - A::SignError: 'static, -{ - let ui = ws.config().ui(); - let mut world_tx_hash: Option = None; - let mut world_block_number: Option = None; - - if let Some(base) = &strategy.base { - ui.print_header("# Base Contract"); - - match base.declare(&migrator, &txn_config).await { - Ok(res) => { - ui.print_sub(format!("Class Hash: {:#x}", res.class_hash)); - } - Err(MigrationError::ClassAlreadyDeclared) => { - ui.print_sub(format!("Already declared: {:#x}", base.diff.local_class_hash)); - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(&ui, base.artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - return Err(e.into()); - } - }; - } - - if let Some(world) = &strategy.world { - ui.print_header("# World"); - - // If a migration is pending for the world, we upgrade only if the remote world - // already exists. - if world.diff.remote_class_hash.is_some() { - let _deploy_result = upgrade_contract( - world, - "world", - world.diff.original_class_hash, - strategy.base.as_ref().unwrap().diff.original_class_hash, - &migrator, - &ui, - &txn_config, - ) - .await - .map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to upgrade world: {e}") - })?; - - ui.print_sub(format!("Upgraded Contract at address: {:#x}", world.contract_address)); - } else { - let calldata = vec![strategy.base.as_ref().unwrap().diff.local_class_hash]; - let deploy_result = - deploy_contract(world, "world", calldata.clone(), &migrator, &ui, &txn_config) - .await - .map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to deploy world: {e}") - })?; - - (world_tx_hash, world_block_number) = - if let ContractDeploymentOutput::Output(deploy_result) = deploy_result { - (Some(deploy_result.transaction_hash), deploy_result.block_number) - } else { - (None, None) - }; - - ui.print_sub(format!("Contract address: {:#x}", world.contract_address)); - } - } - - let world_address = strategy.world_address; - let mut migration_output = MigrationOutput { - world_address, - world_tx_hash, - world_block_number, - full: false, - models: vec![], - contracts: vec![], - }; - - // register namespaces - let mut namespaces = - strategy.models.iter().map(|m| get_namespace_from_tag(&m.diff.tag)).collect::>(); - namespaces.extend( - strategy.contracts.iter().map(|c| get_namespace_from_tag(&c.diff.tag)).collect::>(), - ); - namespaces = namespaces.into_iter().unique().collect::>(); - - register_namespaces(&namespaces, world_address, &migrator, &ui, &txn_config).await?; - - // TODO: rework this part when more time. - if declarers.is_empty() { - match register_dojo_models(&strategy.models, world_address, &migrator, &ui, &txn_config) - .await - { - Ok(output) => { - migration_output.models = output.registered_models; - } - Err(e) => { - ui.anyhow(&e); - return Ok(migration_output); - } - }; - - match register_dojo_contracts( - &strategy.contracts, - world_address, - migrator, - &ui, - &txn_config, - ) - .await - { - Ok(output) => { - migration_output.contracts = output; - } - Err(e) => { - ui.anyhow(&e); - return Ok(migration_output); - } - }; - } else { - match register_dojo_models_with_declarers( - &strategy.models, - world_address, - &migrator, - &ui, - &txn_config, - declarers, - ) - .await - { - Ok(output) => { - migration_output.models = output.registered_models; - } - Err(e) => { - ui.anyhow(&e); - return Ok(migration_output); - } - }; - - match register_dojo_contracts_declarers( - &strategy.contracts, - world_address, - migrator, - &ui, - &txn_config, - declarers, - ) - .await - { - Ok(output) => { - migration_output.contracts = output; - } - Err(e) => { - ui.anyhow(&e); - return Ok(migration_output); - } - }; - } - - migration_output.full = true; - - Ok(migration_output) -} - -/// Upload a metadata as a IPFS artifact and then create a resource to register -/// into the Dojo resource registry. -/// -/// # Arguments -/// * `ui` - The user interface object for displaying information -/// * `resource_id` - The id of the resource to create -/// * `metadata` - The ResourceMetadata object containing the metadata to upload -/// -/// # Returns -/// A [`world::ResourceMetadata`] object to register in the Dojo resource register -/// on success, or an error if the upload fails. -async fn upload_on_ipfs_and_create_resource( - ui: &Ui, - resource_id: Felt, - metadata: ResourceMetadata, -) -> Result { - match metadata.upload().await { - Ok(hash) => { - ui.print_sub(format!("{}: ipfs://{}", metadata.name, hash)); - create_resource_metadata(resource_id, hash) - } - Err(_) => Err(anyhow!("Failed to upload IPFS resource.")), - } -} - -/// Create a resource to register in the Dojo resource registry. -/// -/// # Arguments -/// * `resource_id` - the ID of the resource -/// * `hash` - the IPFS hash -/// -/// # Returns -/// A [`ResourceData`] object to register in the Dojo resource register -/// on success. -fn create_resource_metadata(resource_id: Felt, hash: String) -> Result { - let metadata_uri = cairo_utils::encode_uri(&format!("ipfs://{hash}"))?; - Ok(world::ResourceMetadata { resource_id, metadata_uri }) -} - -/// Upload metadata of the world/models/contracts as IPFS artifacts and then -/// register them in the Dojo resource registry. -/// -/// # Arguments -/// -/// * `ws` - the workspace -/// * `migrator` - the account used to migrate -/// * `migration_output` - the output after having applied the migration plan. -pub async fn upload_metadata( - ws: &Workspace<'_>, - migrator: A, - migration_output: MigrationOutput, - txn_config: TxnConfig, -) -> Result<()> -where - A: ConnectedAccount + Sync + Send, - ::Provider: Send, -{ - let ui = ws.config().ui(); - - ui.print(" "); - ui.print_step(8, "🌐", "Uploading metadata..."); - ui.print(" "); - - let dojo_metadata = dojo_metadata_from_workspace(ws)?; - let mut ipfs = vec![]; - let mut resources = vec![]; - - // world - if migration_output.world_tx_hash.is_some() { - match dojo_metadata.world.upload().await { - Ok(hash) => { - let resource = create_resource_metadata(Felt::ZERO, hash.clone())?; - ui.print_sub(format!("world: ipfs://{}", hash)); - resources.push(resource); - } - Err(err) => { - ui.print_sub(format!("Failed to upload World metadata:\n{err}")); - } - } - } - - // models - if !migration_output.models.is_empty() { - for model_tag in migration_output.models { - if let Some(m) = dojo_metadata.resources_artifacts.get(&model_tag) { - ipfs.push(upload_on_ipfs_and_create_resource( - &ui, - compute_selector_from_tag(&model_tag), - m.clone(), - )); - } - } - } - - // contracts - let migrated_contracts = migration_output.contracts.into_iter().flatten().collect::>(); - - if !migrated_contracts.is_empty() { - for contract in migrated_contracts { - if let Some(m) = dojo_metadata.resources_artifacts.get(&contract.tag) { - ipfs.push(upload_on_ipfs_and_create_resource( - &ui, - naming::compute_selector_from_tag(&contract.tag), - m.clone(), - )); - } - } - } - - // upload IPFS - resources.extend( - future::try_join_all(ipfs) - .await - .map_err(|_| anyhow!("Unable to upload IPFS artifacts."))?, - ); - - ui.print("> All IPFS artifacts have been successfully uploaded.".to_string()); - - // update the resource registry - let world = WorldContract::new(migration_output.world_address, &migrator); - - let calls = resources.iter().map(|r| world.set_metadata_getcall(r)).collect::>(); - - if calls.is_empty() { - ui.print_sub("No metadata to register"); - return Ok(()); - } - - let InvokeTransactionResult { transaction_hash } = - migrator.execute_v1(calls).send_with_cfg(&txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to register metadata into the resource registry: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!( - "> All metadata have been registered in the resource registry (tx hash: \ - {transaction_hash:#x})" - )); - - ui.print(""); - ui.print("\n✨ Done."); - - Ok(()) -} - -async fn register_namespaces( - namespaces: &[String], - world_address: Felt, - migrator: &A, - ui: &Ui, - txn_config: &TxnConfig, -) -> Result<()> -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - let world = WorldContract::new(world_address, migrator); - - // We need to check if the namespace is not already registered. - let mut registered_namespaces = vec![]; - - for namespace in namespaces { - let namespace_selector = naming::compute_bytearray_hash(namespace); - - if let Resource::Namespace = world.resource(&namespace_selector).call().await? { - registered_namespaces.push(namespace); - } - } - - let calls = namespaces - .iter() - .filter(|ns| !registered_namespaces.contains(ns)) - .map(|ns| { - ui.print(italic_message(&ns).to_string()); - world.register_namespace_getcall(&ByteArray::from_string(ns).unwrap()) - }) - .collect::>(); - - if calls.is_empty() { - return Ok(()); - } - - ui.print_header(format!("# Namespaces ({})", namespaces.len() - registered_namespaces.len())); - - let InvokeTransactionResult { transaction_hash } = - world.account.execute_v1(calls).send_with_cfg(txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to register namespace to World: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!("All namespaces are registered at: {transaction_hash:#x}\n")); - - Ok(()) -} - -async fn register_dojo_models( - models: &[ClassMigration], - world_address: Felt, - migrator: &A, - ui: &Ui, - txn_config: &TxnConfig, -) -> Result -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - if models.is_empty() { - return Ok(RegisterOutput { - transaction_hash: Felt::ZERO, - declare_output: vec![], - registered_models: vec![], - }); - } - - ui.print_header(format!("# Models ({})", models.len())); - - let world = WorldContract::new(world_address, &migrator); - - let mut declare_output = vec![]; - let mut models_to_register = vec![]; - - for (i, m) in models.iter().enumerate() { - let tag = &m.diff.tag; - - ui.print(italic_message(tag).to_string()); - - if let Resource::Unregistered = - world.resource(&compute_selector_from_tag(tag)).call().await? - { - models_to_register.push(tag.clone()); - } else { - ui.print_sub("Already registered"); - continue; - } - - match m.declare(&migrator, txn_config).await { - Ok(output) => { - ui.print_sub(format!("Selector: {:#066x}", compute_selector_from_tag(tag))); - ui.print_hidden_sub(format!("Class hash: {:#066x}", output.class_hash)); - ui.print_hidden_sub(format!( - "Declare transaction: {:#066x}", - output.transaction_hash - )); - declare_output.push(output); - } - Err(MigrationError::ClassAlreadyDeclared) => { - ui.print_sub("Already declared"); - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, models[i].artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - bail!("Failed to declare model: {e}") - } - } - } - - let calls = models - .iter() - .filter(|m| models_to_register.contains(&m.diff.tag)) - .map(|c| world.register_model_getcall(&c.diff.local_class_hash.into())) - .collect::>(); - - if calls.is_empty() { - return Ok(RegisterOutput { - transaction_hash: Felt::ZERO, - declare_output: vec![], - registered_models: vec![], - }); - } - - let InvokeTransactionResult { transaction_hash } = - world.account.execute_v1(calls).send_with_cfg(txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to register models to World: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!("All models are registered at: {transaction_hash:#x}\n")); - - Ok(RegisterOutput { transaction_hash, declare_output, registered_models: models_to_register }) -} - -// For now duplicated because the migrator account is different from the declarers account type. -async fn register_dojo_models_with_declarers( - models: &[ClassMigration], - world_address: Felt, - migrator: &A, - ui: &Ui, - txn_config: &TxnConfig, - declarers: &[SingleOwnerAccount], -) -> Result -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - if models.is_empty() { - return Ok(RegisterOutput { - transaction_hash: Felt::ZERO, - declare_output: vec![], - registered_models: vec![], - }); - } - - ui.print_header(format!("# Models ({})", models.len())); - - let mut declare_output = vec![]; - let mut models_to_register = vec![]; - - let mut declarers_tasks = HashMap::new(); - for (i, m) in models.iter().enumerate() { - let declarer_index = i % declarers.len(); - declarers_tasks - .entry(declarer_index) - .or_insert(vec![]) - .push((m.diff.tag.clone(), m.declare(&declarers[declarer_index], txn_config))); - } - - let mut futures = Vec::new(); - - for (declarer_index, d_tasks) in declarers_tasks { - let future = async move { - let mut results = Vec::new(); - for (tag, task) in d_tasks { - let result = task.await; - results.push((declarer_index, tag, result)); - } - results - }; - - futures.push(future); - } - - let all_results = futures::future::join_all(futures).await; - - let world = WorldContract::new(world_address, &migrator); - - for results in all_results { - for (index, tag, result) in results { - ui.print(italic_message(&tag).to_string()); - - if let Resource::Unregistered = - world.resource(&compute_selector_from_tag(&tag)).call().await? - { - models_to_register.push(tag.clone()); - } else { - ui.print_sub("Already registered"); - continue; - } - - match result { - Ok(output) => { - ui.print_sub(format!("Selector: {:#066x}", compute_selector_from_tag(&tag))); - ui.print_hidden_sub(format!("Class hash: {:#066x}", output.class_hash)); - ui.print_hidden_sub(format!( - "Declare transaction: {:#066x}", - output.transaction_hash - )); - declare_output.push(output); - } - Err(MigrationError::ClassAlreadyDeclared) => { - ui.print_sub("Already declared"); - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, models[index].artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - bail!("Failed to declare model: {e}") - } - } - } - } - - let calls = models - .iter() - .filter(|m| models_to_register.contains(&m.diff.tag)) - .map(|c| world.register_model_getcall(&c.diff.local_class_hash.into())) - .collect::>(); - - if calls.is_empty() { - return Ok(RegisterOutput { - transaction_hash: Felt::ZERO, - declare_output: vec![], - registered_models: vec![], - }); - } - - let InvokeTransactionResult { transaction_hash } = - world.account.execute_v1(calls).send_with_cfg(txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to register models to World: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!("All models are registered at: {transaction_hash:#x}\n")); - - Ok(RegisterOutput { transaction_hash, declare_output, registered_models: models_to_register }) -} - -async fn register_dojo_contracts( - contracts: &Vec, - world_address: Felt, - migrator: A, - ui: &Ui, - txn_config: &TxnConfig, -) -> Result>> -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - if contracts.is_empty() { - return Ok(vec![]); - } - - ui.print_header(format!("# Contracts ({})", contracts.len())); - - let mut declare_outputs = vec![]; - - for (i, c) in contracts.iter().enumerate() { - let tag = &c.diff.tag; - ui.print(italic_message(&tag).to_string()); - - match c.declare(&migrator, txn_config).await { - Ok(output) => { - ui.print_sub(format!("Selector: {:#066x}", compute_selector_from_tag(tag))); - ui.print_hidden_sub(format!("Class hash: {:#066x}", output.class_hash)); - ui.print_hidden_sub(format!( - "Declare transaction: {:#066x}", - output.transaction_hash - )); - declare_outputs.push(output); - } - Err(MigrationError::ClassAlreadyDeclared) => { - ui.print_sub("Already declared"); - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, contracts[i].artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - bail!("Failed to declare model: {e}") - } - } - } - - let mut calls = vec![]; - let mut deploy_outputs = vec![]; - - for contract in contracts { - let tag = &contract.diff.tag; - ui.print(italic_message(tag).to_string()); - - if let Ok((call, contract_address, was_upgraded)) = contract - .deploy_dojo_contract_call( - world_address, - contract.diff.local_class_hash, - contract.diff.base_class_hash, - &migrator, - tag, - ) - .await - { - let base_class_hash = contract.diff.base_class_hash; - - calls.push(call); - - if was_upgraded { - ui.print_hidden_sub(format!("{} upgraded at {:#066x}", tag, contract_address)); - } else { - ui.print_hidden_sub(format!("{} deployed at {:#066x}", tag, contract_address)); - } - - deploy_outputs.push(Some(ContractMigrationOutput { - tag: tag.clone(), - contract_address, - base_class_hash, - was_upgraded, - })); - } else { - // contract already deployed. - deploy_outputs.push(None); - } - } - - if calls.is_empty() { - return Ok(deploy_outputs); - } - - let InvokeTransactionResult { transaction_hash } = - migrator.execute_v1(calls).send_with_cfg(txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to deploy contracts: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!("All contracts are deployed at: {transaction_hash:#x}\n")); - - Ok(deploy_outputs) -} - -async fn register_dojo_contracts_declarers( - contracts: &Vec, - world_address: Felt, - migrator: A, - ui: &Ui, - txn_config: &TxnConfig, - declarers: &[SingleOwnerAccount], -) -> Result>> -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - if contracts.is_empty() { - return Ok(vec![]); - } - - ui.print_header(format!("# Contracts ({})", contracts.len())); - - // Declare all and keep (tg, class_hash, tx_hash). - // Then multicall the deploy matching the class hash. - let mut declarers_tasks = HashMap::new(); - for (i, c) in contracts.iter().enumerate() { - let declarer_index = i % declarers.len(); - declarers_tasks - .entry(declarer_index) - .or_insert(vec![]) - .push((c.diff.tag.clone(), c.declare(&declarers[declarer_index], txn_config))); - } - - let mut futures = Vec::new(); - - for (declarer_index, d_tasks) in declarers_tasks { - let future = async move { - let mut results = Vec::new(); - for (tag, task) in d_tasks { - let result = task.await; - results.push((declarer_index, tag, result)); - } - results - }; - - futures.push(future); - } - - let all_results = futures::future::join_all(futures).await; - - let mut declare_outputs = vec![]; - - for results in all_results { - for (index, tag, result) in results { - ui.print(italic_message(&tag).to_string()); - match result { - Ok(output) => { - ui.print_sub(format!("Selector: {:#066x}", compute_selector_from_tag(&tag))); - ui.print_hidden_sub(format!("Class hash: {:#066x}", output.class_hash)); - ui.print_hidden_sub(format!( - "Declare transaction: {:#066x}", - output.transaction_hash - )); - declare_outputs.push(output); - } - Err(MigrationError::ClassAlreadyDeclared) => { - ui.print_sub("Already declared"); - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, contracts[index].artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - bail!("Failed to declare model: {e}") - } - } - } - } - - let mut calls = vec![]; - let mut deploy_outputs = vec![]; - - for contract in contracts { - let tag = &contract.diff.tag; - ui.print(italic_message(tag).to_string()); - - if let Ok((call, contract_address, was_upgraded)) = contract - .deploy_dojo_contract_call( - world_address, - contract.diff.local_class_hash, - contract.diff.base_class_hash, - &migrator, - tag, - ) - .await - { - let base_class_hash = contract.diff.base_class_hash; - - calls.push(call); - - if was_upgraded { - ui.print_sub(format!("{} upgraded at {:#066x}", tag, contract_address)); - } else { - ui.print_sub(format!("{} deployed at {:#066x}", tag, contract_address)); - } - - deploy_outputs.push(Some(ContractMigrationOutput { - tag: tag.clone(), - contract_address, - base_class_hash, - was_upgraded, - })); - } else { - // contract already deployed. - deploy_outputs.push(None); - } - } - - if calls.is_empty() { - return Ok(deploy_outputs); - } - - let InvokeTransactionResult { transaction_hash } = - migrator.execute_v1(calls).send_with_cfg(txn_config).await.map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to deploy contracts: {e}") - })?; - - TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - - ui.print(format!("All contracts are deployed at: {transaction_hash:#x}\n")); - - Ok(deploy_outputs) -} - -async fn deploy_contract( - contract: &ContractMigration, - contract_id: &str, - constructor_calldata: Vec, - migrator: A, - ui: &Ui, - txn_config: &TxnConfig, -) -> Result -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - match contract - .deploy(contract.diff.local_class_hash, constructor_calldata, migrator, txn_config) - .await - { - Ok(mut val) => { - if let Some(declare) = val.clone().declare { - ui.print_hidden_sub(format!( - "Declare transaction: {:#x}", - declare.transaction_hash - )); - } - - ui.print_hidden_sub(format!("Deploy transaction: {:#x}", val.transaction_hash)); - - val.tag = Some(contract.diff.tag.clone()); - Ok(ContractDeploymentOutput::Output(val)) - } - Err(MigrationError::ContractAlreadyDeployed(contract_address)) => { - Ok(ContractDeploymentOutput::AlreadyDeployed(contract_address)) - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, contract.artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - Err(anyhow!("Failed to migrate {contract_id}: {e}")) - } - } -} - -async fn upgrade_contract( - contract: &ContractMigration, - contract_id: &str, - original_class_hash: Felt, - original_base_class_hash: Felt, - migrator: A, - ui: &Ui, - txn_config: &TxnConfig, -) -> Result -where - A: ConnectedAccount + Send + Sync, - ::Provider: Send, -{ - match contract - .upgrade_world( - contract.diff.local_class_hash, - original_class_hash, - original_base_class_hash, - migrator, - txn_config, - ) - .await - { - Ok(val) => { - if let Some(declare) = val.clone().declare { - ui.print_hidden_sub(format!( - "Declare transaction: {:#x}", - declare.transaction_hash - )); - } - - ui.print_hidden_sub(format!("Upgrade transaction: {:#x}", val.transaction_hash)); - - Ok(ContractUpgradeOutput::Output(val)) - } - Err(MigrationError::ArtifactError(e)) => { - return Err(handle_artifact_error(ui, contract.artifact_path(), e)); - } - Err(e) => { - ui.verbose(format!("{e:?}")); - Err(anyhow!("Failed to upgrade {contract_id}: {e}")) - } - } -} - -pub fn handle_artifact_error(ui: &Ui, artifact_path: &Path, error: anyhow::Error) -> anyhow::Error { - let path = artifact_path.to_string_lossy(); - let name = artifact_path.file_name().unwrap().to_string_lossy(); - ui.verbose(format!("{path}: {error:?}")); - - anyhow!( - "Discrepancy detected in {name}.\nUse `sozo clean` to clean your project.\n - Then, rebuild your project with `sozo build`." - ) -} - -pub async fn get_contract_operation_name

( - provider: P, - contract: &ContractMigration, - world_address: Felt, -) -> String -where - P: Provider + Sync + Send, -{ - if let Ok(base_class_hash) = provider - .call( - FunctionCall { - contract_address: world_address, - calldata: vec![], - entry_point_selector: get_selector_from_name("base").unwrap(), - }, - BlockId::Tag(BlockTag::Pending), - ) - .await - { - let contract_address = - get_contract_address(contract.salt, base_class_hash[0], &[], world_address); - - match provider.get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address).await { - Ok(current_class_hash) if current_class_hash != contract.diff.local_class_hash => { - format!("{}: Upgrade", contract.diff.tag) - } - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { - format!("{}: Deploy", contract.diff.tag) - } - Ok(_) => format!("{}: Already Deployed", contract.diff.tag), - Err(_) => format!("{}: Deploy", contract.diff.tag), - } - } else { - format!("{}: Deploy", contract.diff.tag) - } -} - -pub async fn print_strategy

( - ui: &Ui, - provider: P, - strategy: &MigrationStrategy, - world_address: Felt, -) where - P: Provider + Sync + Send, -{ - ui.print("\n📋 Migration Strategy\n"); - - ui.print_header(format!("World address: {:#x}", world_address)); - - ui.print(" "); - - if let Some(base) = &strategy.base { - ui.print_header("# Base Contract"); - ui.print_sub(format!("Class hash: {:#x}", base.diff.local_class_hash)); - } - - ui.print(" "); - - if let Some(world) = &strategy.world { - ui.print_header("# World"); - ui.print_sub(format!("Class hash: {:#x}", world.diff.local_class_hash)); - } - - ui.print(" "); - - if !&strategy.models.is_empty() { - ui.print_header(format!("# Models ({})", &strategy.models.len())); - for m in &strategy.models { - ui.print(m.diff.tag.to_string()); - ui.print_sub(format!("Class hash: {:#x}", m.diff.local_class_hash)); - } - } - - ui.print(" "); - - if !&strategy.contracts.is_empty() { - ui.print_header(format!("# Contracts ({})", &strategy.contracts.len())); - for c in &strategy.contracts { - let op_name = get_contract_operation_name(&provider, c, strategy.world_address).await; - - ui.print(op_name); - ui.print_sub(format!("Class hash: {:#x}", c.diff.local_class_hash)); - let salt = generate_salt(&get_name_from_tag(&c.diff.tag)); - let contract_address = - get_contract_address(salt, c.diff.base_class_hash, &[], world_address); - ui.print_sub(format!("Contract address: {:#x}", contract_address)); - } - } - - ui.print(" "); -} - -#[allow(clippy::too_many_arguments)] -pub async fn update_manifests_and_abis( - ws: &Workspace<'_>, - local_manifest: BaseManifest, - manifest_dir: &Utf8PathBuf, - profile_name: &str, - rpc_url: &str, - world_address: Felt, - migration_output: Option, - salt: &str, -) -> Result<()> { - let ui = ws.config().ui(); - ui.print_step(5, "✨", "Updating manifests..."); - - let deployment_dir = manifest_dir.join(DEPLOYMENT_DIR); - - let deployed_path = deployment_dir.join("manifest").with_extension("toml"); - let deployed_path_json = deployment_dir.join("manifest").with_extension("json"); - - let mut local_manifest: DeploymentManifest = local_manifest.into(); - - local_manifest.world.inner.metadata = Some(WorldMetadata { - profile_name: profile_name.to_string(), - rpc_url: rpc_url.to_string(), - }); - - if deployed_path.exists() { - let previous_manifest = DeploymentManifest::load_from_path(&deployed_path)?; - local_manifest.merge_from_previous(previous_manifest); - }; - - local_manifest.world.inner.address = Some(world_address); - salt.clone_into(&mut local_manifest.world.inner.seed); - - // when the migration has not been applied because in `plan` mode or because of an error, - // the `migration_output` is empty. - if let Some(migration_output) = migration_output { - // update world deployment transaction hash or block number if they are present in the - // migration output - if migration_output.world_tx_hash.is_some() { - local_manifest.world.inner.transaction_hash = migration_output.world_tx_hash; - } - if migration_output.world_block_number.is_some() { - local_manifest.world.inner.block_number = migration_output.world_block_number; - } - - migration_output.contracts.iter().for_each(|contract_output| { - // ignore failed migration which are represented by None - if let Some(output) = contract_output { - // find the contract in local manifest and update its base class hash - let local = local_manifest - .contracts - .iter_mut() - .find(|c| c.inner.tag == output.tag) - .expect("contract got migrated, means it should be present here"); - - local.inner.base_class_hash = output.base_class_hash; - } - }); - } - - // compute contract addresses and update them in the manifest for contracts - // that have a base class hash set. - local_manifest.contracts.iter_mut().for_each(|contract| { - if contract.inner.base_class_hash != Felt::ZERO { - let salt = generate_salt(&get_name_from_tag(&contract.inner.tag)); - contract.inner.address = Some(get_contract_address( - salt, - contract.inner.base_class_hash, - &[], - world_address, - )); - } - }); - - update_manifest_abis(&mut local_manifest, manifest_dir, profile_name).await; - - local_manifest - .write_to_path_toml(&deployed_path) - .with_context(|| "Failed to write toml manifest")?; - - let root_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - - local_manifest - .write_to_path_json(&deployed_path_json, &root_dir) - .with_context(|| "Failed to write json manifest")?; - ui.print("\n✨ Done."); - - Ok(()) -} - -// For now we juust handle writers, handling of owners might be added in the future -pub async fn find_authorization_diff( - ui: &Ui, - world: &WorldContract, - diff: &WorldDiff, - migration_output: Option<&MigrationOutput>, - default_namespace: &str, -) -> Result<(Vec, Vec)> -where - A: ConnectedAccount + Sync + Send, - ::SignError: 'static, -{ - let mut grant = vec![]; - let mut revoke = vec![]; - - let mut recently_migrated = HashSet::new(); - - if let Some(migration_output) = migration_output { - recently_migrated = migration_output - .contracts - .iter() - .flatten() - .map(|m| m.tag.clone()) - .collect::>() - } - - // Generate a map of `Felt` (resource selector) -> `ResourceType` that are available locally - // so we can check if the resource being revoked is known locally. - // - // if the selector is not found in the map we just print its selector - let resource_map = generate_resource_map(ui, world, diff).await?; - - for c in &diff.contracts { - // remote is none meants it was not previously deployed. - // but if it didn't get deployed even during this run we should skip migration for it - if c.remote_class_hash.is_none() && !recently_migrated.contains(&c.tag) { - ui.print_sub(format!("Skipping migration for contract {}", c.tag)); - continue; - } - - let mut local = HashMap::new(); - for write in &c.local_writes { - let write = - if write.contains(':') { write.to_string() } else { format!("m:{}", write) }; - - let resource = ResourceType::from_str(&write)?; - let selector = get_resource_selector(ui, world, &resource, default_namespace) - .await - .with_context(|| format!("Failed to get selector for {}", write))?; - - let resource_writer = ResourceWriter::from_str(&format!("{},{}", write, c.tag))?; - local.insert(selector, resource_writer); - } - - for write in &c.remote_writes { - // This value is fetched from onchain events, so we get them as felts - let selector = Felt::from_str(write).with_context(|| "Expected write to be a felt")?; - if local.remove(&selector).is_some() { - // do nothing for one which are already onchain - } else { - // revoke ones that are not present in local - assert!(Felt::from_str(write).is_ok()); - revoke.push(ResourceWriter::from_str(&format!("s:{},{}", write, c.tag))?); - } - } - - // apply remaining - local.iter().for_each(|(_, resource_writer)| { - grant.push(resource_writer.clone()); - }); - - let contract_grants: Vec<_> = - grant.iter().filter(|rw| rw.tag_or_address == c.tag).cloned().collect(); - if !contract_grants.is_empty() { - ui.print_sub(format!( - "Granting write access to {} for resources: {:?}", - c.tag, - contract_grants - .iter() - .map(|rw| { - let resource = &rw.resource; - match resource { - // Replace selector with appropriate resource type if present in - // resource_map - ResourceType::Selector(s) => resource_map - .get(&s.to_hex_string()) - .cloned() - .unwrap_or_else(|| rw.resource.clone()), - _ => resource.clone(), - } - }) - .collect::>() - )); - } - - let contract_revokes: Vec<_> = - revoke.iter().filter(|rw| rw.tag_or_address == c.tag).cloned().collect(); - if !contract_revokes.is_empty() { - ui.print_sub(format!( - "Revoking write access to {} for resources: {:?}", - c.tag, - contract_revokes - .iter() - .map(|rw| { - let resource = &rw.resource; - match resource { - // Replace selector with appropriate resource type if present in - // resource_map - ResourceType::Selector(s) => resource_map - .get(&s.to_hex_string()) - .cloned() - .unwrap_or_else(|| rw.resource.clone()), - _ => resource.clone(), - } - }) - .collect::>() - )); - } - - if !contract_grants.is_empty() || !contract_revokes.is_empty() { - ui.print(" "); - } - } - - Ok((grant, revoke)) -} - -// copy abi files from `base/abi` to `deployment/abi` and update abi path in -// local_manifest -async fn update_manifest_abis( - local_manifest: &mut DeploymentManifest, - manifest_dir: &Utf8PathBuf, - profile_name: &str, -) { - fs::create_dir_all(manifest_dir).await.expect("Failed to create folder"); - - async fn inner_helper( - manifest_dir: &Utf8PathBuf, - profile_name: &str, - manifest: &mut Manifest, - ) where - T: ManifestMethods, - { - let base_relative_path = manifest.inner.abi().unwrap().to_path().unwrap(); - - // manifests/dev/base/abis/contract/contract.json -> base/abis/contract/contract.json - let base_relative_path = base_relative_path - .strip_prefix(Utf8PathBuf::new().join(MANIFESTS_DIR).join(profile_name)) - .unwrap(); - - // base/abis/contract/contract.json -> contract/contract.json - let stripped_path = base_relative_path - .strip_prefix(Utf8PathBuf::new().join(BASE_DIR).join(ABIS_DIR)) - .unwrap(); - - // deployment/abis/dojo-world.json - let deployed_relative_path = - Utf8PathBuf::new().join(DEPLOYMENT_DIR).join(ABIS_DIR).join(stripped_path); - - // /base/abis/dojo-world.json - let full_base_path = manifest_dir.join(base_relative_path); - - // /deployment/abis/dojo-world.json - let full_deployed_path = manifest_dir.join(deployed_relative_path.clone()); - - fs::create_dir_all(full_deployed_path.parent().unwrap()) - .await - .expect("Failed to create folder"); - - fs::copy(full_base_path, full_deployed_path).await.expect("Failed to copy abi file"); - - manifest.inner.set_abi(Some(AbiFormat::Path( - Utf8PathBuf::from(MANIFESTS_DIR).join(profile_name).join(deployed_relative_path), - ))); - } - - inner_helper::(manifest_dir, profile_name, &mut local_manifest.world) - .await; - - inner_helper::(manifest_dir, profile_name, &mut local_manifest.base).await; - - for contract in local_manifest.contracts.iter_mut() { - inner_helper::(manifest_dir, profile_name, contract).await; - } - - for model in local_manifest.models.iter_mut() { - inner_helper::(manifest_dir, profile_name, model).await; - } -} diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs deleted file mode 100644 index a74db4799f..0000000000 --- a/crates/sozo/ops/src/migration/mod.rs +++ /dev/null @@ -1,427 +0,0 @@ -use std::str::FromStr; -use std::sync::Arc; - -use anyhow::{anyhow, bail, Result}; -use dojo_utils::{TransactionExt, TransactionWaiter, TxnConfig}; -use dojo_world::contracts::naming::compute_selector_from_tag; -use dojo_world::contracts::WorldContract; -use dojo_world::manifest::{BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR}; -use dojo_world::metadata::get_default_namespace_from_ws; -use dojo_world::migration::world::WorldDiff; -use dojo_world::migration::{DeployOutput, UpgradeOutput}; -use scarb::core::Workspace; -#[cfg(feature = "walnut")] -use sozo_walnut::WalnutDebugger; -use starknet::accounts::{ConnectedAccount, ExecutionEncoding, SingleOwnerAccount}; -use starknet::core::types::{BlockId, BlockTag, Call, Felt, InvokeTransactionResult}; -use starknet::core::utils::{cairo_short_string_to_felt, get_contract_address}; -use starknet::macros::selector; -use starknet::providers::jsonrpc::HttpTransport; -use starknet::providers::{AnyProvider, JsonRpcClient, Provider}; -use starknet::signers::{LocalWallet, SigningKey}; -use starknet_crypto::poseidon_hash_single; -use url::Url; - -mod auto_auth; -mod migrate; -pub mod ui; -mod utils; - -pub use self::auto_auth::auto_authorize; -use self::migrate::update_manifests_and_abis; -pub use self::migrate::{ - apply_diff, execute_strategy, find_authorization_diff, prepare_migration, print_strategy, - upload_metadata, -}; -use self::ui::MigrationUi; - -#[derive(Debug, Default, Clone)] -pub struct MigrationOutput { - pub world_address: Felt, - pub world_tx_hash: Option, - pub world_block_number: Option, - // Represents if full migration got completeled. - // If false that means migration got partially completed. - pub full: bool, - - pub models: Vec, - pub contracts: Vec>, -} - -#[derive(Debug, Default, Clone)] -pub struct ContractMigrationOutput { - pub tag: String, - pub contract_address: Felt, - pub base_class_hash: Felt, - pub was_upgraded: bool, -} - -/// Get predeployed accounts from the Katana RPC server. -async fn get_declarers_accounts( - migrator: A, - rpc_url: &str, -) -> Result>> { - let client = reqwest::Client::new(); - let response = client - .post(rpc_url) - .json(&serde_json::json!({ - "jsonrpc": "2.0", - "method": "dev_predeployedAccounts", - "params": [], - "id": 1 - })) - .send() - .await; - - if response.is_err() { - return Ok(vec![]); - } - - let result: serde_json::Value = response.unwrap().json().await?; - - let mut declarers = vec![]; - - if let Some(vals) = result.get("result").and_then(|v| v.as_array()) { - let chain_id = migrator.provider().chain_id().await?; - - for a in vals { - let address = a["address"].as_str().unwrap(); - - // On slot, some accounts are hidden, we skip them. - let private_key = if let Some(pk) = a["privateKey"].as_str() { - pk - } else { - continue; - }; - - let provider = AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new( - Url::parse(rpc_url).unwrap(), - ))); - - let signer = LocalWallet::from(SigningKey::from_secret_scalar( - Felt::from_hex(private_key).unwrap(), - )); - - let mut account = SingleOwnerAccount::new( - provider, - signer, - Felt::from_hex(address).unwrap(), - chain_id, - ExecutionEncoding::New, - ); - - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - declarers.push(account); - } - } - - Ok(declarers) -} - -#[allow(clippy::too_many_arguments)] -pub async fn migrate( - ws: &Workspace<'_>, - world_address: Option, - rpc_url: String, - account: A, - name: &str, - dry_run: bool, - txn_config: TxnConfig, - skip_manifests: Option>, -) -> Result> -where - A: ConnectedAccount + Sync + Send + 'static, - A::Provider: Send, - A::SignError: 'static, -{ - let ui = ws.config().ui(); - - #[cfg(feature = "walnut")] - let walnut_debugger = - WalnutDebugger::new_from_flag(txn_config.walnut, Url::parse(&rpc_url).unwrap()); - - // its path to a file so `parent` should never return `None` - let root_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - - let profile_name = - ws.current_profile().expect("Scarb profile expected to be defined.").to_string(); - let manifest_dir = root_dir.join(MANIFESTS_DIR).join(&profile_name); - let manifest_base_dir = manifest_dir.join(BASE_DIR); - let overlay_dir = root_dir.join(OVERLAYS_DIR).join(&profile_name); - - let target_dir = ws.target_dir().path_existent().unwrap(); - let target_dir = target_dir.join(ws.config().profile().as_str()); - - let default_namespace = get_default_namespace_from_ws(ws)?; - - // Load local and remote World manifests. - let (local_manifest, remote_manifest) = utils::load_world_manifests( - &manifest_base_dir, - &overlay_dir, - &account, - world_address, - &ui, - &skip_manifests, - ) - .await - .map_err(|e| { - ui.error(e.to_string()); - anyhow!( - "\n Use `sozo clean` to clean your project.\nThen, rebuild your project with `sozo \ - build`.", - ) - })?; - - let generated_world_address = get_world_address(&local_manifest, name)?; - if let Some(world_address) = world_address { - if world_address != generated_world_address { - bail!(format!( - "Calculated world address ({:#x}) doesn't match provided world address. If you \ - are deploying with custom seed make sure `world_address` is correctly configured \ - (or not set) in your `dojo_{profile_name}.toml`", - generated_world_address - )) - } - } - - // Calculate diff between local and remote World manifests. - ui.print_step(2, "🧰", "Evaluating Worlds diff..."); - let diff = - WorldDiff::compute(local_manifest.clone(), remote_manifest.clone(), &default_namespace)?; - - let total_diffs = diff.count_diffs(); - ui.print_sub(format!("Total diffs found: {total_diffs}")); - - if total_diffs == 0 { - ui.print("\n✨ No diffs found. Remote World is already up to date!"); - } - - let strategy = prepare_migration(&target_dir, diff.clone(), name, world_address, &ui)?; - // TODO: dry run can also show the diffs for things apart from world state - // what new authorizations would be granted, if ipfs data would change or not, - // etc... - if dry_run { - if total_diffs == 0 { - return Ok(None); - } - - print_strategy(&ui, account.provider(), &strategy, strategy.world_address).await; - - update_manifests_and_abis( - ws, - local_manifest, - &manifest_dir, - &profile_name, - &rpc_url, - strategy.world_address, - None, - name, - ) - .await?; - - Ok(None) - } else { - #[cfg(feature = "walnut")] - if txn_config.walnut { - WalnutDebugger::check_api_key()?; - } - - let declarers = get_declarers_accounts(&account, &rpc_url).await?; - - let declarers_len = if declarers.is_empty() { 1 } else { declarers.len() }; - ui.print_sub(format!("Declarers: {}", declarers_len)); - - let migration_output = if total_diffs != 0 { - match apply_diff(ws, &account, txn_config, &strategy, &declarers).await { - Ok(migration_output) => Some(migration_output), - Err(e) => { - update_manifests_and_abis( - ws, - local_manifest, - &manifest_dir, - &profile_name, - &rpc_url, - strategy.world_address, - None, - name, - ) - .await?; - return Err(e)?; - } - } - } else { - None - }; - - update_manifests_and_abis( - ws, - local_manifest.clone(), - &manifest_dir, - &profile_name, - &rpc_url, - strategy.world_address, - migration_output.clone(), - name, - ) - .await?; - - let account = Arc::new(account); - let world = WorldContract::new(strategy.world_address, account.clone()); - - ui.print(" "); - ui.print_step(6, "🖋️", "Authorizing systems based on overlay..."); - let (grant, revoke) = find_authorization_diff( - &ui, - &world, - &diff, - migration_output.as_ref(), - &default_namespace, - ) - .await?; - - match auto_authorize( - ws, - &world, - &txn_config, - &default_namespace, - &grant, - &revoke, - #[cfg(feature = "walnut")] - &walnut_debugger, - ) - .await - { - Ok(()) => { - ui.print_sub("Auto authorize completed successfully"); - } - Err(e) => { - ui.print_sub(format!("Failed to auto authorize with error: {e}")); - } - }; - - if let Some(migration_output) = &migration_output { - ui.print(" "); - ui.print_step(7, "🏗️", "Initializing contracts..."); - - // Run dojo inits now that everything is actually deployed and permissioned. - let mut init_calls = vec![]; - for (i, c) in strategy.contracts.iter().enumerate() { - if let Some(contract_migration_output) = &migration_output.contracts[i] { - if contract_migration_output.was_upgraded { - ui.print_sub(format!( - "Contract {} was upgraded, skipping initialization", - c.diff.tag - )); - continue; - } - } else { - ui.print_sub(format!( - "Contract {} was not deployed at this run, skipping initialization", - c.diff.tag - )); - continue; - } - - if let Some(skips) = &skip_manifests { - if skips.contains(&c.diff.tag) { - ui.print_sub(format!( - "Contract {} was skipped in config, skipping initialization", - c.diff.tag - )); - continue; - } - } - - let contract_selector = compute_selector_from_tag(&c.diff.tag); - let init_calldata: Vec = c - .diff - .init_calldata - .iter() - .map(|s| Felt::from_str(s)) - .collect::, _>>()?; - - let mut calldata = vec![contract_selector, Felt::from(init_calldata.len())]; - calldata.extend(init_calldata); - - ui.print_sub(format!( - "Initializing contract: {} ([{}])", - c.diff.tag, - calldata - .iter() - .map(|c| format!("{:#x}", c)) - .collect::>() - .join(", ") - )); - - init_calls.push(Call { - calldata, - selector: selector!("init_contract"), - to: strategy.world_address, - }); - } - - if !init_calls.is_empty() { - let InvokeTransactionResult { transaction_hash } = account - .execute_v1(init_calls) - .send_with_cfg(&TxnConfig::init_wait()) - .await - .map_err(|e| { - ui.verbose(format!("{e:?}")); - anyhow!("Failed to deploy contracts: {e}") - })?; - - TransactionWaiter::new(transaction_hash, account.provider()).await?; - ui.print_sub(format!("All contracts are initialized at: {transaction_hash:#x}\n")); - } else { - ui.print_sub("No contracts to initialize"); - } - } - - #[cfg(feature = "walnut")] - if let Some(walnut_debugger) = &walnut_debugger { - walnut_debugger.verify_migration_strategy(ws, &strategy).await?; - } - - if let Some(migration_output) = &migration_output { - if !ws.config().offline() { - upload_metadata(ws, &account, migration_output.clone(), txn_config).await?; - } - } - - // We should print the block number at which the world was deployed by polling the - // transaction hash of the migration transaction here once everything is done as it - // has high chance to be into a mined block. If not, just wait for this inclusion? - // Should be pretty fast with BOLT. - - Ok(migration_output) - } -} - -fn get_world_address( - local_manifest: &dojo_world::manifest::BaseManifest, - name: &str, -) -> Result { - let name = cairo_short_string_to_felt(name)?; - let salt = poseidon_hash_single(name); - - let generated_world_address = get_contract_address( - salt, - local_manifest.world.inner.original_class_hash, - &[local_manifest.base.inner.class_hash], - Felt::ZERO, - ); - - Ok(generated_world_address) -} - -#[allow(dead_code)] -enum ContractDeploymentOutput { - AlreadyDeployed(Felt), - Output(DeployOutput), -} - -#[allow(dead_code)] -enum ContractUpgradeOutput { - Output(UpgradeOutput), -} diff --git a/crates/sozo/ops/src/migration/ui.rs b/crates/sozo/ops/src/migration/ui.rs deleted file mode 100644 index 7ba22923fb..0000000000 --- a/crates/sozo/ops/src/migration/ui.rs +++ /dev/null @@ -1,47 +0,0 @@ -use console::{pad_str, Alignment, Style, StyledObject}; -use scarb_ui::Ui; - -pub trait MigrationUi { - fn print_step(&self, step: usize, icon: &str, message: &str); - - fn print_header(&self, message: impl AsRef); - - fn print_sub(&self, message: impl AsRef); - - fn print_hidden_sub(&self, message: impl AsRef); -} - -impl MigrationUi for Ui { - fn print_step(&self, step: usize, icon: &str, message: &str) { - self.print(format!("{} {icon} {message}.", dimmed_message(format!("[{step}]")))); - } - - fn print_header(&self, message: impl AsRef) { - self.print(bold_message(message.as_ref()).to_string()) - } - - fn print_sub(&self, message: impl AsRef) { - self.print(subtitle(message)); - } - - fn print_hidden_sub(&self, message: impl AsRef) { - self.verbose(subtitle(message)); - } -} - -fn subtitle>(message: D) -> String { - dimmed_message(format!("{} {}", pad_str(">", 3, Alignment::Right, None), message.as_ref())) - .to_string() -} - -pub(super) fn dimmed_message(message: D) -> StyledObject { - Style::new().dim().apply_to(message) -} - -pub(super) fn bold_message(message: D) -> StyledObject { - Style::new().bold().apply_to(message) -} - -pub(super) fn italic_message(message: D) -> StyledObject { - Style::new().italic().apply_to(message) -} diff --git a/crates/sozo/ops/src/migration/utils.rs b/crates/sozo/ops/src/migration/utils.rs deleted file mode 100644 index 8d1b62e016..0000000000 --- a/crates/sozo/ops/src/migration/utils.rs +++ /dev/null @@ -1,132 +0,0 @@ -use std::collections::HashMap; - -use anyhow::{anyhow, Context, Result}; -use camino::Utf8PathBuf; -use dojo_world::contracts::naming::get_namespace_from_tag; -use dojo_world::contracts::WorldContract; -use dojo_world::manifest::{ - AbstractManifestError, BaseManifest, DeploymentManifest, OverlayManifest, -}; -use dojo_world::migration::world::WorldDiff; -use itertools::Itertools; -use scarb_ui::Ui; -use starknet::accounts::{Account, ConnectedAccount}; -use starknet::core::types::Felt; - -use super::ui::MigrationUi; -use crate::auth::{get_resource_selector, ResourceType}; - -/// Loads: -/// - `BaseManifest` from filesystem -/// - `DeployedManifest` from onchain data if `world_address` is `Some` -pub(super) async fn load_world_manifests( - manifest_dir: &Utf8PathBuf, - overlay_dir: &Utf8PathBuf, - account: A, - world_address: Option, - ui: &Ui, - skip_migration: &Option>, -) -> Result<(BaseManifest, Option)> -where - A: ConnectedAccount + Sync + Send, - ::Provider: Send, -{ - ui.print_step(1, "🌎", "Building World state..."); - - let mut local_manifest = BaseManifest::load_from_path(manifest_dir) - .map_err(|e| anyhow!("Fail to load local manifest file: {e}."))?; - - if let Some(skip_manifests) = skip_migration { - local_manifest.remove_tags(skip_manifests); - } - - if overlay_dir.exists() { - let overlay_manifest = OverlayManifest::load_from_path(overlay_dir, &local_manifest) - .map_err(|e| anyhow!("Fail to load overlay manifest file: {e}."))?; - - // merge user defined changes to base manifest - local_manifest.merge(overlay_manifest); - } - - let remote_manifest = if let Some(address) = world_address { - match DeploymentManifest::load_from_remote(account.provider(), address).await { - Ok(manifest) => { - ui.print_sub(format!("Found remote World: {address:#x}")); - Some(manifest) - } - Err(AbstractManifestError::RemoteWorldNotFound) => None, - Err(e) => { - ui.verbose(format!("{e:?}")); - return Err(anyhow!("Failed to build remote World state: {e}")); - } - } - } else { - None - }; - - if remote_manifest.is_none() { - ui.print_sub("No remote World found"); - } - - Ok((local_manifest, remote_manifest)) -} - -pub async fn generate_resource_map( - ui: &Ui, - world: &WorldContract, - diff: &WorldDiff, -) -> Result> -where - A: ConnectedAccount + Sync + Send, - ::SignError: 'static, -{ - let mut resource_map = HashMap::new(); - - for contract in diff.contracts.iter() { - let resource = ResourceType::Contract(contract.tag.clone()); - // we know the tag already contains the namespace - let default_namespace = get_namespace_from_tag(&contract.tag); - let selector = - get_resource_selector(ui, world, &resource, &default_namespace).await.with_context( - || format!("Failed to get resource selector for contract: {}", contract.tag), - )?; - - resource_map.insert(selector.to_hex_string(), resource); - } - - for model in diff.models.iter() { - let resource = ResourceType::Model(model.tag.clone()); - // we know the tag already contains the namespace - let default_namespace = get_namespace_from_tag(&model.tag); - let selector = get_resource_selector(ui, world, &resource, &default_namespace) - .await - .with_context(|| format!("Failed to get resource selector for model: {}", model.tag))?; - - resource_map.insert(selector.to_hex_string(), resource); - } - - // Collect all the namespaces from the contracts and models - let namespaces = { - let mut namespaces = - diff.models.iter().map(|m| get_namespace_from_tag(&m.tag)).collect::>(); - - namespaces.extend( - diff.contracts.iter().map(|c| get_namespace_from_tag(&c.tag)).collect::>(), - ); - - // remove duplicates - namespaces.into_iter().unique().collect::>() - }; - - for namespace in &namespaces { - let resource = ResourceType::Namespace(namespace.clone()); - let selector = - get_resource_selector(ui, world, &resource, "").await.with_context(|| { - format!("Failed to get resource selector for namespace: {}", namespace) - })?; - - resource_map.insert(selector.to_hex_string(), resource); - } - - Ok(resource_map) -} diff --git a/crates/sozo/ops/src/register.rs b/crates/sozo/ops/src/register.rs index 3897489bc5..e3a7d7f1ee 100644 --- a/crates/sozo/ops/src/register.rs +++ b/crates/sozo/ops/src/register.rs @@ -61,9 +61,11 @@ where return Ok(()); } + let namespace = cainome::cairo_serde::ByteArray::from_string("TODO").unwrap(); + let calls = models_to_register .iter() - .map(|c| world.register_model_getcall(&(*c).into())) + .map(|c| world.register_model_getcall(&namespace, &(*c).into())) .collect::>(); let res = world diff --git a/crates/sozo/ops/src/test_utils/setup.rs b/crates/sozo/ops/src/test_utils/setup.rs index 3ea1d53d0f..3b218f2ffe 100644 --- a/crates/sozo/ops/src/test_utils/setup.rs +++ b/crates/sozo/ops/src/test_utils/setup.rs @@ -52,7 +52,7 @@ pub async fn get_declarers_from_sequencer( /// /// A [`Config`] object loaded from the spawn-and-moves Scarb.toml file. pub fn load_config() -> Config { - let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let setup = CompilerTestSetup::from_examples("../../dojo/core", "../../../examples/"); setup.build_test_config("spawn-and-move", Profile::DEV) } diff --git a/crates/sozo/ops/src/tests/mod.rs b/crates/sozo/ops/src/tests/mod.rs index 260110f550..c003cebd88 100644 --- a/crates/sozo/ops/src/tests/mod.rs +++ b/crates/sozo/ops/src/tests/mod.rs @@ -1,5 +1,6 @@ -mod auth; -mod call; -mod migration; -mod model; -mod utils; +// TODO: +// mod auth; +// mod call; +// mod migration; +// mod model; +// mod utils; diff --git a/crates/sozo/ops/src/utils.rs b/crates/sozo/ops/src/utils.rs index 61d9c1d04e..498b2c9b6c 100644 --- a/crates/sozo/ops/src/utils.rs +++ b/crates/sozo/ops/src/utils.rs @@ -1,126 +1,14 @@ use anyhow::{anyhow, Result}; use bigdecimal::BigDecimal; +use cainome::cairo_serde::ClassHash; use dojo_utils::{execution_status_from_receipt, TransactionWaiter}; use dojo_world::contracts::naming::get_name_from_tag; use dojo_world::contracts::world::{WorldContract, WorldContractReader}; use dojo_world::migration::strategy::generate_salt; -use scarb_ui::Ui; -#[cfg(feature = "walnut")] -use sozo_walnut::WalnutDebugger; use starknet::accounts::ConnectedAccount; use starknet::core::types::{BlockId, BlockTag, ExecutionResult, Felt, InvokeTransactionResult}; use starknet::providers::Provider; -use crate::migration::ui::MigrationUi; - -/// Retrieves a contract address from it's name -/// using the world's data, or parses a hex string into -/// a [`Felt`]. -/// -/// # Arguments -/// -/// * `world` - The world's contract connector. -/// * `tag_or_address` - A string with a contract tag or a hexadecimal address. -/// -/// # Returns -/// -/// A [`Felt`] with the address of the contract on success. -pub async fn get_contract_address( - world: &WorldContract, - tag_or_address: &str, -) -> Result { - if tag_or_address.starts_with("0x") { - Felt::from_hex(tag_or_address).map_err(anyhow::Error::from) - } else { - let contract_class_hash = world.base().call().await?; - Ok(starknet::core::utils::get_contract_address( - generate_salt(&get_name_from_tag(tag_or_address)), - contract_class_hash.into(), - &[], - world.address, - )) - } -} - -/// Retrieves a contract address from its name -/// using a world contract reader, or parses a hex string into -/// a [`Felt`]. -/// -/// # Arguments -/// -/// * `world_reader` - The world contract reader. -/// * `tag_or_address` - A string with a contract tag or a hexadecimal address. -/// -/// # Returns -/// -/// A [`Felt`] with the address of the contract on success. -pub async fn get_contract_address_from_reader( - world_reader: &WorldContractReader

, - tag_or_address: String, -) -> Result { - if tag_or_address.starts_with("0x") { - Felt::from_hex(&tag_or_address).map_err(anyhow::Error::from) - } else { - let contract_class_hash = world_reader.base().call().await?; - Ok(starknet::core::utils::get_contract_address( - generate_salt(&get_name_from_tag(&tag_or_address)), - contract_class_hash.into(), - &[], - world_reader.address, - )) - } -} - -/// Handles a transaction result configuring a -/// [`TransactionWaiter`] if required. -/// -/// # Arguments -/// -/// * `provider` - Starknet provider to fetch transaction status. -/// * `transaction_result` - Result of the transaction to handle. -/// * `wait_for_tx` - Wait for the transaction to be mined. -/// * `show_receipt` - If the receipt of the transaction should be displayed on stdout. -/// * `walnut_debugger` - Optionally a Walnut debugger to debug the transaction. stdout. -pub async fn handle_transaction_result

( - ui: &Ui, - provider: P, - transaction_result: InvokeTransactionResult, - wait_for_tx: bool, - show_receipt: bool, - #[cfg(feature = "walnut")] walnut_debugger: &Option, -) -> Result<()> -where - P: Provider + Send, -{ - ui.print_sub(format!("Transaction hash: {:#066x}", transaction_result.transaction_hash)); - - if wait_for_tx { - let receipt = - TransactionWaiter::new(transaction_result.transaction_hash, &provider).await?; - - if show_receipt { - ui.print_sub(format!("Receipt:\n{}", serde_json::to_string_pretty(&receipt)?)); - } else { - match execution_status_from_receipt(&receipt.receipt) { - ExecutionResult::Succeeded => { - ui.print_sub("Status: OK"); - } - ExecutionResult::Reverted { reason } => { - ui.print_sub("Status: REVERTED"); - ui.print(format!("Reason:\n{}", reason)); - } - }; - - #[cfg(feature = "walnut")] - if let Some(walnut_debugger) = walnut_debugger { - walnut_debugger.debug_transaction(ui, &transaction_result.transaction_hash)?; - } - } - } - - Ok(()) -} - /// Parses a string into a [`BlockId`]. /// /// # Arguments diff --git a/crates/sozo/scarbext/Cargo.toml b/crates/sozo/scarbext/Cargo.toml new file mode 100644 index 0000000000..f93ea9ef76 --- /dev/null +++ b/crates/sozo/scarbext/Cargo.toml @@ -0,0 +1,15 @@ +[package] +edition.workspace = true +name = "sozo-scarbext" +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow.workspace = true +camino.workspace = true +dojo-world.workspace = true +scarb.workspace = true +toml.workspace = true +serde.workspace = true +serde_json.workspace = true diff --git a/crates/sozo/scarbext/src/filesystem.rs b/crates/sozo/scarbext/src/filesystem.rs new file mode 100644 index 0000000000..ec90952454 --- /dev/null +++ b/crates/sozo/scarbext/src/filesystem.rs @@ -0,0 +1,52 @@ +use anyhow::Result; +use camino::Utf8Path; +use scarb::flock::Filesystem; + +/// Handy enum for selecting the current profile or all profiles. +#[derive(Debug)] +pub enum ProfileSpec { + WorkspaceCurrent, + All, +} + +/// Extension trait for the [`Filesystem`] type. +pub trait FilesystemExt { + /// Returns a new Filesystem with the given subdirectories. + /// + /// This is a helper function since flock [`Filesystem`] only has a child method. + fn children(&self, sub_dirs: &[impl AsRef]) -> Filesystem; + + /// Lists all the files in the filesystem root, not recursively. + fn list_files(&self) -> Result>; +} + +impl FilesystemExt for Filesystem { + fn children(&self, sub_dirs: &[impl AsRef]) -> Self { + if sub_dirs.is_empty() { + return self.clone(); + } + + let mut result = self.clone(); + + for sub_dir in sub_dirs { + result = result.child(sub_dir); + } + + result + } + + fn list_files(&self) -> Result> { + let mut files = Vec::new(); + + let path = self.to_string(); + + for entry in std::fs::read_dir(path)? { + let entry = entry?; + if entry.file_type()?.is_file() { + files.push(entry.file_name().to_string_lossy().to_string()); + } + } + + Ok(files) + } +} diff --git a/crates/sozo/scarbext/src/lib.rs b/crates/sozo/scarbext/src/lib.rs new file mode 100644 index 0000000000..e33d3c4649 --- /dev/null +++ b/crates/sozo/scarbext/src/lib.rs @@ -0,0 +1,7 @@ +//! Scarb extensions for Sozo. + +pub mod filesystem; +pub mod workspace; + +pub use filesystem::FilesystemExt; +pub use workspace::WorkspaceExt; diff --git a/crates/sozo/scarbext/src/workspace.rs b/crates/sozo/scarbext/src/workspace.rs new file mode 100644 index 0000000000..fa37ec698d --- /dev/null +++ b/crates/sozo/scarbext/src/workspace.rs @@ -0,0 +1,138 @@ +use std::fs; +use std::ops::DerefMut; + +use anyhow::Result; +use dojo_world::config::ProfileConfig; +use dojo_world::local::WorldLocal; +use scarb::core::Workspace; +use scarb::flock::Filesystem; +use serde::Serialize; + +use crate::filesystem::FilesystemExt; + +/// Extension trait for the [`Workspace`] type. +pub trait WorkspaceExt { + /// Returns the target directory for the current profile. + fn target_dir_profile(&self) -> Filesystem; + /// Checks if the current profile is valid for the workspace. + fn profile_check(&self) -> Result<()>; + /// Cleans the target directory for the current profile. + fn clean_dir_profile(&self); + /// Cleans the target directory for all profiles. + fn clean_dir_all_profiles(&self); + /// Checks if the current profile has generated artifacts. + fn ensure_profile_artifacts(&self) -> Result<()>; + /// Loads the profile config for the current profile. + fn load_profile_config(&self) -> Result; + /// Loads the local world from the workspace configuration. + fn load_world_local(&self) -> Result; + /// Writes the manifest for the current profile. + fn write_manifest_profile(&self, manifest: impl Serialize) -> Result<()>; +} + +impl WorkspaceExt for Workspace<'_> { + fn target_dir_profile(&self) -> Filesystem { + self.target_dir() + .child(self.current_profile().expect("Current profile always exists").as_str()) + } + + fn profile_check(&self) -> Result<()> { + if let Err(e) = self.current_profile() { + if e.to_string().contains("has no profile") { + // Extract the profile name from the error message + if let Some(profile_name) = e.to_string().split('`').nth(3) { + anyhow::bail!( + "Profile '{}' not found in workspace. Consider adding [profile.{}] to \ + your Scarb.toml to declare the profile.", + profile_name, + profile_name + ); + } + } + anyhow::bail!("Profile check failed: {}", e); + } + + Ok(()) + } + + fn clean_dir_profile(&self) { + let target_dir = self.target_dir_profile(); + // Ignore errors since the directory might not exist. + let _ = fs::remove_dir_all(target_dir.to_string()); + } + + fn clean_dir_all_profiles(&self) { + let target_dir = self.target_dir(); + // Ignore errors since the directory might not exist. + let _ = fs::remove_dir_all(target_dir.to_string()); + } + + fn ensure_profile_artifacts(&self) -> Result<()> { + let profile_name = self.current_profile()?.to_string(); + + if !self.target_dir_profile().exists() || self.target_dir_profile().list_files()?.is_empty() + { + if profile_name == "dev" { + anyhow::bail!( + "No artifacts generated for the 'dev' profile. Run `sozo build` to generate \ + them since it's the default profile." + ); + } else { + anyhow::bail!( + "Target directory for profile '{}' does not exist or is empty, run `sozo \ + build --profile {}` to generate it.", + profile_name, + profile_name + ); + } + } + + Ok(()) + } + + fn load_profile_config(&self) -> Result { + // Safe to unwrap since manifest is a file. + let manifest_dir = self.manifest_path().parent().unwrap().to_path_buf(); + let profile_str = + self.current_profile().expect("Scarb profile expected to be defined.").to_string(); + + let dev_config_path = manifest_dir.join("dojo_dev.toml"); + let config_path = manifest_dir.join(format!("dojo_{}.toml", &profile_str)); + + if !dev_config_path.exists() { + return Err(anyhow::anyhow!( + "Profile configuration file not found for profile `{}`. Expected at {}.", + &profile_str, + dev_config_path + )); + } + + // If the profile file is not found, default to `dev.toml` file that must exist. + let config_path = if !config_path.exists() { dev_config_path } else { config_path }; + + let content = fs::read_to_string(&config_path)?; + let config: ProfileConfig = toml::from_str(&content)?; + + Ok(config) + } + + fn load_world_local(&self) -> Result { + WorldLocal::from_directory( + self.target_dir_profile().to_string(), + self.load_profile_config()?, + ) + } + + fn write_manifest_profile(&self, manifest: impl Serialize) -> Result<()> { + let profile_name = self.current_profile()?.to_string(); + let manifest_name = format!("manifest_{}.json", &profile_name); + + let manifest_dir = self.manifest_path().parent().unwrap(); + let manifest_dir = Filesystem::new(manifest_dir.into()); + + let mut file = + manifest_dir.create_rw(manifest_name, "Dojo manifest file", self.config())?; + + Ok(serde_json::to_writer_pretty(file.deref_mut(), &manifest)?) + } +} diff --git a/crates/sozo/walnut/Cargo.toml b/crates/sozo/walnut/Cargo.toml index 82dfb5325f..0a9cf690eb 100644 --- a/crates/sozo/walnut/Cargo.toml +++ b/crates/sozo/walnut/Cargo.toml @@ -8,12 +8,13 @@ version.workspace = true [dependencies] anyhow.workspace = true console.workspace = true -dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } +dojo-world.workspace = true reqwest.workspace = true scarb.workspace = true scarb-ui.workspace = true serde.workspace = true serde_json.workspace = true +sozo-scarbext.workspace = true starknet.workspace = true thiserror.workspace = true url.workspace = true diff --git a/crates/sozo/walnut/src/debugger.rs b/crates/sozo/walnut/src/debugger.rs index b7997b0071..0edd38b80c 100644 --- a/crates/sozo/walnut/src/debugger.rs +++ b/crates/sozo/walnut/src/debugger.rs @@ -1,4 +1,4 @@ -use dojo_world::migration::strategy::MigrationStrategy; +use dojo_world::diff::WorldDiff; use scarb::core::Workspace; use scarb_ui::Ui; use starknet::core::types::Felt; @@ -37,9 +37,9 @@ impl WalnutDebugger { pub async fn verify_migration_strategy( &self, ws: &Workspace<'_>, - strategy: &MigrationStrategy, + world_diff: &WorldDiff, ) -> anyhow::Result<()> { - walnut_verify_migration_strategy(ws, self.rpc_url.to_string(), strategy).await + walnut_verify_migration_strategy(ws, self.rpc_url.to_string(), world_diff).await } /// Checks if the Walnut API key is set. diff --git a/crates/sozo/walnut/src/verification.rs b/crates/sozo/walnut/src/verification.rs index b803038cfc..ca11be74ad 100644 --- a/crates/sozo/walnut/src/verification.rs +++ b/crates/sozo/walnut/src/verification.rs @@ -3,12 +3,15 @@ use std::io; use std::path::Path; use console::{pad_str, Alignment, Style, StyledObject}; -use dojo_world::metadata::get_default_namespace_from_ws; -use dojo_world::migration::strategy::MigrationStrategy; +use dojo_world::diff::{ResourceDiff, WorldDiff}; +use dojo_world::local::ResourceLocal; +use dojo_world::remote::ResourceRemote; +use dojo_world::ResourceType; use reqwest::StatusCode; use scarb::core::Workspace; use serde::Serialize; use serde_json::Value; +use sozo_scarbext::WorkspaceExt; use walkdir::WalkDir; use crate::utils::{walnut_get_api_key, walnut_get_api_url}; @@ -25,7 +28,7 @@ use crate::Error; pub async fn walnut_verify_migration_strategy( ws: &Workspace<'_>, rpc_url: String, - migration_strategy: &MigrationStrategy, + world_diff: &WorldDiff, ) -> anyhow::Result<()> { let ui = ws.config().ui(); // Check if rpc_url is localhost @@ -36,69 +39,56 @@ pub async fn walnut_verify_migration_strategy( return Ok(()); } - // its path to a file so `parent` should never return `None` - let root_dir: &Path = ws.manifest_path().parent().unwrap().as_std_path(); - let default_namespace = get_default_namespace_from_ws(ws)?; - // Check if there are any contracts or models in the strategy - if migration_strategy.contracts.is_empty() && migration_strategy.models.is_empty() { + if world_diff.is_synced() { ui.print(" "); ui.print("🌰 No contracts or models to verify."); ui.print(" "); return Ok(()); } + let _profile_config = ws.load_profile_config()?; + + for (_selector, resource) in world_diff.resources.iter() { + if resource.resource_type() == ResourceType::Contract { + match resource { + ResourceDiff::Created(ResourceLocal::Contract(_contract)) => { + // Need to verify created. + } + ResourceDiff::Updated(_, ResourceRemote::Contract(_contract)) => { + // Need to verify updated. + } + _ => { + // Synced, we don't need to verify. + } + } + } + } + // Notify start of verification ui.print(" "); ui.print("🌰 Verifying classes with Walnut..."); ui.print(" "); // Retrieve the API key and URL from environment variables - let api_key = walnut_get_api_key()?; - let api_url = walnut_get_api_url(); + let _api_key = walnut_get_api_key()?; + let _api_url = walnut_get_api_url(); // Collect source code - let source_code = collect_source_code(root_dir)?; - - let mut class_names = Vec::new(); - let mut class_hashes = Vec::new(); - - for contract_migration in &migration_strategy.contracts { - let class_name = get_class_name_from_artifact_path( - &contract_migration.artifact_path, - &default_namespace, - )?; - class_names.push(class_name); - class_hashes.push(contract_migration.diff.local_class_hash.to_hex_string()); - } - - for class_migration in &migration_strategy.models { - let class_name = - get_class_name_from_artifact_path(&class_migration.artifact_path, &default_namespace)?; - class_names.push(class_name); - class_hashes.push(class_migration.diff.local_class_hash.to_hex_string()); - } - - let verification_payload = - VerificationPayload { class_names, class_hashes, rpc_url, source_code }; - - // Send verification request - match verify_classes(verification_payload, &api_url, &api_key).await { - Ok(message) => ui.print(subtitle(message)), - Err(e) => ui.print(subtitle(e.to_string())), - } + // TODO: now it's the same output as scarb, need to update the dojo fork to output the source + // code, or does scarb supports it already? Ok(()) } -fn get_class_name_from_artifact_path(path: &Path, namespace: &str) -> Result { +fn _get_class_name_from_artifact_path(path: &Path, namespace: &str) -> Result { let file_name = path.file_stem().and_then(OsStr::to_str).ok_or(Error::InvalidFileName)?; let class_name = file_name.strip_prefix(namespace).ok_or(Error::NamespacePrefixNotFound)?; Ok(class_name.to_string()) } #[derive(Debug, Serialize)] -struct VerificationPayload { +struct _VerificationPayload { /// The names of the classes we want to verify together with the selector. pub class_names: Vec, /// The hashes of the Sierra classes. @@ -110,8 +100,8 @@ struct VerificationPayload { pub source_code: Value, } -async fn verify_classes( - payload: VerificationPayload, +async fn _verify_classes( + payload: _VerificationPayload, api_url: &str, api_key: &str, ) -> Result { @@ -129,7 +119,7 @@ async fn verify_classes( } } -fn collect_source_code(root_dir: &Path) -> Result { +fn _collect_source_code(root_dir: &Path) -> Result { fn collect_files( root_dir: &Path, search_dir: &Path, @@ -170,11 +160,11 @@ fn collect_source_code(root_dir: &Path) -> Result { Ok(serde_json::Value::Object(file_data)) } -fn subtitle>(message: D) -> String { - dimmed_message(format!("{} {}", pad_str(">", 3, Alignment::Right, None), message.as_ref())) +fn _subtitle>(message: D) -> String { + _dimmed_message(format!("{} {}", pad_str(">", 3, Alignment::Right, None), message.as_ref())) .to_string() } -fn dimmed_message(message: D) -> StyledObject { +fn _dimmed_message(message: D) -> StyledObject { Style::new().dim().apply_to(message) } diff --git a/crates/torii/client/Cargo.toml b/crates/torii/client/Cargo.toml index 0c7f7ec51b..d534123d07 100644 --- a/crates/torii/client/Cargo.toml +++ b/crates/torii/client/Cargo.toml @@ -9,7 +9,7 @@ version.workspace = true async-trait.workspace = true crypto-bigint.workspace = true dojo-types.workspace = true -dojo-world = { workspace = true, features = [ "contracts" ] } +dojo-world.workspace = true futures.workspace = true futures-util.workspace = true num-traits.workspace = true diff --git a/crates/torii/client/src/client/mod.rs b/crates/torii/client/src/client/mod.rs index 9f47b613f2..391cad9ebb 100644 --- a/crates/torii/client/src/client/mod.rs +++ b/crates/torii/client/src/client/mod.rs @@ -99,10 +99,14 @@ impl Client { } /// Similary to entities, this function retrieves event messages matching the query parameter. - pub async fn event_messages(&self, query: Query) -> Result, Error> { + pub async fn event_messages( + &self, + query: Query, + historical: bool, + ) -> Result, Error> { let mut grpc_client = self.inner.write().await; let RetrieveEntitiesResponse { entities, total_count: _ } = - grpc_client.retrieve_event_messages(query).await?; + grpc_client.retrieve_event_messages(query, historical).await?; Ok(entities.into_iter().map(TryInto::try_into).collect::, _>>()?) } @@ -139,9 +143,10 @@ impl Client { pub async fn on_event_message_updated( &self, clauses: Vec, + historical: bool, ) -> Result { let mut grpc_client = self.inner.write().await; - let stream = grpc_client.subscribe_event_messages(clauses).await?; + let stream = grpc_client.subscribe_event_messages(clauses, historical).await?; Ok(stream) } @@ -150,9 +155,12 @@ impl Client { &self, subscription_id: u64, clauses: Vec, + historical: bool, ) -> Result<(), Error> { let mut grpc_client = self.inner.write().await; - grpc_client.update_event_messages_subscription(subscription_id, clauses).await?; + grpc_client + .update_event_messages_subscription(subscription_id, clauses, historical) + .await?; Ok(()) } diff --git a/crates/torii/core/Cargo.toml b/crates/torii/core/Cargo.toml index 30040d528b..345ded02e9 100644 --- a/crates/torii/core/Cargo.toml +++ b/crates/torii/core/Cargo.toml @@ -17,7 +17,7 @@ cainome.workspace = true chrono.workspace = true crypto-bigint.workspace = true dojo-types.workspace = true -dojo-world = { workspace = true, features = [ "contracts", "manifest" ] } +dojo-world.workspace = true futures-channel = "0.3.0" futures-util.workspace = true hashlink.workspace = true @@ -31,16 +31,16 @@ sqlx.workspace = true starknet-crypto.workspace = true starknet.workspace = true thiserror.workspace = true -tokio = { version = "1.32.0", features = [ "sync" ], default-features = true } +tokio = { version = "1.32.0", features = [ "sync", "macros" ], default-features = true } # tokio-stream = "0.1.11" tokio-util.workspace = true toml.workspace = true tracing.workspace = true [dev-dependencies] -camino.workspace = true dojo-test-utils.workspace = true dojo-utils.workspace = true katana-runner.workspace = true scarb.workspace = true tempfile.workspace = true +sozo-scarbext.workspace = true diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index ed51840ae6..f060500f89 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -30,6 +30,8 @@ use crate::processors::erc721_legacy_transfer::Erc721LegacyTransferProcessor; use crate::processors::erc721_transfer::Erc721TransferProcessor; use crate::processors::event_message::EventMessageProcessor; use crate::processors::metadata_update::MetadataUpdateProcessor; +use crate::processors::raw_event::RawEventProcessor; +use crate::processors::register_event::RegisterEventProcessor; use crate::processors::register_model::RegisterModelProcessor; use crate::processors::store_del_record::StoreDelRecordProcessor; use crate::processors::store_set_record::StoreSetRecordProcessor; @@ -54,7 +56,9 @@ impl Default for Processo Self { block: vec![], transaction: vec![], - catch_all_event: Box::new(EventMessageProcessor) as Box>, + // We shouldn't have a catch all for now since the world doesn't forward raw events + // anymore. + catch_all_event: Box::new(RawEventProcessor) as Box>, event_processors: Self::initialize_event_processors(), } } @@ -69,11 +73,13 @@ impl Processors

{ ContractType::WORLD, vec![ Box::new(RegisterModelProcessor) as Box>, + Box::new(RegisterEventProcessor) as Box>, Box::new(StoreSetRecordProcessor), - Box::new(MetadataUpdateProcessor), Box::new(StoreDelRecordProcessor), Box::new(StoreUpdateRecordProcessor), Box::new(StoreUpdateMemberProcessor), + Box::new(MetadataUpdateProcessor), + Box::new(EventMessageProcessor), ], ), ( @@ -820,8 +826,8 @@ impl Engine

{ let task_identifier = match processor.event_key().as_str() { "StoreSetRecord" | "StoreUpdateRecord" | "StoreUpdateMember" | "StoreDelRecord" => { let mut hasher = DefaultHasher::new(); - event.data[0].hash(&mut hasher); - event.data[1].hash(&mut hasher); + event.keys[0].hash(&mut hasher); + event.keys[1].hash(&mut hasher); hasher.finish() } _ => 0, diff --git a/crates/torii/core/src/executor.rs b/crates/torii/core/src/executor.rs index 04d64676b9..4e551b5e4f 100644 --- a/crates/torii/core/src/executor.rs +++ b/crates/torii/core/src/executor.rs @@ -81,6 +81,17 @@ pub struct UpdateCursorsQuery { pub pending_block_timestamp: u64, } +#[derive(Debug, Clone)] +pub struct EventMessageQuery { + pub entity_id: String, + pub model_id: String, + pub keys_str: String, + pub event_id: String, + pub block_timestamp: String, + pub is_historical: bool, + pub ty: Ty, +} + #[derive(Debug, Clone)] pub enum QueryType { SetHead(SetHeadQuery), @@ -88,7 +99,7 @@ pub enum QueryType { UpdateCursors(UpdateCursorsQuery), SetEntity(Ty), DeleteEntity(DeleteEntityQuery), - EventMessage(Ty), + EventMessage(EventMessageQuery), ApplyBalanceDiff(ApplyBalanceDiffQuery), RegisterModel, StoreEvent, @@ -437,12 +448,61 @@ impl<'c> Executor<'c> { let model_registered = ModelRegistered::from_row(&row)?; self.publish_queue.push(BrokerMessage::ModelRegistered(model_registered)); } - QueryType::EventMessage(entity) => { - let row = query.fetch_one(&mut **tx).await.with_context(|| { + QueryType::EventMessage(em_query) => { + // Must be executed first since other tables have foreign keys on event_messages.id. + let event_messages_row = query.fetch_one(&mut **tx).await.with_context(|| { format!("Failed to execute query: {:?}, args: {:?}", statement, arguments) })?; - let mut event_message = EventMessageUpdated::from_row(&row)?; - event_message.updated_model = Some(entity); + + let mut event_counter: i64 = sqlx::query_scalar::<_, i64>( + "SELECT historical_counter FROM event_model WHERE entity_id = ? AND model_id \ + = ?", + ) + .bind(em_query.entity_id.clone()) + .bind(em_query.model_id.clone()) + .fetch_optional(&mut **tx) + .await + .map_or(0, |counter| counter.unwrap_or(0)); + + if em_query.is_historical { + event_counter += 1; + + let data = em_query + .ty + .serialize()? + .iter() + .map(|felt| format!("{:#x}", felt)) + .collect::>() + .join("/"); + + sqlx::query( + "INSERT INTO event_messages_historical (id, keys, event_id, data, \ + model_id, executed_at) VALUES (?, ?, ?, ?, ?, ?) RETURNING *", + ) + .bind(em_query.entity_id.clone()) + .bind(em_query.keys_str.clone()) + .bind(em_query.event_id.clone()) + .bind(data) + .bind(em_query.model_id.clone()) + .bind(em_query.block_timestamp.clone()) + .fetch_one(&mut **tx) + .await?; + } + + sqlx::query( + "INSERT INTO event_model (entity_id, model_id, historical_counter) VALUES (?, \ + ?, ?) ON CONFLICT(entity_id, model_id) DO UPDATE SET \ + historical_counter=EXCLUDED.historical_counter", + ) + .bind(em_query.entity_id.clone()) + .bind(em_query.model_id.clone()) + .bind(event_counter) + .execute(&mut **tx) + .await?; + + let mut event_message = EventMessageUpdated::from_row(&event_messages_row)?; + event_message.updated_model = Some(em_query.ty); + event_message.historical = em_query.is_historical; let optimistic_event_message = OptimisticEventMessage { id: event_message.id.clone(), @@ -452,6 +512,7 @@ impl<'c> Executor<'c> { created_at: event_message.created_at, updated_at: event_message.updated_at, updated_model: event_message.updated_model.clone(), + historical: event_message.historical, }; SimpleBroker::publish(optimistic_event_message); diff --git a/crates/torii/core/src/model.rs b/crates/torii/core/src/model.rs index 7fb097b33b..b45c8338fa 100644 --- a/crates/torii/core/src/model.rs +++ b/crates/torii/core/src/model.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use crypto_bigint::U256; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; -use dojo_world::contracts::abi::model::Layout; +use dojo_world::contracts::abigen::model::Layout; use dojo_world::contracts::model::ModelReader; use sqlx::sqlite::SqliteRow; use sqlx::{Pool, Row, Sqlite}; diff --git a/crates/torii/core/src/processors/event_message.rs b/crates/torii/core/src/processors/event_message.rs index e2044cbe1a..ec52d5b698 100644 --- a/crates/torii/core/src/processors/event_message.rs +++ b/crates/torii/core/src/processors/event_message.rs @@ -1,12 +1,12 @@ use anyhow::{Error, Result}; use async_trait::async_trait; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; -use starknet::core::types::Event; +use starknet::core::types::{Event, Felt}; use starknet::providers::Provider; use tracing::info; use super::EventProcessor; -use crate::processors::MODEL_INDEX; use crate::sql::Sql; pub(crate) const LOG_TARGET: &str = "torii_core::processors::event_message"; @@ -20,18 +20,10 @@ where P: Provider + Send + Sync + std::fmt::Debug, { fn event_key(&self) -> String { - "".to_string() + "EventEmitted".to_string() } - fn validate(&self, event: &Event) -> bool { - // we expect at least 3 keys - // 1: event selector - // 2: model keys, arbitrary length - // last key: system key - if event.keys.len() < 3 { - return false; - } - + fn validate(&self, _event: &Event) -> bool { true } @@ -44,27 +36,42 @@ where event_id: &str, event: &Event, ) -> Result<(), Error> { + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::EventEmitted(e) => e, + _ => { + unreachable!() + } + }; + // silently ignore if the model is not found - let model = match db.model(event.keys[MODEL_INDEX]).await { + let model = match db.model(event.selector).await { Ok(model) => model, Err(_) => return Ok(()), }; info!( target: LOG_TARGET, - model = %model.name, + namespace = %model.namespace, + name = %model.name, + system = %format!("{:#x}", Felt::from(event.system_address)), "Store event message." ); - // skip the first key, as its the event selector - // and dont include last key as its the system key - let mut keys_and_unpacked = - [event.keys[1..event.keys.len() - 1].to_vec(), event.data.clone()].concat(); + // TODO: check historical and keep the internal counter. + + let mut keys_and_unpacked = [event.keys, event.values].concat(); let mut entity = model.schema.clone(); entity.deserialize(&mut keys_and_unpacked)?; - db.set_event_message(entity, event_id, block_timestamp).await?; + db.set_event_message(entity, event_id, block_timestamp, event.historical).await?; Ok(()) } } diff --git a/crates/torii/core/src/processors/metadata_update.rs b/crates/torii/core/src/processors/metadata_update.rs index 4b17858d89..8a1b68f7c2 100644 --- a/crates/torii/core/src/processors/metadata_update.rs +++ b/crates/torii/core/src/processors/metadata_update.rs @@ -4,9 +4,10 @@ use anyhow::{Error, Result}; use async_trait::async_trait; use base64::engine::general_purpose; use base64::Engine as _; -use cainome::cairo_serde::{ByteArray, CairoSerde, Zeroable}; +use cainome::cairo_serde::Zeroable; +use dojo_world::config::WorldMetadata; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; -use dojo_world::metadata::WorldMetadata; use dojo_world::uri::Uri; use reqwest::Client; use starknet::core::types::{Event, Felt}; @@ -34,16 +35,7 @@ where "MetadataUpdate".to_string() } - fn validate(&self, event: &Event) -> bool { - if event.keys.len() > 1 { - info!( - target: LOG_TARGET, - event_key = %>::event_key(self), - invalid_keys = %>::event_keys_as_string(self, event), - "Invalid event keys." - ); - return false; - } + fn validate(&self, _event: &Event) -> bool { true } @@ -56,23 +48,36 @@ where _event_id: &str, event: &Event, ) -> Result<(), Error> { - let resource = &event.data[0]; - let uri_str = ByteArray::cairo_deserialize(&event.data, 1)?.to_string()?; + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::MetadataUpdate(e) => e, + _ => { + unreachable!() + } + }; + + // We know it's a valid Byte Array since it's coming from the world. + let uri_str = event.uri.to_string().unwrap(); info!( target: LOG_TARGET, - resource = %format!("{:#x}", resource), + resource = %format!("{:#x}", event.resource), uri = %uri_str, "Resource metadata set." ); - db.set_metadata(resource, &uri_str, block_timestamp)?; + db.set_metadata(&event.resource, &uri_str, block_timestamp)?; let db = db.clone(); - let resource = *resource; // Only retrieve metadata for the World contract. - if resource.is_zero() { + if event.resource.is_zero() { tokio::spawn(async move { - try_retrieve(db, resource, uri_str).await; + try_retrieve(db, event.resource, uri_str).await; }); } diff --git a/crates/torii/core/src/processors/mod.rs b/crates/torii/core/src/processors/mod.rs index cf25f36ca6..58dad65928 100644 --- a/crates/torii/core/src/processors/mod.rs +++ b/crates/torii/core/src/processors/mod.rs @@ -12,6 +12,8 @@ pub mod erc721_legacy_transfer; pub mod erc721_transfer; pub mod event_message; pub mod metadata_update; +pub mod raw_event; +pub mod register_event; pub mod register_model; pub mod store_del_record; pub mod store_set_record; @@ -21,7 +23,6 @@ pub mod store_update_record; const MODEL_INDEX: usize = 0; const ENTITY_ID_INDEX: usize = 1; -const NUM_KEYS_INDEX: usize = 2; #[async_trait] pub trait EventProcessor

: Send + Sync diff --git a/crates/torii/core/src/processors/raw_event.rs b/crates/torii/core/src/processors/raw_event.rs new file mode 100644 index 0000000000..079247dc54 --- /dev/null +++ b/crates/torii/core/src/processors/raw_event.rs @@ -0,0 +1,39 @@ +use anyhow::{Error, Result}; +use async_trait::async_trait; +use dojo_world::contracts::world::WorldContractReader; +use starknet::core::types::Event; +use starknet::providers::Provider; + +use super::EventProcessor; +use crate::sql::Sql; + +#[derive(Default, Debug)] +pub struct RawEventProcessor; + +#[async_trait] +impl

EventProcessor

for RawEventProcessor +where + P: Provider + Send + Sync + std::fmt::Debug, +{ + fn event_key(&self) -> String { + "".to_string() + } + + fn validate(&self, _event: &Event) -> bool { + true + } + + async fn process( + &self, + _world: &WorldContractReader

, + _db: &mut Sql, + _block_number: u64, + _block_timestamp: u64, + _event_id: &str, + _event: &Event, + ) -> Result<(), Error> { + // We can choose to consider them, or not. + + Ok(()) + } +} diff --git a/crates/torii/core/src/processors/register_event.rs b/crates/torii/core/src/processors/register_event.rs new file mode 100644 index 0000000000..79ab0067f0 --- /dev/null +++ b/crates/torii/core/src/processors/register_event.rs @@ -0,0 +1,103 @@ +use anyhow::{Error, Ok, Result}; +use async_trait::async_trait; +use dojo_world::contracts::abigen::world::Event as WorldEvent; +use dojo_world::contracts::model::ModelReader; +use dojo_world::contracts::world::WorldContractReader; +use starknet::core::types::Event; +use starknet::providers::Provider; +use tracing::{debug, info}; + +use super::EventProcessor; +use crate::sql::Sql; + +pub(crate) const LOG_TARGET: &str = "torii_core::processors::register_event"; + +#[derive(Default, Debug)] +pub struct RegisterEventProcessor; + +#[async_trait] +impl

EventProcessor

for RegisterEventProcessor +where + P: Provider + Send + Sync + std::fmt::Debug, +{ + fn event_key(&self) -> String { + "EventRegistered".to_string() + } + + // We might not need this anymore, since we don't have fallback and all world events must + // be handled. + fn validate(&self, _event: &Event) -> bool { + true + } + + async fn process( + &self, + world: &WorldContractReader

, + db: &mut Sql, + _block_number: u64, + block_timestamp: u64, + _event_id: &str, + event: &Event, + ) -> Result<(), Error> { + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::EventRegistered(e) => e, + _ => { + unreachable!() + } + }; + + // Safe to unwrap, since it's coming from the chain. + let namespace = event.namespace.to_string().unwrap(); + let name = event.name.to_string().unwrap(); + + // Called model here by language, but it's an event. Torii rework will make clear + // distinction. + let model = world.model_reader(&namespace, &name).await?; + let schema = model.schema().await?; + let layout = model.layout().await?; + + // Events are never stored onchain, hence no packing or unpacking. + let unpacked_size: u32 = 0; + let packed_size: u32 = 0; + + info!( + target: LOG_TARGET, + namespace = %namespace, + name = %name, + "Registered event." + ); + + debug!( + target: LOG_TARGET, + name, + schema = ?schema, + layout = ?layout, + class_hash = ?event.class_hash, + contract_address = ?event.address, + packed_size = %packed_size, + unpacked_size = %unpacked_size, + "Registered model content." + ); + + db.register_model( + &namespace, + schema, + layout, + event.class_hash.into(), + event.address.into(), + packed_size, + unpacked_size, + block_timestamp, + ) + .await?; + + Ok(()) + } +} diff --git a/crates/torii/core/src/processors/register_model.rs b/crates/torii/core/src/processors/register_model.rs index 369357a243..6f25230b39 100644 --- a/crates/torii/core/src/processors/register_model.rs +++ b/crates/torii/core/src/processors/register_model.rs @@ -1,6 +1,6 @@ use anyhow::{Error, Ok, Result}; use async_trait::async_trait; -use cainome::cairo_serde::{ByteArray, CairoSerde}; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::model::ModelReader; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::Event; @@ -24,16 +24,9 @@ where "ModelRegistered".to_string() } - fn validate(&self, event: &Event) -> bool { - if event.keys.len() > 1 { - info!( - target: LOG_TARGET, - event_key = %>::event_key(self), - invalid_keys = %>::event_keys_as_string(self, event), - "Invalid event keys." - ); - return false; - } + // We might not need this anymore, since we don't have fallback and all world events must + // be handled. + fn validate(&self, _event: &Event) -> bool { true } @@ -46,13 +39,23 @@ where _event_id: &str, event: &Event, ) -> Result<(), Error> { - let name = ByteArray::cairo_deserialize(&event.data, 0)?; - let mut offset = ByteArray::cairo_serialized_size(&name); - let namespace = ByteArray::cairo_deserialize(&event.data, offset)?; - offset += ByteArray::cairo_serialized_size(&namespace); + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::ModelRegistered(e) => e, + _ => { + unreachable!() + } + }; - let name = name.to_string()?; - let namespace = namespace.to_string()?; + // Safe to unwrap, since it's coming from the chain. + let namespace = event.namespace.to_string().unwrap(); + let name = event.name.to_string().unwrap(); let model = world.model_reader(&namespace, &name).await?; let schema = model.schema().await?; @@ -61,21 +64,20 @@ where let unpacked_size: u32 = model.unpacked_size().await?; let packed_size: u32 = model.packed_size().await?; - let class_hash = event.data[offset]; - let contract_address = event.data[offset + 1]; - info!( target: LOG_TARGET, + namespace = %namespace, name = %name, "Registered model." ); + debug!( target: LOG_TARGET, - name = %name, + name, schema = ?schema, layout = ?layout, - class_hash = ?class_hash, - contract_address = ?contract_address, + class_hash = ?event.class_hash, + contract_address = ?event.address, packed_size = %packed_size, unpacked_size = %unpacked_size, "Registered model content." @@ -85,8 +87,8 @@ where &namespace, schema, layout, - class_hash, - contract_address, + event.class_hash.into(), + event.address.into(), packed_size, unpacked_size, block_timestamp, diff --git a/crates/torii/core/src/processors/store_del_record.rs b/crates/torii/core/src/processors/store_del_record.rs index 2226d4c92f..99f8ba579d 100644 --- a/crates/torii/core/src/processors/store_del_record.rs +++ b/crates/torii/core/src/processors/store_del_record.rs @@ -1,12 +1,12 @@ use anyhow::{Error, Ok, Result}; use async_trait::async_trait; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::Event; use starknet::providers::Provider; use tracing::info; use super::EventProcessor; -use crate::processors::{ENTITY_ID_INDEX, MODEL_INDEX}; use crate::sql::Sql; pub(crate) const LOG_TARGET: &str = "torii_core::processors::store_del_record"; @@ -23,16 +23,7 @@ where "StoreDelRecord".to_string() } - fn validate(&self, event: &Event) -> bool { - if event.keys.len() > 1 { - info!( - target: LOG_TARGET, - event_key = %>::event_key(self), - invalid_keys = %>::event_keys_as_string(self, event), - "Invalid event keys." - ); - return false; - } + fn validate(&self, _event: &Event) -> bool { true } @@ -45,20 +36,34 @@ where event_id: &str, event: &Event, ) -> Result<(), Error> { - let selector = event.data[MODEL_INDEX]; + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::StoreDelRecord(e) => e, + _ => { + unreachable!() + } + }; - let model = db.model(selector).await?; + let model = db.model(event.selector).await?; info!( target: LOG_TARGET, + namespace = %model.namespace, name = %model.name, + entity_id = format!("{:#x}", event.entity_id), "Store delete record." ); - let entity_id = event.data[ENTITY_ID_INDEX]; let entity = model.schema; - db.delete_entity(entity_id, selector, entity, event_id, block_timestamp).await?; + db.delete_entity(event.entity_id, event.selector, entity, event_id, block_timestamp) + .await?; Ok(()) } diff --git a/crates/torii/core/src/processors/store_set_record.rs b/crates/torii/core/src/processors/store_set_record.rs index fa1351b156..5faebc9855 100644 --- a/crates/torii/core/src/processors/store_set_record.rs +++ b/crates/torii/core/src/processors/store_set_record.rs @@ -1,13 +1,12 @@ -use anyhow::{Context, Error, Ok, Result}; +use anyhow::{Error, Ok, Result}; use async_trait::async_trait; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; -use num_traits::ToPrimitive; use starknet::core::types::Event; use starknet::providers::Provider; use tracing::info; use super::EventProcessor; -use crate::processors::{ENTITY_ID_INDEX, MODEL_INDEX, NUM_KEYS_INDEX}; use crate::sql::utils::felts_to_sql_string; use crate::sql::Sql; @@ -25,16 +24,7 @@ where "StoreSetRecord".to_string() } - fn validate(&self, event: &Event) -> bool { - if event.keys.len() > 1 { - info!( - target: LOG_TARGET, - event_key = %>::event_key(self), - invalid_keys = %>::event_keys_as_string(self, event), - "Invalid event keys." - ); - return false; - } + fn validate(&self, _event: &Event) -> bool { true } @@ -47,38 +37,46 @@ where event_id: &str, event: &Event, ) -> Result<(), Error> { - let model_id = event.data[MODEL_INDEX]; + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::StoreSetRecord(e) => e, + _ => { + unreachable!() + } + }; - let model = db.model(model_id).await?; + let model = db.model(event.selector).await?; info!( target: LOG_TARGET, + namespace = %model.namespace, name = %model.name, + entity_id = format!("{:#x}", event.entity_id), "Store set record.", ); - let keys_start = NUM_KEYS_INDEX + 1; - let keys_end: usize = - keys_start + event.data[NUM_KEYS_INDEX].to_usize().context("invalid usize")?; - let keys = event.data[keys_start..keys_end].to_vec(); - let keys_str = felts_to_sql_string(&keys); + let keys_str = felts_to_sql_string(&event.keys); - // keys_end is already the length of the values array. - - let values_start = keys_end + 1; - let values_end: usize = - values_start + event.data[keys_end].to_usize().context("invalid usize")?; - - let values = event.data[values_start..values_end].to_vec(); - let entity_id = event.data[ENTITY_ID_INDEX]; - - let mut keys_and_unpacked = [keys, values].concat(); + let mut keys_and_unpacked = [event.keys, event.values].concat(); let mut entity = model.schema; entity.deserialize(&mut keys_and_unpacked)?; - db.set_entity(entity, event_id, block_timestamp, entity_id, model_id, Some(&keys_str)) - .await?; + db.set_entity( + entity, + event_id, + block_timestamp, + event.entity_id, + event.selector, + Some(&keys_str), + ) + .await?; Ok(()) } } diff --git a/crates/torii/core/src/processors/store_update_record.rs b/crates/torii/core/src/processors/store_update_record.rs index 374e6a5189..ae4bfdac91 100644 --- a/crates/torii/core/src/processors/store_update_record.rs +++ b/crates/torii/core/src/processors/store_update_record.rs @@ -1,14 +1,13 @@ -use anyhow::{Context, Error, Ok, Result}; +use anyhow::{Error, Ok, Result}; use async_trait::async_trait; use dojo_types::schema::Ty; +use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; -use num_traits::ToPrimitive; use starknet::core::types::Event; use starknet::providers::Provider; use tracing::info; use super::EventProcessor; -use crate::processors::{ENTITY_ID_INDEX, MODEL_INDEX}; use crate::sql::Sql; pub(crate) const LOG_TARGET: &str = "torii_core::processors::store_update_record"; @@ -25,16 +24,7 @@ where "StoreUpdateRecord".to_string() } - fn validate(&self, event: &Event) -> bool { - if event.keys.len() > 1 { - info!( - target: LOG_TARGET, - event_key = %>::event_key(self), - invalid_keys = %>::event_keys_as_string(self, event), - "Invalid event keys." - ); - return false; - } + fn validate(&self, _event: &Event) -> bool { true } @@ -47,25 +37,33 @@ where event_id: &str, event: &Event, ) -> Result<(), Error> { - let model_id = event.data[MODEL_INDEX]; - let entity_id = event.data[ENTITY_ID_INDEX]; + // Torii version is coupled to the world version, so we can expect the event to be well + // formed. + let event = match WorldEvent::try_from(event).unwrap_or_else(|_| { + panic!( + "Expected {} event to be well formed.", + >::event_key(self) + ) + }) { + WorldEvent::StoreUpdateRecord(e) => e, + _ => { + unreachable!() + } + }; + + let model_selector = event.selector; + let entity_id = event.entity_id; - let model = db.model(model_id).await?; + let model = db.model(model_selector).await?; info!( target: LOG_TARGET, + namespace = %model.namespace, name = %model.name, entity_id = format!("{:#x}", entity_id), "Store update record.", ); - let values_start = ENTITY_ID_INDEX + 1; - let values_end: usize = - values_start + event.data[values_start].to_usize().context("invalid usize")?; - - // Skip the length to only get the values as they will be deserialized. - let mut values = event.data[values_start + 1..=values_end].to_vec(); - let mut entity = model.schema; match entity { Ty::Struct(ref mut struct_) => { @@ -76,9 +74,10 @@ where _ => return Err(anyhow::anyhow!("Expected struct")), } + let mut values = event.values.to_vec(); entity.deserialize(&mut values)?; - db.set_entity(entity, event_id, block_timestamp, entity_id, model_id, None).await?; + db.set_entity(entity, event_id, block_timestamp, entity_id, model_selector, None).await?; Ok(()) } } diff --git a/crates/torii/core/src/sql/cache.rs b/crates/torii/core/src/sql/cache.rs index 8cbcba36ed..23da95bd34 100644 --- a/crates/torii/core/src/sql/cache.rs +++ b/crates/torii/core/src/sql/cache.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use dojo_types::schema::Ty; -use dojo_world::contracts::abi::model::Layout; +use dojo_world::contracts::abigen::model::Layout; use sqlx::{Pool, Sqlite, SqlitePool}; use starknet_crypto::Felt; use tokio::sync::RwLock; diff --git a/crates/torii/core/src/sql/mod.rs b/crates/torii/core/src/sql/mod.rs index ad00c34ca6..3c20222a9a 100644 --- a/crates/torii/core/src/sql/mod.rs +++ b/crates/torii/core/src/sql/mod.rs @@ -6,9 +6,9 @@ use std::sync::Arc; use anyhow::{anyhow, Context, Result}; use dojo_types::primitive::Primitive; use dojo_types::schema::{EnumOption, Member, Struct, Ty}; -use dojo_world::contracts::abi::model::Layout; +use dojo_world::config::WorldMetadata; +use dojo_world::contracts::abigen::model::Layout; use dojo_world::contracts::naming::compute_selector_from_names; -use dojo_world::metadata::WorldMetadata; use sqlx::pool::PoolConnection; use sqlx::{Pool, Sqlite}; use starknet::core::types::{Event, Felt, InvokeTransaction, Transaction}; @@ -17,8 +17,8 @@ use tokio::sync::mpsc::UnboundedSender; use utils::felts_to_sql_string; use crate::executor::{ - Argument, DeleteEntityQuery, QueryMessage, QueryType, ResetCursorsQuery, SetHeadQuery, - UpdateCursorsQuery, + Argument, DeleteEntityQuery, EventMessageQuery, QueryMessage, QueryType, ResetCursorsQuery, + SetHeadQuery, UpdateCursorsQuery, }; use crate::types::ContractType; use crate::utils::utc_dt_string_from_timestamp; @@ -392,6 +392,7 @@ impl Sql { entity: Ty, event_id: &str, block_timestamp: u64, + is_historical: bool, ) -> Result<()> { let keys = if let Ty::Struct(s) = &entity { let mut keys = Vec::new(); @@ -410,6 +411,8 @@ impl Sql { let model_id = format!("{:#x}", compute_selector_from_names(model_namespace, model_name)); let keys_str = felts_to_sql_string(&keys); + let block_timestamp_str = utc_dt_string_from_timestamp(block_timestamp); + let insert_entities = "INSERT INTO event_messages (id, keys, event_id, executed_at) \ VALUES (?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET \ updated_at=CURRENT_TIMESTAMP, executed_at=EXCLUDED.executed_at, \ @@ -418,17 +421,19 @@ impl Sql { insert_entities.to_string(), vec![ Argument::String(entity_id.clone()), - Argument::String(keys_str), + Argument::String(keys_str.clone()), Argument::String(event_id.to_string()), - Argument::String(utc_dt_string_from_timestamp(block_timestamp)), + Argument::String(block_timestamp_str.clone()), ], - QueryType::EventMessage(entity.clone()), - ))?; - self.executor.send(QueryMessage::other( - "INSERT INTO event_model (entity_id, model_id) VALUES (?, ?) ON CONFLICT(entity_id, \ - model_id) DO NOTHING" - .to_string(), - vec![Argument::String(entity_id.clone()), Argument::String(model_id.clone())], + QueryType::EventMessage(EventMessageQuery { + entity_id: entity_id.clone(), + model_id: model_id.clone(), + keys_str: keys_str.clone(), + event_id: event_id.to_string(), + block_timestamp: block_timestamp_str.clone(), + ty: entity.clone(), + is_historical, + }), ))?; let path = vec![namespaced_name]; diff --git a/crates/torii/core/src/sql/test.rs b/crates/torii/core/src/sql/test.rs index bd6fe9208a..fd1539b49c 100644 --- a/crates/torii/core/src/sql/test.rs +++ b/crates/torii/core/src/sql/test.rs @@ -3,18 +3,18 @@ use std::str::FromStr; use std::sync::Arc; use cainome::cairo_serde::ContractAddress; -use camino::Utf8PathBuf; use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::{copy_spawn_and_move_db, prepare_migration_with_world_and_seed}; +use dojo_test_utils::migration::copy_spawn_and_move_db; use dojo_utils::{TransactionExt, TransactionWaiter, TxnConfig}; use dojo_world::contracts::naming::{compute_bytearray_hash, compute_selector_from_names}; use dojo_world::contracts::world::{WorldContract, WorldContractReader}; use katana_runner::RunnerCtx; use scarb::compiler::Profile; +use sozo_scarbext::WorkspaceExt; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::accounts::Account; use starknet::core::types::{Call, Felt}; -use starknet::core::utils::{get_contract_address, get_selector_from_name}; +use starknet::core::utils::get_selector_from_name; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::{JsonRpcClient, Provider}; use starknet_crypto::poseidon_hash_many; @@ -59,37 +59,25 @@ where #[tokio::test(flavor = "multi_thread")] #[katana_runner::test(accounts = 10, db_dir = copy_spawn_and_move_db().as_str())] async fn test_load_from_remote(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let setup = CompilerTestSetup::from_examples("../../dojo/core", "../../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_dir = Utf8PathBuf::from(ws.target_dir().to_string()).join("dev"); let account = sequencer.account(0); let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_dir, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); + let world_local = ws.load_world_local().unwrap(); + let world_address = world_local.deterministic_world_address().unwrap(); - let actions = strat.contracts.first().unwrap(); - let actions_address = get_contract_address( - actions.salt, - strat.base.as_ref().unwrap().diff.local_class_hash, - &[], - strat.world_address, - ); + let actions_address = world_local + .get_contract_address_local(compute_selector_from_names("ns", "actions")) + .unwrap(); - let world = WorldContract::new(strat.world_address, &account); + let world = WorldContract::new(world_address, &account); let res = world - .grant_writer(&compute_bytearray_hash("dojo_examples"), &ContractAddress(actions_address)) + .grant_writer(&compute_bytearray_hash("ns"), &ContractAddress(actions_address)) .send_with_cfg(&TxnConfig::init_wait()) .await .unwrap(); @@ -122,7 +110,7 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { TransactionWaiter::new(tx.transaction_hash, &provider).await.unwrap(); - let world_reader = WorldContractReader::new(strat.world_address, Arc::clone(&provider)); + let world_reader = WorldContractReader::new(world_address, Arc::clone(&provider)); let tempfile = NamedTempFile::new().unwrap(); let path = tempfile.path().to_string_lossy(); @@ -148,7 +136,7 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { let _block_timestamp = 1710754478_u64; let models = sqlx::query("SELECT * FROM models").fetch_all(&pool).await.unwrap(); - assert_eq!(models.len(), 10); + assert_eq!(models.len(), 8); let (id, name, namespace, packed_size, unpacked_size): (String, String, String, u8, u8) = sqlx::query_as( @@ -159,9 +147,9 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { .await .unwrap(); - assert_eq!(id, format!("{:#x}", compute_selector_from_names("dojo_examples", "Position"))); + assert_eq!(id, format!("{:#x}", compute_selector_from_names("ns", "Position"))); assert_eq!(name, "Position"); - assert_eq!(namespace, "dojo_examples"); + assert_eq!(namespace, "ns"); assert_eq!(packed_size, 1); assert_eq!(unpacked_size, 2); @@ -174,9 +162,9 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { .await .unwrap(); - assert_eq!(id, format!("{:#x}", compute_selector_from_names("dojo_examples", "Moves"))); + assert_eq!(id, format!("{:#x}", compute_selector_from_names("ns", "Moves"))); assert_eq!(name, "Moves"); - assert_eq!(namespace, "dojo_examples"); + assert_eq!(namespace, "ns"); assert_eq!(packed_size, 0); assert_eq!(unpacked_size, 2); @@ -189,9 +177,9 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { .await .unwrap(); - assert_eq!(id, format!("{:#x}", compute_selector_from_names("dojo_examples", "PlayerConfig"))); + assert_eq!(id, format!("{:#x}", compute_selector_from_names("ns", "PlayerConfig"))); assert_eq!(name, "PlayerConfig"); - assert_eq!(namespace, "dojo_examples"); + assert_eq!(namespace, "ns"); assert_eq!(packed_size, 0); assert_eq!(unpacked_size, 0); @@ -213,39 +201,28 @@ async fn test_load_from_remote(sequencer: &RunnerCtx) { assert_eq!(keys, format!("{:#x}/", account.address())); } +#[ignore = "This test is being flaky and need to find why. Sometimes it fails, sometimes it passes."] #[tokio::test(flavor = "multi_thread")] #[katana_runner::test(accounts = 10, db_dir = copy_spawn_and_move_db().as_str())] async fn test_load_from_remote_del(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let setup = CompilerTestSetup::from_examples("../../dojo/core", "../../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_dir = Utf8PathBuf::from(ws.target_dir().to_string()).join("dev"); let account = sequencer.account(0); let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_dir, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); - let actions = strat.contracts.first().unwrap(); - let actions_address = get_contract_address( - actions.salt, - strat.base.as_ref().unwrap().diff.local_class_hash, - &[], - strat.world_address, - ); + let world_local = ws.load_world_local().unwrap(); + let world_address = world_local.deterministic_world_address().unwrap(); + let actions_address = world_local + .get_contract_address_local(compute_selector_from_names("ns", "actions")) + .unwrap(); - let world = WorldContract::new(strat.world_address, &account); + let world = WorldContract::new(world_address, &account); let res = world - .grant_writer(&compute_bytearray_hash("dojo_examples"), &ContractAddress(actions_address)) + .grant_writer(&compute_bytearray_hash("ns"), &ContractAddress(actions_address)) .send_with_cfg(&TxnConfig::init_wait()) .await .unwrap(); @@ -291,7 +268,7 @@ async fn test_load_from_remote_del(sequencer: &RunnerCtx) { TransactionWaiter::new(res.transaction_hash, &provider).await.unwrap(); - let world_reader = WorldContractReader::new(strat.world_address, Arc::clone(&provider)); + let world_reader = WorldContractReader::new(world_address, Arc::clone(&provider)); let tempfile = NamedTempFile::new().unwrap(); let path = tempfile.path().to_string_lossy(); @@ -315,9 +292,10 @@ async fn test_load_from_remote_del(sequencer: &RunnerCtx) { let _ = bootstrap_engine(world_reader, db.clone(), provider).await; - assert_eq!(count_table("dojo_examples-PlayerConfig", &pool).await, 0); - assert_eq!(count_table("dojo_examples-PlayerConfig$favorite_item", &pool).await, 0); - assert_eq!(count_table("dojo_examples-PlayerConfig$items", &pool).await, 0); + // TODO: seems that we don't delete the record after delete only values are zeroed? + assert_eq!(count_table("ns-PlayerConfig", &pool).await, 0); + assert_eq!(count_table("ns-PlayerConfig$favorite_item", &pool).await, 0); + assert_eq!(count_table("ns-PlayerConfig$items", &pool).await, 0); // TODO: check how we can have a test that is more chronological with Torii re-syncing // to ensure we can test intermediate states. @@ -326,37 +304,24 @@ async fn test_load_from_remote_del(sequencer: &RunnerCtx) { #[tokio::test(flavor = "multi_thread")] #[katana_runner::test(accounts = 10, db_dir = copy_spawn_and_move_db().as_str())] async fn test_update_with_set_record(sequencer: &RunnerCtx) { - let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let setup = CompilerTestSetup::from_examples("../../dojo/core", "../../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_dir = Utf8PathBuf::from(ws.target_dir().to_string()).join("dev"); - - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_dir, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); - let actions = strat.contracts.first().unwrap(); - let actions_address = get_contract_address( - actions.salt, - strat.base.as_ref().unwrap().diff.local_class_hash, - &[], - strat.world_address, - ); + let world_local = ws.load_world_local().unwrap(); + let world_address = world_local.deterministic_world_address().unwrap(); + let actions_address = world_local + .get_contract_address_local(compute_selector_from_names("ns", "actions")) + .unwrap(); let account = sequencer.account(0); let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); - let world = WorldContract::new(strat.world_address, &account); + let world = WorldContract::new(world_address, &account); let res = world - .grant_writer(&compute_bytearray_hash("dojo_examples"), &ContractAddress(actions_address)) + .grant_writer(&compute_bytearray_hash("ns"), &ContractAddress(actions_address)) .send_with_cfg(&TxnConfig::init_wait()) .await .unwrap(); @@ -389,7 +354,7 @@ async fn test_update_with_set_record(sequencer: &RunnerCtx) { TransactionWaiter::new(move_res.transaction_hash, &provider).await.unwrap(); - let world_reader = WorldContractReader::new(strat.world_address, Arc::clone(&provider)); + let world_reader = WorldContractReader::new(world_address, Arc::clone(&provider)); let tempfile = NamedTempFile::new().unwrap(); let path = tempfile.path().to_string_lossy(); diff --git a/crates/torii/core/src/sql/utils.rs b/crates/torii/core/src/sql/utils.rs index 66b345dd1a..9b7d2dad33 100644 --- a/crates/torii/core/src/sql/utils.rs +++ b/crates/torii/core/src/sql/utils.rs @@ -1,5 +1,6 @@ use std::cmp::Ordering; use std::ops::{Add, AddAssign, Sub, SubAssign}; +use std::str::FromStr; use starknet::core::types::U256; use starknet_crypto::Felt; @@ -28,6 +29,10 @@ pub fn sql_string_to_u256(sql_string: &str) -> U256 { U256::from(crypto_bigint::U256::from_be_hex(sql_string)) } +pub fn sql_string_to_felts(sql_string: &str) -> Vec { + sql_string.split(FELT_DELIMITER).map(|felt| Felt::from_str(felt).unwrap()).collect() +} + // type used to do calculation on inmemory balances #[derive(Debug, Clone, Copy)] pub struct I256 { diff --git a/crates/torii/core/src/types.rs b/crates/torii/core/src/types.rs index 254a095517..a9ecf79a0d 100644 --- a/crates/torii/core/src/types.rs +++ b/crates/torii/core/src/types.rs @@ -79,6 +79,8 @@ pub struct EventMessage { // this should never be None #[sqlx(skip)] pub updated_model: Option, + #[sqlx(skip)] + pub historical: bool, } #[derive(FromRow, Deserialize, Debug, Clone)] @@ -94,6 +96,8 @@ pub struct OptimisticEventMessage { // this should never be None #[sqlx(skip)] pub updated_model: Option, + #[sqlx(skip)] + pub historical: bool, } #[derive(FromRow, Deserialize, Debug, Clone)] diff --git a/crates/torii/graphql/Cargo.toml b/crates/torii/graphql/Cargo.toml index 7ec5edc7a1..4d31a89943 100644 --- a/crates/torii/graphql/Cargo.toml +++ b/crates/torii/graphql/Cargo.toml @@ -37,7 +37,7 @@ warp.workspace = true camino.workspace = true dojo-test-utils = { workspace = true, features = [ "build-examples" ] } dojo-utils.workspace = true -dojo-world.workspace = true +dojo-world = { workspace = true, features = [ "metadata" ] } katana-runner.workspace = true scarb.workspace = true serial_test = "2.0.0" @@ -45,3 +45,4 @@ starknet.workspace = true starknet-crypto.workspace = true tempfile.workspace = true toml.workspace = true +sozo-scarbext.workspace = true diff --git a/crates/torii/graphql/src/lib.rs b/crates/torii/graphql/src/lib.rs index d9c57ed18d..7ebfa00c3e 100644 --- a/crates/torii/graphql/src/lib.rs +++ b/crates/torii/graphql/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(unused_crate_dependencies)] +// #![warn(unused_crate_dependencies)] pub mod object; diff --git a/crates/torii/graphql/src/tests/metadata_test.rs b/crates/torii/graphql/src/tests/metadata_test.rs index 24224eb6b0..d92cca5854 100644 --- a/crates/torii/graphql/src/tests/metadata_test.rs +++ b/crates/torii/graphql/src/tests/metadata_test.rs @@ -2,8 +2,7 @@ mod tests { use std::collections::HashMap; - use dojo_world::config::ProfileConfig; - use dojo_world::metadata::WorldMetadata; + use dojo_world::config::{ProfileConfig, WorldMetadata}; use sqlx::SqlitePool; use starknet::core::types::Felt; use tokio::sync::broadcast; diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index d12c4c5e80..7a54dcce72 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -4,20 +4,20 @@ use std::sync::Arc; use anyhow::Result; use async_graphql::dynamic::Schema; -use camino::Utf8PathBuf; use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::{copy_types_test_db, prepare_migration_with_world_and_seed}; +use dojo_test_utils::migration::copy_types_test_db; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; use dojo_utils::{TransactionExt, TransactionWaiter, TxnConfig}; -use dojo_world::contracts::abi::model::Layout; -use dojo_world::contracts::abi::world::Resource; +use dojo_world::contracts::abigen::model::Layout; +use dojo_world::contracts::abigen::world::Resource; use dojo_world::contracts::naming::{compute_bytearray_hash, compute_selector_from_tag}; use dojo_world::contracts::{WorldContract, WorldContractReader}; use katana_runner::{KatanaRunner, KatanaRunnerConfig}; use scarb::compiler::Profile; use serde::Deserialize; use serde_json::Value; +use sozo_scarbext::WorkspaceExt; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use sqlx::SqlitePool; use starknet::accounts::{Account, ConnectedAccount}; @@ -279,12 +279,10 @@ pub async fn spinup_types_test(path: &str) -> Result { let pool = SqlitePoolOptions::new().connect_with(options).await.unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let setup = CompilerTestSetup::from_paths("../../dojo-core", &["../types-test"]); + let setup = CompilerTestSetup::from_paths("../../dojo/core", &["../types-test"]); let config = setup.build_test_config("types-test", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_dir = Utf8PathBuf::from(ws.target_dir().to_string()).join("dev"); let seq_config = KatanaRunnerConfig { n_accounts: 10, ..Default::default() } .with_db_dir(copy_types_test_db().as_str()); @@ -294,18 +292,12 @@ pub async fn spinup_types_test(path: &str) -> Result { let account = sequencer.account(0); let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_dir, - None, - "types_test", - "types_test", - ) - .unwrap(); + let world_local = ws.load_world_local().unwrap(); + let world_address = world_local.deterministic_world_address().unwrap(); - let world = WorldContract::new(strat.world_address, &account); + let world = WorldContract::new(world_address, &account); - let records_address = if let Resource::Contract((_, records_address)) = + let records_address = if let Resource::Contract((records_address, _)) = world.resource(&compute_selector_from_tag("types_test-records")).call().await.unwrap() { records_address @@ -346,20 +338,16 @@ pub async fn spinup_types_test(path: &str) -> Result { TransactionWaiter::new(transaction_hash, &provider).await?; - let world = WorldContractReader::new(strat.world_address, Arc::clone(&provider)); + let world = WorldContractReader::new(world_address, Arc::clone(&provider)); let (shutdown_tx, _) = broadcast::channel(1); let (mut executor, sender) = Executor::new(pool.clone(), shutdown_tx.clone()).await.unwrap(); tokio::spawn(async move { executor.run().await.unwrap(); }); - let db = Sql::new( - pool.clone(), - sender, - &HashMap::from([(strat.world_address, ContractType::WORLD)]), - ) - .await - .unwrap(); + let db = Sql::new(pool.clone(), sender, &HashMap::from([(world_address, ContractType::WORLD)])) + .await + .unwrap(); let (shutdown_tx, _) = broadcast::channel(1); let mut engine = Engine::new( @@ -370,7 +358,7 @@ pub async fn spinup_types_test(path: &str) -> Result { EngineConfig::default(), shutdown_tx, None, - Arc::new(HashMap::from([(strat.world_address, ContractType::WORLD)])), + Arc::new(HashMap::from([(world_address, ContractType::WORLD)])), ); let to = account.provider().block_hash_and_number().await?.block_number; diff --git a/crates/torii/graphql/src/tests/models_ordering_test.rs b/crates/torii/graphql/src/tests/models_ordering_test.rs index 42182182fa..737a4dc8a6 100644 --- a/crates/torii/graphql/src/tests/models_ordering_test.rs +++ b/crates/torii/graphql/src/tests/models_ordering_test.rs @@ -71,9 +71,11 @@ mod tests { let connection: Connection = serde_json::from_value(world_model).unwrap(); let first_model = connection.edges.first().unwrap(); let second_model = connection.edges.get(1).unwrap(); - let last_model = connection.edges.get(2).unwrap(); + let third_model = connection.edges.get(2).unwrap(); + let last_model = connection.edges.get(3).unwrap(); assert_eq!(&first_model.node.name, "Record"); - assert_eq!(&second_model.node.name, "RecordSibling"); + assert_eq!(&second_model.node.name, "RecordLogged"); + assert_eq!(&third_model.node.name, "RecordSibling"); assert_eq!(&last_model.node.name, "Subrecord"); Ok(()) } diff --git a/crates/torii/graphql/src/tests/subscription_test.rs b/crates/torii/graphql/src/tests/subscription_test.rs index f35b60fcc6..11ef4585eb 100644 --- a/crates/torii/graphql/src/tests/subscription_test.rs +++ b/crates/torii/graphql/src/tests/subscription_test.rs @@ -7,7 +7,7 @@ mod tests { use async_graphql::value; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; - use dojo_world::contracts::abi::model::Layout; + use dojo_world::contracts::abigen::model::Layout; use dojo_world::contracts::naming::{compute_selector_from_names, compute_selector_from_tag}; use serial_test::serial; use sqlx::SqlitePool; diff --git a/crates/torii/grpc/Cargo.toml b/crates/torii/grpc/Cargo.toml index 3734b9aee6..e585af72f2 100644 --- a/crates/torii/grpc/Cargo.toml +++ b/crates/torii/grpc/Cargo.toml @@ -22,7 +22,7 @@ strum.workspace = true strum_macros.workspace = true # server -dojo-world = { path = "../../dojo-world", features = [ "contracts" ] } +dojo-world.workspace = true hyper.workspace = true rand.workspace = true serde_json.workspace = true @@ -37,6 +37,7 @@ dojo-utils.workspace = true katana-runner.workspace = true scarb.workspace = true tempfile.workspace = true +sozo-scarbext.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] tonic-web-wasm-client.workspace = true diff --git a/crates/torii/grpc/proto/world.proto b/crates/torii/grpc/proto/world.proto index fa3e6ef385..4898c44b8e 100644 --- a/crates/torii/grpc/proto/world.proto +++ b/crates/torii/grpc/proto/world.proto @@ -29,13 +29,13 @@ service World { rpc RetrieveEntitiesStreaming (RetrieveEntitiesRequest) returns (stream RetrieveEntitiesStreamingResponse); // Subscribe to entity updates. - rpc SubscribeEventMessages (SubscribeEntitiesRequest) returns (stream SubscribeEntityResponse); + rpc SubscribeEventMessages (SubscribeEventMessagesRequest) returns (stream SubscribeEntityResponse); // Update entity subscription - rpc UpdateEventMessagesSubscription (UpdateEntitiesSubscriptionRequest) returns (google.protobuf.Empty); + rpc UpdateEventMessagesSubscription (UpdateEventMessagesSubscriptionRequest) returns (google.protobuf.Empty); // Retrieve entities - rpc RetrieveEventMessages (RetrieveEntitiesRequest) returns (RetrieveEntitiesResponse); + rpc RetrieveEventMessages (RetrieveEventMessagesRequest) returns (RetrieveEntitiesResponse); // Retrieve events rpc RetrieveEvents (RetrieveEventsRequest) returns (RetrieveEventsResponse); @@ -81,11 +81,22 @@ message SubscribeEntitiesRequest { repeated types.EntityKeysClause clauses = 1; } +message SubscribeEventMessagesRequest { + repeated types.EntityKeysClause clauses = 1; + bool historical = 2; +} + message UpdateEntitiesSubscriptionRequest { uint64 subscription_id = 1; repeated types.EntityKeysClause clauses = 2; } +message UpdateEventMessagesSubscriptionRequest { + uint64 subscription_id = 1; + repeated types.EntityKeysClause clauses = 2; + bool historical = 3; +} + message SubscribeEntityResponse { types.Entity entity = 1; uint64 subscription_id = 2; @@ -96,6 +107,13 @@ message RetrieveEntitiesRequest { types.Query query = 1; } +message RetrieveEventMessagesRequest { + // The event messages to retrieve + types.Query query = 1; + // Should we retrieve historical event messages? + bool historical = 2; +} + message RetrieveEntitiesResponse { repeated types.Entity entities = 1; uint32 total_count = 2; diff --git a/crates/torii/grpc/src/client.rs b/crates/torii/grpc/src/client.rs index 0ca8c463e5..6499dde2dd 100644 --- a/crates/torii/grpc/src/client.rs +++ b/crates/torii/grpc/src/client.rs @@ -9,11 +9,12 @@ use tonic::codec::CompressionEncoding; use tonic::transport::Endpoint; use crate::proto::world::{ - world_client, RetrieveEntitiesRequest, RetrieveEntitiesResponse, RetrieveEventsRequest, - RetrieveEventsResponse, SubscribeEntitiesRequest, SubscribeEntityResponse, - SubscribeEventsRequest, SubscribeEventsResponse, SubscribeIndexerRequest, - SubscribeIndexerResponse, SubscribeModelsRequest, SubscribeModelsResponse, - UpdateEntitiesSubscriptionRequest, WorldMetadataRequest, + world_client, RetrieveEntitiesRequest, RetrieveEntitiesResponse, RetrieveEventMessagesRequest, + RetrieveEventsRequest, RetrieveEventsResponse, SubscribeEntitiesRequest, + SubscribeEntityResponse, SubscribeEventMessagesRequest, SubscribeEventsRequest, + SubscribeEventsResponse, SubscribeIndexerRequest, SubscribeIndexerResponse, + SubscribeModelsRequest, SubscribeModelsResponse, UpdateEntitiesSubscriptionRequest, + UpdateEventMessagesSubscriptionRequest, WorldMetadataRequest, }; use crate::types::schema::{Entity, SchemaError}; use crate::types::{EntityKeysClause, Event, EventQuery, IndexerUpdate, ModelKeysClause, Query}; @@ -96,8 +97,9 @@ impl WorldClient { pub async fn retrieve_event_messages( &mut self, query: Query, + historical: bool, ) -> Result { - let request = RetrieveEntitiesRequest { query: Some(query.into()) }; + let request = RetrieveEventMessagesRequest { query: Some(query.into()), historical }; self.inner .retrieve_event_messages(request) .await @@ -172,11 +174,12 @@ impl WorldClient { pub async fn subscribe_event_messages( &mut self, clauses: Vec, + historical: bool, ) -> Result { let clauses = clauses.into_iter().map(|c| c.into()).collect(); let stream = self .inner - .subscribe_event_messages(SubscribeEntitiesRequest { clauses }) + .subscribe_event_messages(SubscribeEventMessagesRequest { clauses, historical }) .await .map_err(Error::Grpc) .map(|res| res.into_inner())?; @@ -194,12 +197,14 @@ impl WorldClient { &mut self, subscription_id: u64, clauses: Vec, + historical: bool, ) -> Result<(), Error> { let clauses = clauses.into_iter().map(|c| c.into()).collect(); self.inner - .update_event_messages_subscription(UpdateEntitiesSubscriptionRequest { + .update_event_messages_subscription(UpdateEventMessagesSubscriptionRequest { subscription_id, clauses, + historical, }) .await .map_err(Error::Grpc) diff --git a/crates/torii/grpc/src/lib.rs b/crates/torii/grpc/src/lib.rs index ea54cebf02..8eaf4efe8c 100644 --- a/crates/torii/grpc/src/lib.rs +++ b/crates/torii/grpc/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(unused_crate_dependencies)] +// #![warn(unused_crate_dependencies)] #[cfg(target_arch = "wasm32")] extern crate wasm_prost as prost; diff --git a/crates/torii/grpc/src/server/mod.rs b/crates/torii/grpc/src/server/mod.rs index b1fb797836..4e710713e7 100644 --- a/crates/torii/grpc/src/server/mod.rs +++ b/crates/torii/grpc/src/server/mod.rs @@ -42,6 +42,7 @@ use tonic_web::GrpcWebLayer; use torii_core::error::{Error, ParseError, QueryError}; use torii_core::model::{build_sql_query, map_row_to_ty}; use torii_core::sql::cache::ModelCache; +use torii_core::sql::utils::sql_string_to_felts; use tower_http::cors::{AllowOrigin, CorsLayer}; use self::subscriptions::entity::EntityManager; @@ -52,8 +53,9 @@ use crate::proto::types::member_value::ValueType; use crate::proto::types::LogicalOperator; use crate::proto::world::world_server::WorldServer; use crate::proto::world::{ - RetrieveEntitiesStreamingResponse, SubscribeEntitiesRequest, SubscribeEntityResponse, - SubscribeEventsResponse, SubscribeIndexerRequest, SubscribeIndexerResponse, + RetrieveEntitiesStreamingResponse, RetrieveEventMessagesRequest, SubscribeEntitiesRequest, + SubscribeEntityResponse, SubscribeEventMessagesRequest, SubscribeEventsResponse, + SubscribeIndexerRequest, SubscribeIndexerResponse, UpdateEventMessagesSubscriptionRequest, WorldMetadataRequest, WorldMetadataResponse, }; use crate::proto::{self}; @@ -68,6 +70,8 @@ pub(crate) static EVENT_MESSAGES_TABLE: &str = "event_messages"; pub(crate) static EVENT_MESSAGES_MODEL_RELATION_TABLE: &str = "event_model"; pub(crate) static EVENT_MESSAGES_ENTITY_RELATION_COLUMN: &str = "event_message_id"; +pub(crate) static EVENT_MESSAGES_HISTORICAL_TABLE: &str = "event_messages_historical"; + impl From for Error { fn from(err: SchemaError) -> Self { match err { @@ -312,6 +316,44 @@ impl DojoWorld { Ok(all_entities) } + async fn fetch_historical_event_messages( + &self, + query: &str, + keys_pattern: Option<&str>, + limit: Option, + offset: Option, + ) -> Result, Error> { + let db_entities: Vec<(String, String, String, String)> = if keys_pattern.is_some() { + sqlx::query_as(query) + .bind(keys_pattern.unwrap()) + .bind(limit) + .bind(offset) + .fetch_all(&self.pool) + .await? + } else { + sqlx::query_as(query).bind(limit).bind(offset).fetch_all(&self.pool).await? + }; + + let mut entities = HashMap::new(); + for (id, data, model_id, _) in db_entities { + let hashed_keys = + Felt::from_str(&id).map_err(ParseError::FromStr)?.to_bytes_be().to_vec(); + let model = self + .model_cache + .model(&Felt::from_str(&model_id).map_err(ParseError::FromStr)?) + .await?; + let mut schema = model.schema; + schema.deserialize(&mut sql_string_to_felts(&data))?; + + let entity = entities + .entry(id) + .or_insert_with(|| proto::types::Entity { hashed_keys, models: vec![] }); + entity.models.push(schema.as_struct().unwrap().clone().into()); + } + + Ok(entities.into_values().collect()) + } + #[allow(clippy::too_many_arguments)] pub(crate) async fn query_by_hashed_keys( &self, @@ -353,8 +395,20 @@ impl DojoWorld { } // Query to get entity IDs and their model IDs - let mut query = format!( - r#" + let mut query = if table == EVENT_MESSAGES_HISTORICAL_TABLE { + format!( + r#" + SELECT {table}.id, {table}.data, {table}.model_id, group_concat({model_relation_table}.model_id) as model_ids + FROM {table} + JOIN {model_relation_table} ON {table}.id = {model_relation_table}.entity_id + {filter_ids} + GROUP BY {table}.event_id + ORDER BY {table}.event_id DESC + "# + ) + } else { + format!( + r#" SELECT {table}.id, group_concat({model_relation_table}.model_id) as model_ids FROM {table} JOIN {model_relation_table} ON {table}.id = {model_relation_table}.entity_id @@ -362,7 +416,8 @@ impl DojoWorld { GROUP BY {table}.id ORDER BY {table}.event_id DESC "# - ); + ) + }; if limit.is_some() { query += " LIMIT ?" @@ -372,6 +427,12 @@ impl DojoWorld { query += " OFFSET ?" } + if table == EVENT_MESSAGES_HISTORICAL_TABLE { + let entities = + self.fetch_historical_event_messages(&query, None, limit, offset).await?; + return Ok((entities, total_count)); + } + let db_entities: Vec<(String, String)> = sqlx::query_as(&query).bind(limit).bind(offset).fetch_all(&self.pool).await?; @@ -446,15 +507,27 @@ impl DojoWorld { return Ok((Vec::new(), 0)); } - let mut models_query = format!( - r#" - SELECT {table}.id, group_concat({model_relation_table}.model_id) as model_ids - FROM {table} - JOIN {model_relation_table} ON {table}.id = {model_relation_table}.entity_id - WHERE {table}.keys REGEXP ? - GROUP BY {table}.id - "# - ); + let mut models_query = if table == EVENT_MESSAGES_HISTORICAL_TABLE { + format!( + r#" + SELECT {table}.id, {table}.data, {table}.model_id, group_concat({model_relation_table}.model_id) as model_ids + FROM {table} + JOIN {model_relation_table} ON {table}.id = {model_relation_table}.entity_id + WHERE {table}.keys REGEXP ? + GROUP BY {table}.event_id + "# + ) + } else { + format!( + r#" + SELECT {table}.id, group_concat({model_relation_table}.model_id) as model_ids + FROM {table} + JOIN {model_relation_table} ON {table}.id = {model_relation_table}.entity_id + WHERE {table}.keys REGEXP ? + GROUP BY {table}.id + "# + ) + }; if !keys_clause.models.is_empty() { // filter by models @@ -485,6 +558,13 @@ impl DojoWorld { models_query += " OFFSET ?"; } + if table == EVENT_MESSAGES_HISTORICAL_TABLE { + let entities = self + .fetch_historical_event_messages(&models_query, Some(&keys_pattern), limit, offset) + .await?; + return Ok((entities, total_count)); + } + let db_entities: Vec<(String, String)> = sqlx::query_as(&models_query) .bind(&keys_pattern) .bind(limit) @@ -838,9 +918,10 @@ impl DojoWorld { async fn subscribe_event_messages( &self, clauses: Vec, + historical: bool, ) -> Result>, Error> { self.event_message_manager - .add_subscriber(clauses.into_iter().map(|keys| keys.into()).collect()) + .add_subscriber(clauses.into_iter().map(|keys| keys.into()).collect(), historical) .await } @@ -1195,11 +1276,11 @@ impl proto::world::world_server::World for DojoWorld { async fn subscribe_event_messages( &self, - request: Request, + request: Request, ) -> ServiceResult { - let SubscribeEntitiesRequest { clauses } = request.into_inner(); + let SubscribeEventMessagesRequest { clauses, historical } = request.into_inner(); let rx = self - .subscribe_event_messages(clauses) + .subscribe_event_messages(clauses, historical) .await .map_err(|e| Status::internal(e.to_string()))?; @@ -1208,13 +1289,15 @@ impl proto::world::world_server::World for DojoWorld { async fn update_event_messages_subscription( &self, - request: Request, + request: Request, ) -> ServiceResult<()> { - let UpdateEntitiesSubscriptionRequest { subscription_id, clauses } = request.into_inner(); + let UpdateEventMessagesSubscriptionRequest { subscription_id, clauses, historical } = + request.into_inner(); self.event_message_manager .update_subscriber( subscription_id, clauses.into_iter().map(|keys| keys.into()).collect(), + historical, ) .await; @@ -1223,16 +1306,14 @@ impl proto::world::world_server::World for DojoWorld { async fn retrieve_event_messages( &self, - request: Request, + request: Request, ) -> Result, Status> { - let query = request - .into_inner() - .query - .ok_or_else(|| Status::invalid_argument("Missing query argument"))?; + let RetrieveEventMessagesRequest { query, historical } = request.into_inner(); + let query = query.ok_or_else(|| Status::invalid_argument("Missing query argument"))?; let entities = self .retrieve_entities( - EVENT_MESSAGES_TABLE, + if historical { EVENT_MESSAGES_HISTORICAL_TABLE } else { EVENT_MESSAGES_TABLE }, EVENT_MESSAGES_MODEL_RELATION_TABLE, EVENT_MESSAGES_ENTITY_RELATION_COLUMN, query, diff --git a/crates/torii/grpc/src/server/subscriptions/event_message.rs b/crates/torii/grpc/src/server/subscriptions/event_message.rs index c0aa33edfe..1fb578ed47 100644 --- a/crates/torii/grpc/src/server/subscriptions/event_message.rs +++ b/crates/torii/grpc/src/server/subscriptions/event_message.rs @@ -9,7 +9,9 @@ use futures::Stream; use futures_util::StreamExt; use rand::Rng; use starknet::core::types::Felt; -use tokio::sync::mpsc::{channel, unbounded_channel, Receiver, UnboundedReceiver, UnboundedSender}; +use tokio::sync::mpsc::{ + channel, unbounded_channel, Receiver, Sender, UnboundedReceiver, UnboundedSender, +}; use tokio::sync::RwLock; use torii_core::error::{Error, ParseError}; use torii_core::simple_broker::SimpleBroker; @@ -17,7 +19,6 @@ use torii_core::sql::FELT_DELIMITER; use torii_core::types::OptimisticEventMessage; use tracing::{error, trace}; -use super::entity::EntitiesSubscriber; use super::match_entity_keys; use crate::proto; use crate::proto::world::SubscribeEntityResponse; @@ -25,15 +26,26 @@ use crate::types::EntityKeysClause; pub(crate) const LOG_TARGET: &str = "torii::grpc::server::subscriptions::event_message"; +#[derive(Debug)] +pub struct EventMessageSubscriber { + /// Entity ids that the subscriber is interested in + pub(crate) clauses: Vec, + /// Whether the subscriber is interested in historical event messages + pub(crate) historical: bool, + /// The channel to send the response back to the subscriber. + pub(crate) sender: Sender>, +} + #[derive(Debug, Default)] pub struct EventMessageManager { - subscribers: RwLock>, + subscribers: RwLock>, } impl EventMessageManager { pub async fn add_subscriber( &self, clauses: Vec, + historical: bool, ) -> Result>, Error> { let subscription_id = rand::thread_rng().gen::(); let (sender, receiver) = channel(1); @@ -46,12 +58,17 @@ impl EventMessageManager { self.subscribers .write() .await - .insert(subscription_id, EntitiesSubscriber { clauses, sender }); + .insert(subscription_id, EventMessageSubscriber { clauses, historical, sender }); Ok(receiver) } - pub async fn update_subscriber(&self, id: u64, clauses: Vec) { + pub async fn update_subscriber( + &self, + id: u64, + clauses: Vec, + historical: bool, + ) { let sender = { let subscribers = self.subscribers.read().await; if let Some(subscriber) = subscribers.get(&id) { @@ -61,7 +78,10 @@ impl EventMessageManager { } }; - self.subscribers.write().await.insert(id, EntitiesSubscriber { clauses, sender }); + self.subscribers + .write() + .await + .insert(id, EventMessageSubscriber { clauses, historical, sender }); } pub(super) async fn remove_subscriber(&self, id: u64) { @@ -115,6 +135,11 @@ impl Service { .map_err(ParseError::FromStr)?; for (idx, sub) in subs.subscribers.read().await.iter() { + // Check if the subscriber is interested in this historical or non-historical event + if sub.historical != entity.historical { + continue; + } + // Check if the subscriber is interested in this entity // If we have a clause of hashed keys, then check that the id of the entity // is in the list of hashed keys. diff --git a/crates/torii/grpc/src/server/tests/entities_test.rs b/crates/torii/grpc/src/server/tests/entities_test.rs index 0bc8451919..e7996092e9 100644 --- a/crates/torii/grpc/src/server/tests/entities_test.rs +++ b/crates/torii/grpc/src/server/tests/entities_test.rs @@ -3,19 +3,20 @@ use std::str::FromStr; use std::sync::Arc; use cainome::cairo_serde::ContractAddress; -use camino::Utf8PathBuf; use dojo_test_utils::compiler::CompilerTestSetup; -use dojo_test_utils::migration::{copy_spawn_and_move_db, prepare_migration_with_world_and_seed}; +use dojo_test_utils::migration::copy_spawn_and_move_db; +use dojo_types::naming::compute_selector_from_names; use dojo_utils::{TransactionExt, TransactionWaiter, TxnConfig}; use dojo_world::contracts::naming::compute_bytearray_hash; use dojo_world::contracts::{WorldContract, WorldContractReader}; use katana_runner::RunnerCtx; use scarb::compiler::Profile; use scarb::ops; +use sozo_scarbext::WorkspaceExt; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::accounts::Account; use starknet::core::types::Call; -use starknet::core::utils::{get_contract_address, get_selector_from_name}; +use starknet::core::utils::get_selector_from_name; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::{JsonRpcClient, Provider}; use starknet_crypto::poseidon_hash_many; @@ -46,41 +47,28 @@ async fn test_entities_queries(sequencer: &RunnerCtx) { .unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let setup = CompilerTestSetup::from_examples("../../dojo/core", "../../../examples/"); let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let manifest_path = Utf8PathBuf::from(config.manifest_path().parent().unwrap()); - let target_path = ws.target_dir().path_existent().unwrap().join(config.profile().to_string()); - let account = sequencer.account(0); - let (strat, _) = prepare_migration_with_world_and_seed( - manifest_path, - target_path, - None, - "dojo_examples", - "dojo_examples", - ) - .unwrap(); + let world_local = ws.load_world_local().unwrap(); + let world_address = world_local.deterministic_world_address().unwrap(); - let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); + let actions_address = world_local + .get_contract_address_local(compute_selector_from_names("ns", "actions")) + .unwrap(); - let world = WorldContract::new(strat.world_address, &account); - let world_reader = WorldContractReader::new(strat.world_address, Arc::clone(&provider)); + let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); - let actions = strat.contracts.first().unwrap(); - let actions_address = get_contract_address( - actions.salt, - strat.base.as_ref().unwrap().diff.local_class_hash, - &[], - strat.world_address, - ); + let world = WorldContract::new(world_address, &account); + let world_reader = WorldContractReader::new(world_address, Arc::clone(&provider)); world - .grant_writer(&compute_bytearray_hash("dojo_examples"), &ContractAddress(actions_address)) + .grant_writer(&compute_bytearray_hash("ns"), &ContractAddress(actions_address)) .send_with_cfg(&TxnConfig::init_wait()) .await .unwrap(); @@ -104,13 +92,9 @@ async fn test_entities_queries(sequencer: &RunnerCtx) { tokio::spawn(async move { executor.run().await.unwrap(); }); - let db = Sql::new( - pool.clone(), - sender, - &HashMap::from([(strat.world_address, ContractType::WORLD)]), - ) - .await - .unwrap(); + let db = Sql::new(pool.clone(), sender, &HashMap::from([(world_address, ContractType::WORLD)])) + .await + .unwrap(); let (shutdown_tx, _) = broadcast::channel(1); let mut engine = Engine::new( @@ -121,7 +105,7 @@ async fn test_entities_queries(sequencer: &RunnerCtx) { EngineConfig::default(), shutdown_tx, None, - Arc::new(HashMap::from([(strat.world_address, ContractType::WORLD)])), + Arc::new(HashMap::from([(world_address, ContractType::WORLD)])), ); let to = provider.block_hash_and_number().await.unwrap().block_number; @@ -131,7 +115,7 @@ async fn test_entities_queries(sequencer: &RunnerCtx) { db.execute().await.unwrap(); let (_, receiver) = tokio::sync::mpsc::channel(1); - let grpc = DojoWorld::new(db.pool, receiver, strat.world_address, provider.clone()); + let grpc = DojoWorld::new(db.pool, receiver, world_address, provider.clone()); let entities = grpc .query_by_keys( @@ -154,7 +138,7 @@ async fn test_entities_queries(sequencer: &RunnerCtx) { assert_eq!(entities.len(), 1); let entity: Entity = entities.first().unwrap().clone().try_into().unwrap(); - assert_eq!(entity.models.first().unwrap().name, "dojo_examples-Position"); - assert_eq!(entity.models.get(1).unwrap().name, "dojo_examples-Moves"); + assert_eq!(entity.models.first().unwrap().name, "ns-Moves"); + assert_eq!(entity.models.get(1).unwrap().name, "ns-Position"); assert_eq!(entity.hashed_keys, poseidon_hash_many(&[account.address()])); } diff --git a/crates/torii/libp2p/Cargo.toml b/crates/torii/libp2p/Cargo.toml index ee7abd13a1..5e356d81f7 100644 --- a/crates/torii/libp2p/Cargo.toml +++ b/crates/torii/libp2p/Cargo.toml @@ -17,7 +17,7 @@ cainome.workspace = true chrono.workspace = true crypto-bigint.workspace = true dojo-types.workspace = true -dojo-world = { path = "../../dojo-world", features = [ "contracts" ] } +dojo-world.workspace = true indexmap.workspace = true serde_json.workspace = true starknet.workspace = true diff --git a/crates/torii/libp2p/src/tests.rs b/crates/torii/libp2p/src/tests.rs index dcc3af889f..e862f11667 100644 --- a/crates/torii/libp2p/src/tests.rs +++ b/crates/torii/libp2p/src/tests.rs @@ -528,7 +528,7 @@ mod test { use std::time::Duration; use dojo_types::schema::{Member, Struct, Ty}; - use dojo_world::contracts::abi::model::Layout; + use dojo_world::contracts::abigen::model::Layout; use indexmap::IndexMap; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::providers::jsonrpc::HttpTransport; diff --git a/crates/torii/migrations/20241028234131_event_message_historical.sql b/crates/torii/migrations/20241028234131_event_message_historical.sql new file mode 100644 index 0000000000..c0ce4a9e97 --- /dev/null +++ b/crates/torii/migrations/20241028234131_event_message_historical.sql @@ -0,0 +1,20 @@ +-- Ensures event messages can be stored as historical. +-- The historicallity is achieved by storing a counter for each pair . +CREATE TABLE event_messages_historical ( + -- No primary key, since we are storing 1-M relationship + -- to retrieve all historical events for a given entity_id. + id TEXT NOT NULL, + keys TEXT NOT NULL, + event_id TEXT NOT NULL, + -- The serialized data of the event, which contains the Ty. + data TEXT NOT NULL, + -- The model id of the serialized data. + model_id TEXT NOT NULL, + executed_at DATETIME NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- The counter added on is merely used to avoid querying a +-- potentially big table to get the latest counter for a given . +ALTER TABLE event_model ADD COLUMN historical_counter BIGINT DEFAULT 0; diff --git a/crates/torii/types-test/Scarb.lock b/crates/torii/types-test/Scarb.lock index 8720cc6b90..c48437326a 100644 --- a/crates/torii/types-test/Scarb.lock +++ b/crates/torii/types-test/Scarb.lock @@ -3,11 +3,18 @@ version = 1 [[package]] name = "dojo" -version = "1.0.0-alpha.4" +version = "1.0.0-rc.0" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "2.8.4" [[package]] name = "types_test" -version = "1.0.0-alpha.4" +version = "1.0.0-rc.0" dependencies = [ "dojo", ] diff --git a/crates/torii/types-test/Scarb.toml b/crates/torii/types-test/Scarb.toml index 43db0fdd62..f2ff23fa0e 100644 --- a/crates/torii/types-test/Scarb.toml +++ b/crates/torii/types-test/Scarb.toml @@ -1,14 +1,14 @@ [package] -cairo-version = "=2.7.0" +cairo-version = "=2.8.4" edition = "2024_07" name = "types_test" -version = "1.0.0-alpha.4" +version = "1.0.0-rc.0" [cairo] sierra-replace-ids = true [dependencies] -dojo = { path = "../../dojo-core" } +dojo = { path = "../../dojo/core" } -[[target.dojo]] -build-external-contracts = [ ] +[[target.starknet-contract]] +build-external-contracts = ["dojo::world::world_contract::world"] diff --git a/crates/torii/types-test/src/contracts.cairo b/crates/torii/types-test/src/contracts.cairo index 6d2b154d9a..71a979a4e8 100644 --- a/crates/torii/types-test/src/contracts.cairo +++ b/crates/torii/types-test/src/contracts.cairo @@ -1,28 +1,22 @@ -use starknet::{ContractAddress, ClassHash}; - -#[dojo::interface] -trait IRecords { - fn create(ref world: IWorldDispatcher, num_records: u8); - fn delete(ref world: IWorldDispatcher, record_id: u32); +#[starknet::interface] +trait IRecords { + fn create(ref self: T, num_records: u8); + fn delete(ref self: T, record_id: u32); } #[dojo::contract] mod records { - use starknet::{ContractAddress, get_caller_address}; use types_test::models::{ - Record, RecordStore, RecordSibling, RecordSiblingStore, Subrecord, SubrecordStore, Nested, - NestedMore, NestedMost, Depth + Record, RecordSibling, Subrecord, Nested, NestedMore, NestedMost, Depth }; use types_test::{seed, random}; + use dojo::model::ModelStorage; + use dojo::event::EventStorage; + use dojo::world::IWorldDispatcherTrait; use super::IRecords; - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - RecordLogged: RecordLogged - } - #[derive(Drop, starknet::Event)] + #[dojo::event] struct RecordLogged { #[key] record_id: u32, @@ -34,8 +28,9 @@ mod records { #[abi(embed_v0)] impl RecordsImpl of IRecords { - fn create(ref world: IWorldDispatcher, num_records: u8) { + fn create(ref self: ContractState, num_records: u8) { let mut record_idx = 0; + let mut world = self.world(@"types_test"); loop { if record_idx == num_records { @@ -53,82 +48,88 @@ mod records { ); let composite_u256 = u256 { low: random_u128, high: random_u128 }; - let record_id = world.uuid(); - let subrecord_id = world.uuid(); + let record_id = world.dispatcher.uuid(); + let subrecord_id = world.dispatcher.uuid(); - set!( - world, - ( - Record { - record_id, - depth: Depth::Zero, - type_i8: type_felt.try_into().unwrap(), - type_i16: type_felt.try_into().unwrap(), - type_i32: type_felt.try_into().unwrap(), - type_i64: type_felt.try_into().unwrap(), - type_i128: type_felt.try_into().unwrap(), - type_u8: record_idx.into(), - type_u16: record_idx.into(), - type_u32: record_idx.into(), - type_u64: record_idx.into(), - type_u128: record_idx.into(), - type_u256: type_felt.into(), - type_bool: if record_idx % 2 == 0 { - true - } else { - false - }, - type_felt: record_idx.into(), - type_class_hash: type_felt.try_into().unwrap(), - type_contract_address: type_felt.try_into().unwrap(), - type_deeply_nested: Nested { - depth: Depth::One, + let record = Record { + record_id, + depth: Depth::Zero, + type_i8: type_felt.try_into().unwrap(), + type_i16: type_felt.try_into().unwrap(), + type_i32: type_felt.try_into().unwrap(), + type_i64: type_felt.try_into().unwrap(), + type_i128: type_felt.try_into().unwrap(), + type_u8: record_idx.into(), + type_u16: record_idx.into(), + type_u32: record_idx.into(), + type_u64: record_idx.into(), + type_u128: record_idx.into(), + type_u256: type_felt.into(), + type_bool: if record_idx % 2 == 0 { + true + } else { + false + }, + type_felt: record_idx.into(), + type_class_hash: type_felt.try_into().unwrap(), + type_contract_address: type_felt.try_into().unwrap(), + type_deeply_nested: Nested { + depth: Depth::One, + type_number: record_idx.into(), + type_string: type_felt, + type_nested_more: NestedMore { + depth: Depth::Two, + type_number: record_idx.into(), + type_string: type_felt, + type_nested_most: NestedMost { + depth: Depth::Three, type_number: record_idx.into(), type_string: type_felt, - type_nested_more: NestedMore { - depth: Depth::Two, - type_number: record_idx.into(), - type_string: type_felt, - type_nested_most: NestedMost { - depth: Depth::Three, - type_number: record_idx.into(), - type_string: type_felt, - } - } - }, - type_nested_one: NestedMost { - depth: Depth::One, type_number: 1, type_string: 1, - }, - type_nested_two: NestedMost { - depth: Depth::One, type_number: 2, type_string: 2, - }, - random_u8, - random_u128, - composite_u256, - }, - RecordSibling { record_id, random_u8 }, - Subrecord { - record_id, subrecord_id, type_u8: record_idx.into(), random_u8, + } } - ) - ); + }, + type_nested_one: NestedMost { + depth: Depth::One, type_number: 1, type_string: 1, + }, + type_nested_two: NestedMost { + depth: Depth::One, type_number: 2, type_string: 2, + }, + random_u8, + random_u128, + composite_u256, + }; + let record_sibling = RecordSibling { record_id, random_u8 }; + let subrecord = Subrecord { + record_id, subrecord_id, type_u8: record_idx.into(), random_u8, + }; + + world.write_model(@record); + world.write_model(@record_sibling); + world.write_model(@subrecord); record_idx += 1; - emit!( - world, - RecordLogged { record_id, type_u8: record_idx.into(), type_felt, random_u128 } - ); + world.emit_event( + @RecordLogged { + record_id, type_u8: record_idx.into(), type_felt, random_u128 + } + ); }; } // Implemment fn delete, input param: record_id - fn delete(ref world: IWorldDispatcher, record_id: u32) { - let world = self.world_dispatcher.read(); - let (record, record_sibling) = get!(world, record_id, (Record, RecordSibling)); + fn delete(ref self: ContractState, record_id: u32) { + let mut world = self.world(@"types_test"); + + let record: Record = world.read_model(record_id); + let record_sibling: RecordSibling = world.read_model(record_id); + let subrecord_id = record_id + 1; - let subrecord = get!(world, (record_id, subrecord_id), (Subrecord)); - delete!(world, (record, record_sibling, subrecord)); + let subrecord: Subrecord = world.read_model((record_id, subrecord_id)); + + world.erase_model(@record); + world.erase_model(@record_sibling); + world.erase_model(@subrecord); } } } diff --git a/crates/torii/types-test/src/models.cairo b/crates/torii/types-test/src/models.cairo index 0fe9a7e105..a1d9cad0ea 100644 --- a/crates/torii/types-test/src/models.cairo +++ b/crates/torii/types-test/src/models.cairo @@ -1,4 +1,3 @@ -use core::array::ArrayTrait; use starknet::{ContractAddress, ClassHash}; #[derive(Introspect, Drop, Serde)] diff --git a/examples/game-lib/Scarb.lock b/examples/game-lib/Scarb.lock index 8c5b4655e5..775fb46b9b 100644 --- a/examples/game-lib/Scarb.lock +++ b/examples/game-lib/Scarb.lock @@ -17,12 +17,11 @@ dependencies = [ [[package]] name = "dojo" -version = "1.0.0-alpha.4" +version = "1.0.0-rc.0" dependencies = [ "dojo_plugin", ] [[package]] name = "dojo_plugin" -version = "1.0.0-alpha.4" -source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79351d11c197f63e8cc1ff36" +version = "2.8.4" diff --git a/examples/game-lib/Scarb.toml b/examples/game-lib/Scarb.toml index 268b6a52f2..b075438218 100644 --- a/examples/game-lib/Scarb.toml +++ b/examples/game-lib/Scarb.toml @@ -9,4 +9,4 @@ version = "0.1.0" description = "Example game library for Dojo" [workspace.dependencies] -dojo = { path = "../../crates/dojo-core/" } +dojo = { path = "../../crates/dojo/core/" } diff --git a/examples/simple/.gitignore b/examples/simple/.gitignore new file mode 100644 index 0000000000..c890ea1524 --- /dev/null +++ b/examples/simple/.gitignore @@ -0,0 +1 @@ +manifests diff --git a/examples/simple/.snfoundry_cache/.prev_tests_failed b/examples/simple/.snfoundry_cache/.prev_tests_failed new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/simple/Scarb.lock b/examples/simple/Scarb.lock new file mode 100644 index 0000000000..c8ee34f166 --- /dev/null +++ b/examples/simple/Scarb.lock @@ -0,0 +1,28 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "1.0.0-rc.0" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_cairo_test" +version = "1.0.0-rc.0" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo_plugin" +version = "2.8.4" + +[[package]] +name = "dojo_simple" +version = "0.1.0" +dependencies = [ + "dojo", + "dojo_cairo_test", +] diff --git a/examples/simple/Scarb.toml b/examples/simple/Scarb.toml new file mode 100644 index 0000000000..24771a36ae --- /dev/null +++ b/examples/simple/Scarb.toml @@ -0,0 +1,19 @@ +[package] +cairo-version = "=2.8.4" +name = "dojo_simple" +version = "0.1.0" +edition = "2024_07" + +[[target.starknet-contract]] +sierra = true +build-external-contracts = ["dojo::world::world_contract::world"] + +[dependencies] +dojo = { path = "../../crates/dojo/core" } +starknet = "2.8.4" + +[dev-dependencies] +dojo_cairo_test = { path = "../../crates/dojo/core-cairo-test" } + +[features] +default = [] diff --git a/examples/simple/dojo_dev.toml b/examples/simple/dojo_dev.toml new file mode 100644 index 0000000000..5f388ecb45 --- /dev/null +++ b/examples/simple/dojo_dev.toml @@ -0,0 +1,30 @@ +[world] +description = "Simple world." +name = "simple" +seed = "simple" + +[env] +rpc_url = "http://localhost:5050/" +# Default account for katana with seed = 0 +account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec" +private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912" +#world_address = "0x077c0dc7c1aba7f8842aff393ce6aa71fa675b4ced1bc927f7fc971b6acd92fc" + +[namespace] +default = "ns" +mappings = { "ns" = ["c1", "M"], "ns2" = ["c1", "M"] } + +[init_call_args] +"ns-c1" = ["0xfffe"] +"ns2-c1" = ["0xfffe"] + +[writers] +"ns" = ["ns-c1", "ns-c2"] +"ns-M" = ["ns-c2", "ns-c1", "ns2-c1"] + +[owners] +"ns" = ["ns-c1"] + +[migration] +order_inits = ["ns-c2", "ns-c1"] +skip_contracts = ["ns-c3"] diff --git a/examples/simple/manifest_dev.json b/examples/simple/manifest_dev.json new file mode 100644 index 0000000000..f202e7e3d0 --- /dev/null +++ b/examples/simple/manifest_dev.json @@ -0,0 +1,1956 @@ +{ + "world": { + "class_hash": "0x139239a99d627697b19b9856beaef7896fc75375caf3d750dd76982a7afeb78", + "address": "0x4bb1b5116e5ed181392417f0c18ade13246cb30447e4dba0f8421c80bb77e2e", + "seed": "simple", + "name": "simple", + "abi": [ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::iworld::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "dojo::world::resource::Resource", + "variants": [ + { + "name": "Model", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Event", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Contract", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "World", + "type": "()" + }, + { + "name": "Unregistered", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::definition::ModelIndex", + "variants": [ + { + "name": "Keys", + "type": "core::array::Span::" + }, + { + "name": "Id", + "type": "core::felt252" + }, + { + "name": "MemberId", + "type": "(core::felt252, core::felt252)" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::meta::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::iworld::IWorld", + "items": [ + { + "type": "function", + "name": "resource", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::world::resource::Resource" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "init_contract", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit_event", + "inputs": [ + { + "name": "event_selector", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "historical", + "type": "core::bool" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::iworld::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::iworld::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "world_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractInitialized", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "init_calldata", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventEmitted", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "system_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "historical", + "type": "core::bool", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "member_selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world_contract::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world_contract::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "EventRegistered", + "type": "dojo::world::world_contract::world::EventRegistered", + "kind": "nested" + }, + { + "name": "ContractRegistered", + "type": "dojo::world::world_contract::world::ContractRegistered", + "kind": "nested" + }, + { + "name": "ModelUpgraded", + "type": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "nested" + }, + { + "name": "EventUpgraded", + "type": "dojo::world::world_contract::world::EventUpgraded", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "ContractInitialized", + "type": "dojo::world::world_contract::world::ContractInitialized", + "kind": "nested" + }, + { + "name": "EventEmitted", + "type": "dojo::world::world_contract::world::EventEmitted", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateRecord", + "type": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateMember", + "type": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world_contract::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "nested" + } + ] + } + ] + }, + "contracts": [ + { + "address": "0x16501c6eeae49a38af2a34e8c50a5ba6ac08c655e9c9b77b1306aad73aaca9d", + "class_hash": "0x13767b87a8459556babbcf8cbdf2800181b462ef47f6fdafc14fc14fc1dae57", + "abi": [ + { + "type": "impl", + "name": "c1__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "v", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "MyInterfaceImpl", + "interface_name": "dojo_simple::MyInterface" + }, + { + "type": "interface", + "name": "dojo_simple::MyInterface", + "items": [ + { + "type": "function", + "name": "system_1", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + }, + { + "name": "v", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_2", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_3", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + }, + { + "name": "v", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_4", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_simple::c1::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [ + "0xfffe" + ], + "tag": "ns-c1", + "systems": [] + }, + { + "address": "0x707ff87e1260619aa7c41ebd7f12a32d8cc358565e539c9f7b85140af3ca285", + "class_hash": "0x1eef253239f61c49444c41990940fa8fee51b021d19e48c20d31f45bc465d46", + "abi": [ + { + "type": "impl", + "name": "c2__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_simple::c2::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "ns-c2", + "systems": [] + }, + { + "address": "0x41c67324187d806f29b4d02be6b358b9d0f68db4ae070d826d3a8149feba80f", + "class_hash": "0x4be29e651d49e58fba33f71ab6fe7fe101ee811842d07852b70d43a407fef2a", + "abi": [ + { + "type": "impl", + "name": "c3__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_simple::c3::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "ns-c3", + "systems": [] + }, + { + "address": "0x5d52f8c5bd309ba73977008086d7c7f9c0d2991d2e29e96f01f99bf2065f88e", + "class_hash": "0x13767b87a8459556babbcf8cbdf2800181b462ef47f6fdafc14fc14fc1dae57", + "abi": [ + { + "type": "impl", + "name": "c1__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "v", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "MyInterfaceImpl", + "interface_name": "dojo_simple::MyInterface" + }, + { + "type": "interface", + "name": "dojo_simple::MyInterface", + "items": [ + { + "type": "function", + "name": "system_1", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + }, + { + "name": "v", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_2", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_3", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + }, + { + "name": "v", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "system_4", + "inputs": [ + { + "name": "k", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_simple::c1::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [ + "0xfffe" + ], + "tag": "ns2-c1", + "systems": [] + } + ], + "models": [ + { + "members": [], + "class_hash": "0xb35ce9998d1524acfc8b0318aed7375b0d977b6362a2f7af23be2950aa96fd", + "tag": "M" + }, + { + "members": [], + "class_hash": "0xb35ce9998d1524acfc8b0318aed7375b0d977b6362a2f7af23be2950aa96fd", + "tag": "M" + } + ], + "events": [ + { + "members": [], + "class_hash": "0x65aa33d998d733abc890ee36503fe1df8e7c01f2cf1a92b147bd424a1af56d7", + "tag": "E" + }, + { + "members": [], + "class_hash": "0x58568a90180a44515609dbaf69bb0c1aa56f29e93688f4bfdab10268fe68ce1", + "tag": "EH" + } + ] +} \ No newline at end of file diff --git a/examples/simple/src/lib.cairo b/examples/simple/src/lib.cairo new file mode 100644 index 0000000000..f7ec1ea258 --- /dev/null +++ b/examples/simple/src/lib.cairo @@ -0,0 +1,144 @@ +#[starknet::contract] +pub mod sn_c1 { + #[storage] + struct Storage {} +} + +#[derive(Drop, Serde)] +#[dojo::model] +pub struct M { + #[key] + pub k: felt252, + pub v: felt252, +} + +#[derive(Introspect, Drop, Serde)] +#[dojo::event] +pub struct E { + #[key] + pub k: felt252, + pub v: u32, +} + +#[derive(Introspect, Drop, Serde)] +#[dojo::event(historical: true)] +pub struct EH { + #[key] + pub k: felt252, + pub v: u32, +} + +#[starknet::interface] +pub trait MyInterface { + fn system_1(ref self: T, k: felt252, v: felt252); + fn system_2(ref self: T, k: felt252) -> felt252; + fn system_3(ref self: T, k: felt252, v: u32); + fn system_4(ref self: T, k: felt252); +} + +#[dojo::contract] +pub mod c1 { + use super::{MyInterface, M, E, EH, MValue}; + use dojo::model::{ModelStorage, ModelValueStorage, Model, ModelPtr}; + use dojo::event::EventStorage; + + fn dojo_init(self: @ContractState, v: felt252) { + let m = M { k: 0, v, }; + + let mut world = self.world_default(); + world.write_model(@m); + } + + #[abi(embed_v0)] + impl MyInterfaceImpl of MyInterface { + fn system_1(ref self: ContractState, k: felt252, v: felt252) { + let mut world = self.world_default(); + + let m = M { k, v, }; + + world.write_model(@m) + } + + fn system_2(ref self: ContractState, k: felt252) -> felt252 { + let mut world = self.world_default(); + + let m: M = world.read_model(k); + + m.v + } + + fn system_3(ref self: ContractState, k: felt252, v: u32) { + let mut world = self.world_default(); + + let e = E { k, v, }; + world.emit_event(@e); + + let eh = EH { k, v, }; + world.emit_event(@eh); + } + + fn system_4(ref self: ContractState, k: felt252) { + let mut world = self.world_default(); + + let m = M { k, v: 288, }; + + let entity_id = Model::::entity_id(@m); + + world.write_model(@m); + world.erase_model(@m); + + let mut mv: MValue = world.read_value_from_id(entity_id); + mv.v = 12; + world.write_value_from_id(entity_id, @mv); + + world.erase_model_ptr(ModelPtr::::Id(entity_id)); + } + } + + #[generate_trait] + impl InternalImpl of InternalTrait { + // Need a function since byte array can't be const. + // We could have a self.world with an other function to init from hash, that can be + // constant. + fn world_default(self: @ContractState) -> dojo::world::WorldStorage { + self.world(@"ns") + } + } +} + +#[dojo::contract] +pub mod c2 {} + +#[dojo::contract] +pub mod c3 {} + +#[cfg(test)] +mod tests { + use dojo::model::ModelStorage; + use dojo_cairo_test::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait}; + use super::{c1, m_M, M}; + + #[test] + fn test_1() { + let ndef = NamespaceDef { + namespace: "ns", resources: [ + TestResource::Model(m_M::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Contract( + ContractDefTrait::new(c1::TEST_CLASS_HASH, "c1") + .with_init_calldata([0xff].span()) + .with_writer_of([dojo::utils::bytearray_hash(@"ns")].span()) + ) + ].span() + }; + + let world = spawn_test_world([ndef].span()); + + let m: M = world.read_model(0); + assert!(m.v == 0xff, "invalid b"); + //let m2 = M { a: 120, b: 244, }; + + // `write_model_test` goes over permissions checks. + //starknet::testing::set_contract_address(123.try_into().unwrap()); + //world.write_model_test(@m2); + } +} diff --git a/examples/spawn-and-move/Scarb.lock b/examples/spawn-and-move/Scarb.lock index 38cedc596a..de912cb87c 100644 --- a/examples/spawn-and-move/Scarb.lock +++ b/examples/spawn-and-move/Scarb.lock @@ -17,13 +17,28 @@ dependencies = [ [[package]] name = "dojo" -version = "1.0.0-alpha.4" +version = "1.0.0-rc.0" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_cairo_test" +version = "1.0.0-rc.0" +dependencies = [ + "dojo", +] [[package]] name = "dojo_examples" -version = "1.0.0-alpha.8" +version = "1.0.0-rc.0" dependencies = [ "armory", "bestiary", "dojo", + "dojo_cairo_test", ] + +[[package]] +name = "dojo_plugin" +version = "2.8.4" diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 275c6c1c8d..bee3481810 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -1,7 +1,7 @@ [package] -cairo-version = "=2.7.0" +cairo-version = "=2.8.4" name = "dojo_examples" -version = "1.0.0-alpha.8" +version = "1.0.0-rc.0" # Use the prelude with the less imports as possible # from corelib. edition = "2024_07" @@ -9,13 +9,17 @@ edition = "2024_07" [cairo] sierra-replace-ids = true +[[target.starknet-contract]] +build-external-contracts = [ "dojo::world::world_contract::world" ] + [dependencies] armory = { path = "../game-lib/armory" } bestiary = { path = "../game-lib/bestiary" } -dojo = { path = "../../crates/dojo-core" } +dojo = { path = "../../crates/dojo/core" } +starknet = "2.8.4" -[[target.dojo]] -build-external-contracts = [ "armory::Flatbow", "bestiary::RiverSkale" ] +[dev-dependencies] +dojo_cairo_test = { path = "../../crates/dojo/core-cairo-test" } [features] default = [ "dungeon" ] diff --git a/examples/spawn-and-move/dojo_dev.toml b/examples/spawn-and-move/dojo_dev.toml index 025ec87e89..9b757c62a5 100644 --- a/examples/spawn-and-move/dojo_dev.toml +++ b/examples/spawn-and-move/dojo_dev.toml @@ -4,14 +4,17 @@ name = "example" seed = "dojo_examples" [namespace] -default = "dojo_examples" -# remapping can be done at tag level, or for the whole namespace. -# In this example, `armory-Flatbow` model will belong to `dojo_examples_weapons` namespace, and all `bestiary` models will belong to the `dojo_examples_foes` namespace when compiled into `spawn-and-move`. -mappings = { "armory-Flatbow" = "dojo_examples_weapons", "bestiary" = "dojo_examples_foes" } +default = "ns" [env] rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x46c1fd10836a8426197bf412fc5f26ea10f11a8d5c61474407f03f82c096593" +world_address = "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32" + +[init_call_args] +"ns-others" = ["0xff"] + +[writers] +"ns" = [ "ns-mock_token", "ns-actions", "ns-others" ] \ No newline at end of file diff --git a/examples/spawn-and-move/manifest_dev.json b/examples/spawn-and-move/manifest_dev.json new file mode 100644 index 0000000000..20ae62e96d --- /dev/null +++ b/examples/spawn-and-move/manifest_dev.json @@ -0,0 +1,889 @@ +{ + "world": { + "class_hash": "0x139239a99d627697b19b9856beaef7896fc75375caf3d750dd76982a7afeb78", + "address": "0x234d358c2ec21c98a229966bd2bae6dbf2c517969c361bc649361f9055afc32", + "seed": "dojo_examples", + "name": "example" + }, + "contracts": [ + { + "address": "0x5a24b6dbf1b4b07f26f9920f490bb6a546f4620cb53d8a98b1da6317c3b8451", + "class_hash": "0x7b375686817add5ce9bef07ac7e4366fdd39d2be910f79896974ffda2471664", + "abi": [ + { + "type": "impl", + "name": "actions__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_examples::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_player_config", + "inputs": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_player_position", + "inputs": [], + "outputs": [ + { + "type": "dojo_examples::models::Position" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "reset_player_config", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_player_server_profile", + "inputs": [ + { + "name": "server_id", + "type": "core::integer::u32" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_models", + "inputs": [ + { + "name": "seed", + "type": "core::felt252" + }, + { + "name": "n_models", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "enter_dungeon", + "inputs": [ + { + "name": "dungeon_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "actions", + "systems": [] + }, + { + "address": "0x2e7d504b81c2f1b60986c95de64b650feb8ae625f04c6cd924150fab3cad4a8", + "class_hash": "0x777841f87b122c785037c7ba983550cb35e476bed81535a6c9b5bfff2183906", + "abi": [ + { + "type": "impl", + "name": "dungeon__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDungeonImpl", + "interface_name": "dojo_examples::dungeon::IDungeon" + }, + { + "type": "interface", + "name": "dojo_examples::dungeon::IDungeon", + "items": [ + { + "type": "function", + "name": "enter", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_examples::dungeon::dungeon::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "dungeon", + "systems": [] + }, + { + "address": "0x7e8f3994bc030bea8d1072fcb4d37bb0f1bdc0d8ff5bf3f7bd5211993c42736", + "class_hash": "0x10f24f231c572fa028b886c626e274856de5b7f4988f60dc442b691da8460a4", + "abi": [ + { + "type": "impl", + "name": "mock_token__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_examples::mock_token::mock_token::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "mock_token", + "systems": [] + }, + { + "address": "0x22dd2a3e90b337d147a7107e52dce4880f7efb85a93c8b5d9ca305ab978ec34", + "class_hash": "0x7da188de97bc0e2a08c20d3c75428ed2173bb0282cafd6ba693bc09f9d528c8", + "abi": [ + { + "type": "impl", + "name": "others__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [ + "0xff" + ], + "tag": "others", + "systems": [] + } + ], + "models": [ + { + "members": [], + "class_hash": "0x51b0ffe6e8ece3d15b6fabce1f07dab1a1233e220da151375a2df149337be02", + "tag": "Message" + }, + { + "members": [], + "class_hash": "0x1fd7e174290df3e0526cfaaad57d42830221fa18bb95ff2758efc669994bfb9", + "tag": "MockToken" + }, + { + "members": [], + "class_hash": "0x3f64a8d029dd11345095690578548dd96502e39a7df92f3ccc32d3bb9fd76e7", + "tag": "Moves" + }, + { + "members": [], + "class_hash": "0x725eafc8b33454db8df462f4dda1509ab6183b6b075e04467e1629cc5f0c047", + "tag": "PlayerConfig" + }, + { + "members": [], + "class_hash": "0x6be5880fe4240c8ddf9d5db79c004e46c17aa7804df1f4aa2824d0748fa7056", + "tag": "Position" + }, + { + "members": [], + "class_hash": "0x5b6daaed2b92e067b3d7c8bef42c5920ba35d13dfc35bf3de6a89953c7fceb0", + "tag": "ServerProfile" + } + ], + "events": [ + { + "members": [], + "class_hash": "0x37920709310be24ce9be9993d3f17b632a080eef9d4383b03fe251189696cc2", + "tag": "ContractInitialized" + }, + { + "members": [], + "class_hash": "0x22c33f3c7e525a21cd3651326f74c61deff6d75e26e06725f53ac2dfd4646fa", + "tag": "Moved" + } + ] +} \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json deleted file mode 100644 index ce8ce13c25..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json +++ /dev/null @@ -1,406 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsImpl", - "interface_name": "dojo_examples::actions::IActions" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::IActions", - "items": [ - { - "type": "function", - "name": "spawn", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_config", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_player_position", - "inputs": [], - "outputs": [ - { - "type": "dojo_examples::models::Position" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "update_player_name", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "update_player_items", - "inputs": [ - { - "name": "items", - "type": "core::array::Array::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "reset_player_config", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_server_profile", - "inputs": [ - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_models", - "inputs": [ - { - "name": "seed", - "type": "core::felt252" - }, - { - "name": "n_models", - "type": "core::integer::u32" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "enter_dungeon", - "inputs": [ - { - "name": "dungeon_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::actions::actions::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json deleted file mode 100644 index 753438f06f..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDungeonImpl", - "interface_name": "dojo_examples::dungeon::IDungeon" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::IDungeon", - "items": [ - { - "type": "function", - "name": "enter", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::dungeon::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::dungeon::dungeon::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-mock_token-31599eb2.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-mock_token-31599eb2.json deleted file mode 100644 index c72fe81e69..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-mock_token-31599eb2.json +++ /dev/null @@ -1,206 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::mock_token::mock_token::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::mock_token::mock_token::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::mock_token::mock_token::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-others-61de2c18.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-others-61de2c18.json deleted file mode 100644 index b8cbcf6f22..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-others-61de2c18.json +++ /dev/null @@ -1,219 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/dojo-base.json b/examples/spawn-and-move/manifests/dev/base/abis/dojo-base.json deleted file mode 100644 index 4800464226..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/dojo-base.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::base_contract::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "flat" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json deleted file mode 100644 index 8553809311..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json +++ /dev/null @@ -1,1231 +0,0 @@ -[ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::world_contract::IWorld" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::model::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "enum", - "name": "dojo::world::world_contract::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Contract", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Namespace", - "type": "()" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::world_contract::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::world_contract::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::world::update::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::world::update::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::world::update::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::update::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::world::update::ProgramOutput" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "ConfigImpl", - "interface_name": "dojo::world::config::IConfig" - }, - { - "type": "interface", - "name": "dojo::world::config::IConfig", - "items": [ - { - "type": "function", - "name": "set_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_facts_registry", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_facts_registry", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::Event", - "kind": "enum", - "variants": [ - { - "name": "DifferProgramHashUpdate", - "type": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "nested" - }, - { - "name": "FactsRegistryUpdate", - "type": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StateUpdated", - "kind": "struct", - "members": [ - { - "name": "da_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world_contract::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::world::config::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world_contract::world::StateUpdated", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json deleted file mode 100644 index 4641430128..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Message-1bb1d226.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Message-1bb1d226.json deleted file mode 100644 index 5e416425e2..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Message-1bb1d226.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-MockToken-38903c7c.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-MockToken-38903c7c.json deleted file mode 100644 index 79677cca37..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-MockToken-38903c7c.json +++ /dev/null @@ -1,407 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" - }, - { - "type": "struct", - "name": "dojo_examples::models::MockToken", - "members": [ - { - "name": "account", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "amount", - "type": "core::integer::u128" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imock_token", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::MockToken" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::mock_token::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moved-318ae40d.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moved-318ae40d.json deleted file mode 100644 index bfae2f690c..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moved-318ae40d.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movedImpl", - "interface_name": "dojo_examples::actions::actions::Imoved" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::actions::actions::Moved", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::actions::actions::Moved" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moves-2e2accba.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moves-2e2accba.json deleted file mode 100644 index d1fba9822d..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Moves-2e2accba.json +++ /dev/null @@ -1,437 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Moves", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "remaining", - "type": "core::integer::u8" - }, - { - "name": "last_direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imoves", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Moves" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::moves::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-PlayerConfig-3adad785.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-PlayerConfig-3adad785.json deleted file mode 100644 index 6b373d240f..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-PlayerConfig-3adad785.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerConfig", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - }, - { - "name": "items", - "type": "core::array::Array::" - }, - { - "name": "favorite_item", - "type": "core::option::Option::" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iplayer_config", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::PlayerConfig" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::player_config::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Position-1e145e26.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Position-1e145e26.json deleted file mode 100644 index 203c340d15..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Position-1e145e26.json +++ /dev/null @@ -1,421 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iposition", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Position" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::position::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json deleted file mode 100644 index 58aa520a88..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "server_profileImpl", - "interface_name": "dojo_examples::models::Iserver_profile" - }, - { - "type": "struct", - "name": "dojo_examples::models::ServerProfile", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iserver_profile", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::ServerProfile" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::server_profile::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json deleted file mode 100644 index aab11e5888..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "river_skaleImpl", - "interface_name": "bestiary::Iriver_skale" - }, - { - "type": "struct", - "name": "bestiary::RiverSkale", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "health", - "type": "core::integer::u32" - }, - { - "name": "armor", - "type": "core::integer::u32" - }, - { - "name": "attack", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "bestiary::Iriver_skale", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "bestiary::RiverSkale" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "bestiary::river_skale::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json deleted file mode 100644 index 55eaa66dde..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "flatbowImpl", - "interface_name": "armory::Iflatbow" - }, - { - "type": "struct", - "name": "armory::Flatbow", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "atk_speek", - "type": "core::integer::u32" - }, - { - "name": "range", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "armory::Iflatbow", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "armory::Flatbow" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "armory::flatbow::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml deleted file mode 100644 index 6fbfd7f944..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml +++ /dev/null @@ -1,21 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2aaecb3ded9ebb721f13780007e9704cba0d96b48195f357a35f4969d1b1941" -original_class_hash = "0x2aaecb3ded9ebb721f13780007e9704cba0d96b48195f357a35f4969d1b1941" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-actions" -systems = [ - "set_models", - "spawn", - "move", - "set_player_config", - "reset_player_config", - "set_player_server_profile", - "enter_dungeon", - "update_player_name", - "update_player_items", -] -manifest_name = "dojo_examples-actions-40b6994c" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml deleted file mode 100644 index cf60c05c33..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x117e4d75bef86d66e413d13f30904d2c93798f513ffa0bf83b4fac3fdfc4a62" -original_class_hash = "0x117e4d75bef86d66e413d13f30904d2c93798f513ffa0bf83b4fac3fdfc4a62" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-dungeon" -systems = ["enter"] -manifest_name = "dojo_examples-dungeon-6620e0e6" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token-31599eb2.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token-31599eb2.toml deleted file mode 100644 index 1f108c745f..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token-31599eb2.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x3ad65950996d7b0bc6c04a94d401cdb19bda3ab2cffc2098d90e25077dfa11a" -original_class_hash = "0x3ad65950996d7b0bc6c04a94d401cdb19bda3ab2cffc2098d90e25077dfa11a" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/dojo_examples-mock_token-31599eb2.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-mock_token" -systems = [] -manifest_name = "dojo_examples-mock_token-31599eb2" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others-61de2c18.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others-61de2c18.toml deleted file mode 100644 index 910cd889a8..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others-61de2c18.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2331b72955719869459bdacf66061a55975d6c2bc379349b082ee9d9a350a18" -original_class_hash = "0x2331b72955719869459bdacf66061a55975d6c2bc379349b082ee9d9a350a18" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/dojo_examples-others-61de2c18.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-others" -systems = [] -manifest_name = "dojo_examples-others-61de2c18" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo-base.toml b/examples/spawn-and-move/manifests/dev/base/dojo-base.toml deleted file mode 100644 index 44b3746b00..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/dojo-base.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -original_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -abi = "manifests/dev/base/abis/dojo-base.json" -tag = "dojo-base" -manifest_name = "dojo-base" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml deleted file mode 100644 index 4dfc391ebd..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -original_class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -abi = "manifests/dev/base/abis/dojo-world.json" -tag = "dojo-world" -manifest_name = "dojo-world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ContractInitialized-376b7bd6.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ContractInitialized-376b7bd6.toml deleted file mode 100644 index 9df44d0961..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ContractInitialized-376b7bd6.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x720bb4a3a1324dea862ac8b3ac3e30ac55490ce6ec9f7f68341db081b290c08" -original_class_hash = "0x720bb4a3a1324dea862ac8b3ac3e30ac55490ce6ec9f7f68341db081b290c08" -abi = "manifests/dev/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json" -tag = "dojo_examples-ContractInitialized" -qualified_path = "dojo_examples::others::others::contract_initialized" -manifest_name = "dojo_examples-ContractInitialized-376b7bd6" - -[[members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Message-1bb1d226.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Message-1bb1d226.toml deleted file mode 100644 index 07dd21e79b..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Message-1bb1d226.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x3ca17c0ebb595e1d1cc01813923864316a49b91f4a725ef1371329abbc1947b" -original_class_hash = "0x3ca17c0ebb595e1d1cc01813923864316a49b91f4a725ef1371329abbc1947b" -abi = "manifests/dev/base/abis/models/dojo_examples-Message-1bb1d226.json" -tag = "dojo_examples-Message" -qualified_path = "dojo_examples::models::message" -manifest_name = "dojo_examples-Message-1bb1d226" - -[[members]] -name = "identity" -type = "ContractAddress" -key = true - -[[members]] -name = "channel" -type = "felt252" -key = true - -[[members]] -name = "message" -type = "ByteArray" -key = false - -[[members]] -name = "salt" -type = "felt252" -key = true diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-MockToken-38903c7c.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-MockToken-38903c7c.toml deleted file mode 100644 index cf5e869b8c..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-MockToken-38903c7c.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x244a875f2049e4ca875b631270f1203a5be374fc040a8c4bd40405eeeea07bd" -original_class_hash = "0x244a875f2049e4ca875b631270f1203a5be374fc040a8c4bd40405eeeea07bd" -abi = "manifests/dev/base/abis/models/dojo_examples-MockToken-38903c7c.json" -tag = "dojo_examples-MockToken" -qualified_path = "dojo_examples::models::mock_token" -manifest_name = "dojo_examples-MockToken-38903c7c" - -[[members]] -name = "account" -type = "ContractAddress" -key = true - -[[members]] -name = "amount" -type = "u128" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moved-318ae40d.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moved-318ae40d.toml deleted file mode 100644 index 89fe5c408f..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moved-318ae40d.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x71f21bb9f7454ede4f4fe1482012218ef57448ca9687018dab409c4ddb790a2" -original_class_hash = "0x71f21bb9f7454ede4f4fe1482012218ef57448ca9687018dab409c4ddb790a2" -abi = "manifests/dev/base/abis/models/dojo_examples-Moved-318ae40d.json" -tag = "dojo_examples-Moved" -qualified_path = "dojo_examples::actions::actions::moved" -manifest_name = "dojo_examples-Moved-318ae40d" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moves-2e2accba.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moves-2e2accba.toml deleted file mode 100644 index 5fa07c879b..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Moves-2e2accba.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4dd1c573b5cdc56561be8b28a4840048a3a008d1a4a6eed397ec4135effaf44" -original_class_hash = "0x4dd1c573b5cdc56561be8b28a4840048a3a008d1a4a6eed397ec4135effaf44" -abi = "manifests/dev/base/abis/models/dojo_examples-Moves-2e2accba.json" -tag = "dojo_examples-Moves" -qualified_path = "dojo_examples::models::moves" -manifest_name = "dojo_examples-Moves-2e2accba" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "remaining" -type = "u8" -key = false - -[[members]] -name = "last_direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-PlayerConfig-3adad785.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-PlayerConfig-3adad785.toml deleted file mode 100644 index 660fdee336..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-PlayerConfig-3adad785.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x515f106010313c2fcd87719836e75873aa75a711a4bdcd2ea0b6e38854deebf" -original_class_hash = "0x515f106010313c2fcd87719836e75873aa75a711a4bdcd2ea0b6e38854deebf" -abi = "manifests/dev/base/abis/models/dojo_examples-PlayerConfig-3adad785.json" -tag = "dojo_examples-PlayerConfig" -qualified_path = "dojo_examples::models::player_config" -manifest_name = "dojo_examples-PlayerConfig-3adad785" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false - -[[members]] -name = "items" -type = "Array" -key = false - -[[members]] -name = "favorite_item" -type = "Option" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Position-1e145e26.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Position-1e145e26.toml deleted file mode 100644 index ea9e123e7d..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Position-1e145e26.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x5af60d63e6a1d25fc117fde1fa7e1d628adc46a52c3d007541ed6dd369e8ea" -original_class_hash = "0x5af60d63e6a1d25fc117fde1fa7e1d628adc46a52c3d007541ed6dd369e8ea" -abi = "manifests/dev/base/abis/models/dojo_examples-Position-1e145e26.json" -tag = "dojo_examples-Position" -qualified_path = "dojo_examples::models::position" -manifest_name = "dojo_examples-Position-1e145e26" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "vec" -type = "Vec2" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ServerProfile-4caad1e6.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ServerProfile-4caad1e6.toml deleted file mode 100644 index bc286019fd..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-ServerProfile-4caad1e6.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x2fa72f20995710bef20ac3c36e2f43ec210517a787927ea3407e2b29c21bb0b" -original_class_hash = "0x2fa72f20995710bef20ac3c36e2f43ec210517a787927ea3407e2b29c21bb0b" -abi = "manifests/dev/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json" -tag = "dojo_examples-ServerProfile" -qualified_path = "dojo_examples::models::server_profile" -manifest_name = "dojo_examples-ServerProfile-4caad1e6" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "server_id" -type = "u32" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml deleted file mode 100644 index 1d8d2490c9..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4f3cbb247febb63bf5ab34d87504fd85e7a3b4ab6ff16fa2bf23597bf3309c7" -original_class_hash = "0x4f3cbb247febb63bf5ab34d87504fd85e7a3b4ab6ff16fa2bf23597bf3309c7" -abi = "manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json" -tag = "dojo_examples_foes-RiverSkale" -qualified_path = "bestiary::river_skale" -manifest_name = "dojo_examples_foes-RiverSkale-39535c12" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "health" -type = "u32" -key = false - -[[members]] -name = "armor" -type = "u32" -key = false - -[[members]] -name = "attack" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml deleted file mode 100644 index da82bd85b4..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x783cecd986c0f03f8ac70318f67d57ea8072db7d4d135d54585f4de33c879ad" -original_class_hash = "0x783cecd986c0f03f8ac70318f67d57ea8072db7d4d135d54585f4de33c879ad" -abi = "manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json" -tag = "dojo_examples_weapons-Flatbow" -qualified_path = "armory::flatbow" -manifest_name = "dojo_examples_weapons-Flatbow-22f5bd16" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "atk_speek" -type = "u32" -key = false - -[[members]] -name = "range" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json deleted file mode 100644 index ce8ce13c25..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json +++ /dev/null @@ -1,406 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsImpl", - "interface_name": "dojo_examples::actions::IActions" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::IActions", - "items": [ - { - "type": "function", - "name": "spawn", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_config", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_player_position", - "inputs": [], - "outputs": [ - { - "type": "dojo_examples::models::Position" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "update_player_name", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "update_player_items", - "inputs": [ - { - "name": "items", - "type": "core::array::Array::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "reset_player_config", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_server_profile", - "inputs": [ - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_models", - "inputs": [ - { - "name": "seed", - "type": "core::felt252" - }, - { - "name": "n_models", - "type": "core::integer::u32" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "enter_dungeon", - "inputs": [ - { - "name": "dungeon_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::actions::actions::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json deleted file mode 100644 index 753438f06f..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDungeonImpl", - "interface_name": "dojo_examples::dungeon::IDungeon" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::IDungeon", - "items": [ - { - "type": "function", - "name": "enter", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::dungeon::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::dungeon::dungeon::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-mock_token-31599eb2.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-mock_token-31599eb2.json deleted file mode 100644 index c72fe81e69..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-mock_token-31599eb2.json +++ /dev/null @@ -1,206 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::mock_token::mock_token::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::mock_token::mock_token::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::mock_token::mock_token::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-others-61de2c18.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-others-61de2c18.json deleted file mode 100644 index b8cbcf6f22..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-others-61de2c18.json +++ /dev/null @@ -1,219 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-base.json b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-base.json deleted file mode 100644 index 4800464226..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-base.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::base_contract::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "flat" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json deleted file mode 100644 index 8553809311..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json +++ /dev/null @@ -1,1231 +0,0 @@ -[ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::world_contract::IWorld" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::model::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "enum", - "name": "dojo::world::world_contract::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Contract", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Namespace", - "type": "()" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::world_contract::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::world_contract::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::world::update::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::world::update::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::world::update::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::update::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::world::update::ProgramOutput" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "ConfigImpl", - "interface_name": "dojo::world::config::IConfig" - }, - { - "type": "interface", - "name": "dojo::world::config::IConfig", - "items": [ - { - "type": "function", - "name": "set_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_facts_registry", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_facts_registry", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::Event", - "kind": "enum", - "variants": [ - { - "name": "DifferProgramHashUpdate", - "type": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "nested" - }, - { - "name": "FactsRegistryUpdate", - "type": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StateUpdated", - "kind": "struct", - "members": [ - { - "name": "da_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world_contract::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::world::config::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world_contract::world::StateUpdated", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ContractInitialized-376b7bd6.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ContractInitialized-376b7bd6.json deleted file mode 100644 index 4641430128..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ContractInitialized-376b7bd6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Message-1bb1d226.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Message-1bb1d226.json deleted file mode 100644 index 5e416425e2..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Message-1bb1d226.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-MockToken-38903c7c.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-MockToken-38903c7c.json deleted file mode 100644 index 79677cca37..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-MockToken-38903c7c.json +++ /dev/null @@ -1,407 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" - }, - { - "type": "struct", - "name": "dojo_examples::models::MockToken", - "members": [ - { - "name": "account", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "amount", - "type": "core::integer::u128" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imock_token", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::MockToken" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::mock_token::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moved-318ae40d.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moved-318ae40d.json deleted file mode 100644 index bfae2f690c..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moved-318ae40d.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movedImpl", - "interface_name": "dojo_examples::actions::actions::Imoved" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::actions::actions::Moved", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::actions::actions::Moved" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moves-2e2accba.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moves-2e2accba.json deleted file mode 100644 index d1fba9822d..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Moves-2e2accba.json +++ /dev/null @@ -1,437 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Moves", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "remaining", - "type": "core::integer::u8" - }, - { - "name": "last_direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imoves", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Moves" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::moves::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-PlayerConfig-3adad785.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-PlayerConfig-3adad785.json deleted file mode 100644 index 6b373d240f..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-PlayerConfig-3adad785.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerConfig", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - }, - { - "name": "items", - "type": "core::array::Array::" - }, - { - "name": "favorite_item", - "type": "core::option::Option::" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iplayer_config", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::PlayerConfig" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::player_config::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Position-1e145e26.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Position-1e145e26.json deleted file mode 100644 index 203c340d15..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Position-1e145e26.json +++ /dev/null @@ -1,421 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iposition", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Position" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::position::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ServerProfile-4caad1e6.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ServerProfile-4caad1e6.json deleted file mode 100644 index 58aa520a88..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ServerProfile-4caad1e6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "server_profileImpl", - "interface_name": "dojo_examples::models::Iserver_profile" - }, - { - "type": "struct", - "name": "dojo_examples::models::ServerProfile", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iserver_profile", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::ServerProfile" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::server_profile::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json deleted file mode 100644 index aab11e5888..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "river_skaleImpl", - "interface_name": "bestiary::Iriver_skale" - }, - { - "type": "struct", - "name": "bestiary::RiverSkale", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "health", - "type": "core::integer::u32" - }, - { - "name": "armor", - "type": "core::integer::u32" - }, - { - "name": "attack", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "bestiary::Iriver_skale", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "bestiary::RiverSkale" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "bestiary::river_skale::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json deleted file mode 100644 index 55eaa66dde..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "flatbowImpl", - "interface_name": "armory::Iflatbow" - }, - { - "type": "struct", - "name": "armory::Flatbow", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "atk_speek", - "type": "core::integer::u32" - }, - { - "name": "range", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "armory::Iflatbow", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "armory::Flatbow" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "armory::flatbow::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json deleted file mode 100644 index ce8ce13c25..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json +++ /dev/null @@ -1,406 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsImpl", - "interface_name": "dojo_examples::actions::IActions" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::IActions", - "items": [ - { - "type": "function", - "name": "spawn", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_config", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_player_position", - "inputs": [], - "outputs": [ - { - "type": "dojo_examples::models::Position" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "update_player_name", - "inputs": [ - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "update_player_items", - "inputs": [ - { - "name": "items", - "type": "core::array::Array::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "reset_player_config", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_player_server_profile", - "inputs": [ - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_models", - "inputs": [ - { - "name": "seed", - "type": "core::felt252" - }, - { - "name": "n_models", - "type": "core::integer::u32" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "enter_dungeon", - "inputs": [ - { - "name": "dungeon_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::actions::actions::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json deleted file mode 100644 index 753438f06f..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDungeonImpl", - "interface_name": "dojo_examples::dungeon::IDungeon" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::IDungeon", - "items": [ - { - "type": "function", - "name": "enter", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::dungeon::dungeon::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::dungeon::dungeon::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-mock_token-31599eb2.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-mock_token-31599eb2.json deleted file mode 100644 index c72fe81e69..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-mock_token-31599eb2.json +++ /dev/null @@ -1,206 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::mock_token::mock_token::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::mock_token::mock_token::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::mock_token::mock_token::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-others-61de2c18.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-others-61de2c18.json deleted file mode 100644 index b8cbcf6f22..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-others-61de2c18.json +++ /dev/null @@ -1,219 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::contract::IContract" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::contract::IContract", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/dojo-base.json b/examples/spawn-and-move/manifests/release/base/abis/dojo-base.json deleted file mode 100644 index 4800464226..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/dojo-base.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::world_contract::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::world_contract::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::world_contract::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::base_contract::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "flat" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json deleted file mode 100644 index 8553809311..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json +++ /dev/null @@ -1,1231 +0,0 @@ -[ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::world_contract::IWorld" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::model::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "enum", - "name": "dojo::world::world_contract::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Contract", - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - }, - { - "name": "Namespace", - "type": "()" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::model::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::world_contract::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::world_contract::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::world_contract::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::world::update::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::world::update::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::world::update::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::update::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::world::update::ProgramOutput" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "ConfigImpl", - "interface_name": "dojo::world::config::IConfig" - }, - { - "type": "interface", - "name": "dojo::world::config::IConfig", - "items": [ - { - "type": "function", - "name": "set_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_facts_registry", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_facts_registry", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::config::Config::Event", - "kind": "enum", - "variants": [ - { - "name": "DifferProgramHashUpdate", - "type": "dojo::world::config::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::world::config::Config::MergerProgramHashUpdate", - "kind": "nested" - }, - { - "name": "FactsRegistryUpdate", - "type": "dojo::world::config::Config::FactsRegistryUpdate", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StateUpdated", - "kind": "struct", - "members": [ - { - "name": "da_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world_contract::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::world::config::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world_contract::world::StateUpdated", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json deleted file mode 100644 index 4641430128..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Message-1bb1d226.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Message-1bb1d226.json deleted file mode 100644 index 5e416425e2..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Message-1bb1d226.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-MockToken-38903c7c.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-MockToken-38903c7c.json deleted file mode 100644 index 79677cca37..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-MockToken-38903c7c.json +++ /dev/null @@ -1,407 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" - }, - { - "type": "struct", - "name": "dojo_examples::models::MockToken", - "members": [ - { - "name": "account", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "amount", - "type": "core::integer::u128" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imock_token", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::MockToken" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::mock_token::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moved-318ae40d.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moved-318ae40d.json deleted file mode 100644 index bfae2f690c..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moved-318ae40d.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movedImpl", - "interface_name": "dojo_examples::actions::actions::Imoved" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::actions::actions::Moved", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::actions::actions::Moved" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moves-2e2accba.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moves-2e2accba.json deleted file mode 100644 index d1fba9822d..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Moves-2e2accba.json +++ /dev/null @@ -1,437 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" - }, - { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Moves", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "remaining", - "type": "core::integer::u8" - }, - { - "name": "last_direction", - "type": "dojo_examples::models::Direction" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imoves", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Moves" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::moves::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-PlayerConfig-3adad785.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-PlayerConfig-3adad785.json deleted file mode 100644 index 6b373d240f..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-PlayerConfig-3adad785.json +++ /dev/null @@ -1,433 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ - { - "name": "item_id", - "type": "core::integer::u32" - }, - { - "name": "quantity", - "type": "core::integer::u32" - }, - { - "name": "score", - "type": "core::integer::i32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::PlayerConfig", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - }, - { - "name": "items", - "type": "core::array::Array::" - }, - { - "name": "favorite_item", - "type": "core::option::Option::" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iplayer_config", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::PlayerConfig" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::player_config::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Position-1e145e26.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Position-1e145e26.json deleted file mode 100644 index 203c340d15..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Position-1e145e26.json +++ /dev/null @@ -1,421 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" - }, - { - "type": "struct", - "name": "dojo_examples::models::Vec2", - "members": [ - { - "name": "x", - "type": "core::integer::u32" - }, - { - "name": "y", - "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "vec", - "type": "dojo_examples::models::Vec2" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iposition", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Position" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::position::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json deleted file mode 100644 index 58aa520a88..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "server_profileImpl", - "interface_name": "dojo_examples::models::Iserver_profile" - }, - { - "type": "struct", - "name": "dojo_examples::models::ServerProfile", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "server_id", - "type": "core::integer::u32" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Iserver_profile", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::ServerProfile" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::server_profile::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json deleted file mode 100644 index aab11e5888..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json +++ /dev/null @@ -1,415 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "river_skaleImpl", - "interface_name": "bestiary::Iriver_skale" - }, - { - "type": "struct", - "name": "bestiary::RiverSkale", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "health", - "type": "core::integer::u32" - }, - { - "name": "armor", - "type": "core::integer::u32" - }, - { - "name": "attack", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "bestiary::Iriver_skale", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "bestiary::RiverSkale" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "bestiary::river_skale::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json deleted file mode 100644 index 55eaa66dde..0000000000 --- a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::model::layout::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::layout::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::model::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::model::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::model::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::model::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::model::IModel", - "items": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::layout::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::model::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "flatbowImpl", - "interface_name": "armory::Iflatbow" - }, - { - "type": "struct", - "name": "armory::Flatbow", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "atk_speek", - "type": "core::integer::u32" - }, - { - "name": "range", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "armory::Iflatbow", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "armory::Flatbow" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "armory::flatbow::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml deleted file mode 100644 index e15acdf766..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml +++ /dev/null @@ -1,21 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2aaecb3ded9ebb721f13780007e9704cba0d96b48195f357a35f4969d1b1941" -original_class_hash = "0x2aaecb3ded9ebb721f13780007e9704cba0d96b48195f357a35f4969d1b1941" -base_class_hash = "0x0" -abi = "manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-actions" -systems = [ - "set_models", - "spawn", - "move", - "set_player_config", - "reset_player_config", - "set_player_server_profile", - "enter_dungeon", - "update_player_name", - "update_player_items", -] -manifest_name = "dojo_examples-actions-40b6994c" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml deleted file mode 100644 index 2d3cd43c81..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x117e4d75bef86d66e413d13f30904d2c93798f513ffa0bf83b4fac3fdfc4a62" -original_class_hash = "0x117e4d75bef86d66e413d13f30904d2c93798f513ffa0bf83b4fac3fdfc4a62" -base_class_hash = "0x0" -abi = "manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-dungeon" -systems = ["enter"] -manifest_name = "dojo_examples-dungeon-6620e0e6" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-mock_token-31599eb2.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-mock_token-31599eb2.toml deleted file mode 100644 index 9619bdb4e6..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-mock_token-31599eb2.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x3ad65950996d7b0bc6c04a94d401cdb19bda3ab2cffc2098d90e25077dfa11a" -original_class_hash = "0x3ad65950996d7b0bc6c04a94d401cdb19bda3ab2cffc2098d90e25077dfa11a" -base_class_hash = "0x0" -abi = "manifests/release/base/abis/contracts/dojo_examples-mock_token-31599eb2.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-mock_token" -systems = [] -manifest_name = "dojo_examples-mock_token-31599eb2" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-others-61de2c18.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-others-61de2c18.toml deleted file mode 100644 index a5627d0b65..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-others-61de2c18.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2331b72955719869459bdacf66061a55975d6c2bc379349b082ee9d9a350a18" -original_class_hash = "0x2331b72955719869459bdacf66061a55975d6c2bc379349b082ee9d9a350a18" -base_class_hash = "0x0" -abi = "manifests/release/base/abis/contracts/dojo_examples-others-61de2c18.json" -reads = [] -writes = [] -init_calldata = [] -tag = "dojo_examples-others" -systems = [] -manifest_name = "dojo_examples-others-61de2c18" diff --git a/examples/spawn-and-move/manifests/release/base/dojo-base.toml b/examples/spawn-and-move/manifests/release/base/dojo-base.toml deleted file mode 100644 index a2ae530db5..0000000000 --- a/examples/spawn-and-move/manifests/release/base/dojo-base.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -original_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" -abi = "manifests/release/base/abis/dojo-base.json" -tag = "dojo-base" -manifest_name = "dojo-base" diff --git a/examples/spawn-and-move/manifests/release/base/dojo-world.toml b/examples/spawn-and-move/manifests/release/base/dojo-world.toml deleted file mode 100644 index 39ebfa681c..0000000000 --- a/examples/spawn-and-move/manifests/release/base/dojo-world.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -original_class_hash = "0x6f38d5d9507c5d9546290e1a27e309efe5a9af3770b6cc1627db4a1b90a7dce" -abi = "manifests/release/base/abis/dojo-world.json" -tag = "dojo-world" -manifest_name = "dojo-world" diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ContractInitialized-376b7bd6.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ContractInitialized-376b7bd6.toml deleted file mode 100644 index 3f44583131..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ContractInitialized-376b7bd6.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x720bb4a3a1324dea862ac8b3ac3e30ac55490ce6ec9f7f68341db081b290c08" -original_class_hash = "0x720bb4a3a1324dea862ac8b3ac3e30ac55490ce6ec9f7f68341db081b290c08" -abi = "manifests/release/base/abis/models/dojo_examples-ContractInitialized-376b7bd6.json" -tag = "dojo_examples-ContractInitialized" -qualified_path = "dojo_examples::others::others::contract_initialized" -manifest_name = "dojo_examples-ContractInitialized-376b7bd6" - -[[members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Message-1bb1d226.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Message-1bb1d226.toml deleted file mode 100644 index 7f88709381..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Message-1bb1d226.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x3ca17c0ebb595e1d1cc01813923864316a49b91f4a725ef1371329abbc1947b" -original_class_hash = "0x3ca17c0ebb595e1d1cc01813923864316a49b91f4a725ef1371329abbc1947b" -abi = "manifests/release/base/abis/models/dojo_examples-Message-1bb1d226.json" -tag = "dojo_examples-Message" -qualified_path = "dojo_examples::models::message" -manifest_name = "dojo_examples-Message-1bb1d226" - -[[members]] -name = "identity" -type = "ContractAddress" -key = true - -[[members]] -name = "channel" -type = "felt252" -key = true - -[[members]] -name = "message" -type = "ByteArray" -key = false - -[[members]] -name = "salt" -type = "felt252" -key = true diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-MockToken-38903c7c.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-MockToken-38903c7c.toml deleted file mode 100644 index aff0ceb11c..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-MockToken-38903c7c.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x244a875f2049e4ca875b631270f1203a5be374fc040a8c4bd40405eeeea07bd" -original_class_hash = "0x244a875f2049e4ca875b631270f1203a5be374fc040a8c4bd40405eeeea07bd" -abi = "manifests/release/base/abis/models/dojo_examples-MockToken-38903c7c.json" -tag = "dojo_examples-MockToken" -qualified_path = "dojo_examples::models::mock_token" -manifest_name = "dojo_examples-MockToken-38903c7c" - -[[members]] -name = "account" -type = "ContractAddress" -key = true - -[[members]] -name = "amount" -type = "u128" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moved-318ae40d.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moved-318ae40d.toml deleted file mode 100644 index dd80b1bfb6..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moved-318ae40d.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x71f21bb9f7454ede4f4fe1482012218ef57448ca9687018dab409c4ddb790a2" -original_class_hash = "0x71f21bb9f7454ede4f4fe1482012218ef57448ca9687018dab409c4ddb790a2" -abi = "manifests/release/base/abis/models/dojo_examples-Moved-318ae40d.json" -tag = "dojo_examples-Moved" -qualified_path = "dojo_examples::actions::actions::moved" -manifest_name = "dojo_examples-Moved-318ae40d" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moves-2e2accba.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moves-2e2accba.toml deleted file mode 100644 index b199535b66..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Moves-2e2accba.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4dd1c573b5cdc56561be8b28a4840048a3a008d1a4a6eed397ec4135effaf44" -original_class_hash = "0x4dd1c573b5cdc56561be8b28a4840048a3a008d1a4a6eed397ec4135effaf44" -abi = "manifests/release/base/abis/models/dojo_examples-Moves-2e2accba.json" -tag = "dojo_examples-Moves" -qualified_path = "dojo_examples::models::moves" -manifest_name = "dojo_examples-Moves-2e2accba" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "remaining" -type = "u8" -key = false - -[[members]] -name = "last_direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-PlayerConfig-3adad785.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-PlayerConfig-3adad785.toml deleted file mode 100644 index 8265fde585..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-PlayerConfig-3adad785.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x515f106010313c2fcd87719836e75873aa75a711a4bdcd2ea0b6e38854deebf" -original_class_hash = "0x515f106010313c2fcd87719836e75873aa75a711a4bdcd2ea0b6e38854deebf" -abi = "manifests/release/base/abis/models/dojo_examples-PlayerConfig-3adad785.json" -tag = "dojo_examples-PlayerConfig" -qualified_path = "dojo_examples::models::player_config" -manifest_name = "dojo_examples-PlayerConfig-3adad785" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false - -[[members]] -name = "items" -type = "Array" -key = false - -[[members]] -name = "favorite_item" -type = "Option" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Position-1e145e26.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Position-1e145e26.toml deleted file mode 100644 index cbd25a32b4..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Position-1e145e26.toml +++ /dev/null @@ -1,17 +0,0 @@ -kind = "DojoModel" -class_hash = "0x5af60d63e6a1d25fc117fde1fa7e1d628adc46a52c3d007541ed6dd369e8ea" -original_class_hash = "0x5af60d63e6a1d25fc117fde1fa7e1d628adc46a52c3d007541ed6dd369e8ea" -abi = "manifests/release/base/abis/models/dojo_examples-Position-1e145e26.json" -tag = "dojo_examples-Position" -qualified_path = "dojo_examples::models::position" -manifest_name = "dojo_examples-Position-1e145e26" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "vec" -type = "Vec2" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ServerProfile-4caad1e6.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ServerProfile-4caad1e6.toml deleted file mode 100644 index 73192a2b7f..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-ServerProfile-4caad1e6.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x2fa72f20995710bef20ac3c36e2f43ec210517a787927ea3407e2b29c21bb0b" -original_class_hash = "0x2fa72f20995710bef20ac3c36e2f43ec210517a787927ea3407e2b29c21bb0b" -abi = "manifests/release/base/abis/models/dojo_examples-ServerProfile-4caad1e6.json" -tag = "dojo_examples-ServerProfile" -qualified_path = "dojo_examples::models::server_profile" -manifest_name = "dojo_examples-ServerProfile-4caad1e6" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "server_id" -type = "u32" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml deleted file mode 100644 index ff4e9f71b9..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml +++ /dev/null @@ -1,27 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4f3cbb247febb63bf5ab34d87504fd85e7a3b4ab6ff16fa2bf23597bf3309c7" -original_class_hash = "0x4f3cbb247febb63bf5ab34d87504fd85e7a3b4ab6ff16fa2bf23597bf3309c7" -abi = "manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json" -tag = "dojo_examples_foes-RiverSkale" -qualified_path = "bestiary::river_skale" -manifest_name = "dojo_examples_foes-RiverSkale-39535c12" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "health" -type = "u32" -key = false - -[[members]] -name = "armor" -type = "u32" -key = false - -[[members]] -name = "attack" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml deleted file mode 100644 index 3db33ef70d..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml +++ /dev/null @@ -1,22 +0,0 @@ -kind = "DojoModel" -class_hash = "0x783cecd986c0f03f8ac70318f67d57ea8072db7d4d135d54585f4de33c879ad" -original_class_hash = "0x783cecd986c0f03f8ac70318f67d57ea8072db7d4d135d54585f4de33c879ad" -abi = "manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json" -tag = "dojo_examples_weapons-Flatbow" -qualified_path = "armory::flatbow" -manifest_name = "dojo_examples_weapons-Flatbow-22f5bd16" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "atk_speek" -type = "u32" -key = false - -[[members]] -name = "range" -type = "u32" -key = false diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 70c6c5c16e..10095145b0 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -1,18 +1,16 @@ -use dojo_examples::models::{Direction, Position, Vec2, PlayerItem}; - -#[dojo::interface] -pub trait IActions { - fn spawn(ref world: IWorldDispatcher); - fn move(ref world: IWorldDispatcher, direction: Direction); - fn set_player_config(ref world: IWorldDispatcher, name: ByteArray); - fn get_player_position(world: @IWorldDispatcher) -> Position; - fn update_player_name(ref world: IWorldDispatcher, name: ByteArray); - fn update_player_items(ref world: IWorldDispatcher, items: Array); - fn reset_player_config(ref world: IWorldDispatcher); - fn set_player_server_profile(ref world: IWorldDispatcher, server_id: u32, name: ByteArray); - fn set_models(ref world: IWorldDispatcher, seed: felt252, n_models: u32); +use dojo_examples::models::{Direction, Position}; + +#[starknet::interface] +pub trait IActions { + fn spawn(ref self: T); + fn move(ref self: T, direction: Direction); + fn set_player_config(ref self: T, name: ByteArray); + fn get_player_position(self: @T) -> Position; + fn reset_player_config(ref self: T); + fn set_player_server_profile(ref self: T, server_id: u32, name: ByteArray); + fn set_models(ref self: T, seed: felt252, n_models: u32); #[cfg(feature: 'dungeon')] - fn enter_dungeon(ref world: IWorldDispatcher, dungeon_address: starknet::ContractAddress); + fn enter_dungeon(ref self: T, dungeon_address: starknet::ContractAddress); } #[dojo::contract] @@ -21,10 +19,11 @@ pub mod actions { use starknet::{ContractAddress, get_caller_address}; use dojo_examples::models::{ - Position, Moves, Direction, Vec2, PlayerConfig, PlayerItem, ServerProfile, PositionStore, - MovesStore, MovesEntityStore, PlayerConfigStore, PlayerConfigEntityStore, + Position, Moves, MovesValue, Direction, Vec2, PlayerConfig, PlayerItem, ServerProfile, }; use dojo_examples::utils::next_position; + use dojo::model::{ModelStorage, ModelValueStorage}; + use dojo::event::EventStorage; // Features can be used on modules, structs, trait and `use`. Not inside // a function. @@ -37,7 +36,6 @@ pub mod actions { #[derive(Copy, Drop, Serde)] #[dojo::event] - #[dojo::model] pub struct Moved { #[key] pub player: ContractAddress, @@ -48,7 +46,7 @@ pub mod actions { #[abi(embed_v0)] impl ActionsImpl of IActions { // Set some models randomly. - fn set_models(ref world: IWorldDispatcher, seed: felt252, n_models: u32) { + fn set_models(ref self: ContractState, seed: felt252, n_models: u32) { let uint: u256 = seed.into(); let prng: u32 = (uint % 4_294_967_000).try_into().unwrap(); let byte: u8 = (uint % 255).try_into().unwrap(); @@ -69,52 +67,59 @@ pub mod actions { favorite_item: Option::None }; + let mut world = self.world_default(); + if n_models == 4 { - set!(world, (moves, position, server_profile, player_config)); + world.write_model(@moves); + world.write_model(@position); + world.write_model(@server_profile); + world.write_model(@player_config); } else if n_models == 3 { - set!(world, (moves, position, server_profile)); + world.write_model(@moves); + world.write_model(@position); + world.write_model(@server_profile); } else if n_models == 2 { - set!(world, (moves, position)); + world.write_model(@moves); + world.write_model(@position); } else { - set!(world, (moves)); + world.write_model(@moves); } } // ContractState is defined by system decorator expansion - fn spawn(ref world: IWorldDispatcher) { + fn spawn(ref self: ContractState) { let player = get_caller_address(); - self.set_default_position(player, world); + self.set_default_position(player); } - fn move(ref world: IWorldDispatcher, direction: Direction) { + fn move(ref self: ContractState, direction: Direction) { let player = get_caller_address(); + let mut world = self.world_default(); // instead of using the `get!` macro, you can directly use // the Store::get method - let mut position = PositionStore::get(world, player); + let mut position: Position = world.read_model(player); - // you can also get entity values by entity ID with the `EntityStore` trait. - // Note that it returns a `Entity` struct which contains - // model values and the entity ID. - let move_id = MovesStore::entity_id_from_keys(player); - let mut moves = MovesEntityStore::get(world, move_id); + // You can get the entity ID in different ways. + // Using the `Model` Model::::entity_id(@model). + // Or using `dojo::utils::entity_id_from_keys([player].span())`. + let player_felt: felt252 = player.into(); + let move_id = dojo::utils::entity_id_from_keys([player_felt].span()); + let mut moves: MovesValue = world.read_value_from_id(move_id); moves.remaining -= 1; moves.last_direction = direction; - let next = next_position(position, direction); + world.write_value_from_id(move_id, @moves); - // instead of using the `set!` macro, you can directly use - // the Store::set method - next.set(world); - - // you can also update entity values by entity ID with the `EntityStore` - // trait. - moves.update(world); + let next = next_position(position, direction); + world.write_model(@next); - emit!(world, (Moved { player, direction })); + world.emit_event(@Moved { player, direction }); } - fn set_player_config(ref world: IWorldDispatcher, name: ByteArray) { + fn set_player_config(ref self: ContractState, name: ByteArray) { + let mut world = self.world_default(); + let player = get_caller_address(); let items = array![ @@ -123,20 +128,24 @@ pub mod actions { ]; let config = PlayerConfig { player, name, items, favorite_item: Option::Some(1), }; - - set!(world, (config)); + world.write_model(@config); } - fn reset_player_config(ref world: IWorldDispatcher) { + fn reset_player_config(ref self: ContractState) { let player = get_caller_address(); + let mut world = self.world_default(); - let (position, moves) = get!(world, player, (Position, Moves)); - let config = PlayerConfigStore::get(world, player); + let position: Position = world.read_model(player); + let moves: Moves = world.read_model(player); + let config: PlayerConfig = world.read_model(player); - delete!(world, (position, moves)); - config.delete(world); + world.erase_model(@position); + world.erase_model(@moves); + world.erase_model(@config); - let (position, moves, config) = get!(world, player, (Position, Moves, PlayerConfig)); + let position: Position = world.read_model(player); + let moves: Moves = world.read_model(player); + let config: PlayerConfig = world.read_model(player); assert(moves.remaining == 0, 'bad remaining'); assert(moves.last_direction == Direction::None, 'bad last direction'); @@ -150,50 +159,31 @@ pub mod actions { assert(config.name == empty_string, 'bad name'); } - fn set_player_server_profile(ref world: IWorldDispatcher, server_id: u32, name: ByteArray) { + fn set_player_server_profile(ref self: ContractState, server_id: u32, name: ByteArray) { let player = get_caller_address(); - set!(world, ServerProfile { player, server_id, name }); + let mut world = self.world_default(); + + let profile = ServerProfile { player, server_id, name }; + world.write_model(@profile); } - fn get_player_position(world: @IWorldDispatcher) -> Position { + fn get_player_position(self: @ContractState) -> Position { let player = get_caller_address(); - get!(world, player, (Position)) + let mut world = self.world_default(); + world.read_model(player) } #[cfg(feature: 'dungeon')] - fn enter_dungeon(ref world: IWorldDispatcher, dungeon_address: ContractAddress) { + fn enter_dungeon(ref self: ContractState, dungeon_address: ContractAddress) { + let mut world = self.world_default(); + let flatbow = Flatbow { id: 1, atk_speek: 2, range: 1 }; let river_skale = RiverSkale { id: 1, health: 5, armor: 3, attack: 2 }; - set!(world, (flatbow, river_skale)); - IDungeonDispatcher { contract_address: dungeon_address }.enter(); - } - - fn update_player_name(ref world: IWorldDispatcher, name: ByteArray) { - let player = get_caller_address(); - let config = PlayerConfigStore::get(world, player); - config.set_name(world, name.clone()); - - let new_name = PlayerConfigStore::get_name(world, player); - assert(new_name == name, 'unable to change name'); - } - - fn update_player_items(ref world: IWorldDispatcher, items: Array) { - let player = get_caller_address(); - let config_id = PlayerConfigStore::entity_id_from_keys(player); - - let items_clone = items.clone(); - - let config = PlayerConfigEntityStore::get(world, config_id); - config.set_items(world, items); + world.write_model(@flatbow); + world.write_model(@river_skale); - let new_items = PlayerConfigEntityStore::get_items(world, config_id); - let mut size = items_clone.len(); - - while size > 0 { - assert(new_items.at(size - 1) == items_clone.at(size - 1), 'item not found'); - size -= 1; - } + IDungeonDispatcher { contract_address: dungeon_address }.enter(); } } @@ -201,65 +191,77 @@ pub mod actions { // Hence, the use of `self` to access the contract state. #[generate_trait] impl InternalImpl of InternalUtils { - fn set_default_position( - self: @ContractState, player: ContractAddress, world: IWorldDispatcher - ) { - // The world is always accessible from `self` inside a `dojo::contract`. - // let world = self.world(); - - set!( - world, - ( - Moves { player, remaining: 99, last_direction: Direction::None }, - Position { player, vec: Vec2 { x: 10, y: 10 } }, - ) - ); + fn set_default_position(self: @ContractState, player: ContractAddress) { + let mut world = self.world_default(); + + world.write_model(@Moves { player, remaining: 99, last_direction: Direction::None }); + world.write_model(@Position { player, vec: Vec2 { x: 10, y: 10 } },); + } + + /// Use the default namespace "ns". A function is handy since the ByteArray + /// can't be const. + fn world_default(self: @ContractState) -> dojo::world::WorldStorage { + self.world(@"ns") } } } #[cfg(test)] mod tests { - use dojo::model::{Model, ModelTest, ModelIndex, ModelEntityTest}; - use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; - - use dojo::utils::test::deploy_contract; + use dojo::model::{ModelStorage, ModelValueStorage, ModelStorageTest}; + use dojo::world::WorldStorageTrait; + use dojo_cairo_test::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait}; use super::{actions, IActionsDispatcher, IActionsDispatcherTrait}; - use armory::flatbow; - use dojo_examples::models::{ - Position, position, PositionStore, PositionEntityStore, Moves, moves, Direction, Vec2 - }; + use dojo_examples::models::{Position, PositionValue, m_Position, Moves, m_Moves, Direction,}; + + fn namespace_def() -> NamespaceDef { + let ndef = NamespaceDef { + namespace: "ns", resources: [ + TestResource::Model(m_Position::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Model(m_Moves::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Event(actions::e_Moved::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Contract( + ContractDefTrait::new(actions::TEST_CLASS_HASH, "actions") + .with_writer_of([dojo::utils::bytearray_hash(@"ns")].span()) + ) + ].span() + }; + + ndef + } #[test] fn test_world_test_set() { let caller = starknet::contract_address_const::<0x0>(); - let world = spawn_test_world!(); + let ndef = namespace_def(); + let mut world = spawn_test_world([ndef].span()); // Without having the permission, we can set data into the dojo database for the given // models. - let mut position = PositionStore::get(world, caller); + let mut position: Position = world.read_model(caller); assert(position.vec.x == 0 && position.vec.y == 0, 'bad x'); position.vec.x = 122; - // `set_test` and `delete_test` are available on `Model`. - // `update_test` and `delete_test` are available on `ModelEntity`. - position.set_test(world); + // `write_model_test` and `erase_model_test` are available to bypass permissions. + world.write_model_test(@position); - let id = PositionStore::entity_id_from_keys(caller); - let mut position = PositionEntityStore::get(world, id); + // Example using the entity id. + let caller_felt: felt252 = caller.into(); + let id = dojo::utils::entity_id_from_keys([caller_felt].span()); + let mut position: PositionValue = world.read_value_from_id(id); assert(position.vec.x == 122, 'bad x'); position.vec.y = 88; - position.update_test(world); + world.write_value_from_id(id, @position); - let mut position = PositionStore::get(world, caller); + let mut position: Position = world.read_model(caller); assert(position.vec.y == 88, 'bad y'); - position.delete_test(world); + world.erase_model(@position); - let position = PositionStore::get(world, caller); + let position: Position = world.read_model(caller); assert(position.vec.x == 0 && position.vec.y == 0, 'bad delete'); } @@ -268,22 +270,15 @@ mod tests { fn test_move() { let caller = starknet::contract_address_const::<0x0>(); - // deploy world with only the models for the given namespaces. - let world = spawn_test_world!(["dojo_examples", "dojo_examples_weapons"]); - - // deploy systems contract - let contract_address = world - .deploy_contract('salt', actions::TEST_CLASS_HASH.try_into().unwrap()); - let actions_system = IActionsDispatcher { contract_address }; + let ndef = namespace_def(); + let mut world = spawn_test_world([ndef].span()); - // set authorizations - world.grant_writer(Model::::selector(), contract_address); - world.grant_writer(Model::::selector(), contract_address); + let (actions_system_addr, _) = world.dns(@"actions").unwrap(); + let actions_system = IActionsDispatcher { contract_address: actions_system_addr }; - // System calls actions_system.spawn(); - let initial_moves = get!(world, caller, Moves); - let initial_position = get!(world, caller, Position); + let initial_moves: Moves = world.read_model(caller); + let initial_position: Position = world.read_model(caller); assert( initial_position.vec.x == 10 && initial_position.vec.y == 10, 'wrong initial position' @@ -291,13 +286,13 @@ mod tests { actions_system.move(Direction::Right(())); - let moves = get!(world, caller, Moves); + let moves: Moves = world.read_model(caller); let right_dir_felt: felt252 = Direction::Right(()).into(); assert(moves.remaining == initial_moves.remaining - 1, 'moves is wrong'); assert(moves.last_direction.into() == right_dir_felt, 'last direction is wrong'); - let new_position = get!(world, caller, Position); + let new_position: Position = world.read_model(caller); assert(new_position.vec.x == initial_position.vec.x + 1, 'position x is wrong'); assert(new_position.vec.y == initial_position.vec.y, 'position y is wrong'); } diff --git a/examples/spawn-and-move/src/dungeon.cairo b/examples/spawn-and-move/src/dungeon.cairo index 474f88b818..8ac2950b7f 100644 --- a/examples/spawn-and-move/src/dungeon.cairo +++ b/examples/spawn-and-move/src/dungeon.cairo @@ -1,12 +1,12 @@ -#[dojo::interface] -pub trait IDungeon { - fn enter(); +#[starknet::interface] +pub trait IDungeon { + fn enter(self: @T); } #[dojo::contract] pub mod dungeon { #[abi(embed_v0)] pub impl IDungeonImpl of super::IDungeon { - fn enter() {} + fn enter(self: @ContractState) {} } } diff --git a/examples/spawn-and-move/src/mock_token.cairo b/examples/spawn-and-move/src/mock_token.cairo index 1d0174eb34..a7a637038a 100644 --- a/examples/spawn-and-move/src/mock_token.cairo +++ b/examples/spawn-and-move/src/mock_token.cairo @@ -1,10 +1,12 @@ #[dojo::contract] pub mod mock_token { use dojo_examples::models::{MockToken}; + use dojo::model::ModelStorage; use starknet::{ContractAddress, get_caller_address}; - fn dojo_init(world: @IWorldDispatcher) { + fn dojo_init(self: @ContractState) { let account: ContractAddress = get_caller_address(); - set!(world, MockToken { account, amount: 1000 }); + let mut world = self.world(@"ns"); + world.write_model(@MockToken { account, amount: 1000 }); } } diff --git a/examples/spawn-and-move/src/models.cairo b/examples/spawn-and-move/src/models.cairo index 094ec84eab..fc389d2cc9 100644 --- a/examples/spawn-and-move/src/models.cairo +++ b/examples/spawn-and-move/src/models.cairo @@ -117,7 +117,7 @@ impl Vec2Impl of Vec2Trait { #[cfg(test)] mod tests { - use super::{Position, Vec2, Vec2Trait}; + use super::{Vec2, Vec2Trait}; #[test] #[available_gas(100000)] diff --git a/examples/spawn-and-move/src/others.cairo b/examples/spawn-and-move/src/others.cairo index 8b9c1a9c67..b864d264cb 100644 --- a/examples/spawn-and-move/src/others.cairo +++ b/examples/spawn-and-move/src/others.cairo @@ -1,31 +1,19 @@ #[dojo::contract] pub mod others { - use starknet::{ContractAddress, ClassHash, get_caller_address}; - use dojo_examples::models::{Position, Moves, Direction, Vec2}; - use dojo_examples::utils::next_position; + use starknet::{ContractAddress, get_caller_address}; + use dojo::event::EventStorage; #[derive(Copy, Drop, Serde)] #[dojo::event] - #[dojo::model] struct ContractInitialized { #[key] - contract_address: ContractAddress, - contract_class: ClassHash, + caller: ContractAddress, value: u8, } + fn dojo_init(self: @ContractState, value: u8) { + let mut world = self.world(@"ns"); - fn dojo_init( - world: @IWorldDispatcher, - actions_address: ContractAddress, - actions_class: ClassHash, - value: u8 - ) { - emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); + world.emit_event(@ContractInitialized { caller: get_caller_address(), value }); } } diff --git a/scripts/build_cairo_projects.sh b/scripts/build_cairo_projects.sh index df5536ebc6..cfa2c2bc0b 100644 --- a/scripts/build_cairo_projects.sh +++ b/scripts/build_cairo_projects.sh @@ -6,5 +6,5 @@ sozo_path=$1 # Re-run the minimal tests, this will re-build the projects + generate the build artifacts. $sozo_path build --manifest-path examples/spawn-and-move/Scarb.toml $sozo_path build --manifest-path examples/spawn-and-move/Scarb.toml -P release +$sozo_path build --manifest-path examples/simple/Scarb.toml $sozo_path build --manifest-path crates/torii/types-test/Scarb.toml -$sozo_path build --manifest-path crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml diff --git a/scripts/cairo_fmt.sh b/scripts/cairo_fmt.sh index 3c3dad52b6..c5977f9cb7 100755 --- a/scripts/cairo_fmt.sh +++ b/scripts/cairo_fmt.sh @@ -1,4 +1,6 @@ #!/bin/bash scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt --check -scarb --manifest-path crates/dojo-core/Scarb.toml fmt --check +scarb --manifest-path examples/simple/Scarb.toml fmt --check +scarb --manifest-path crates/dojo/core/Scarb.toml fmt --check +scarb --manifest-path crates/dojo/core-cairo-test/Scarb.toml fmt --check diff --git a/scripts/cairo_test.sh b/scripts/cairo_test.sh index b4f57ad916..e6db2d45cb 100755 --- a/scripts/cairo_test.sh +++ b/scripts/cairo_test.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail -cargo run -r --bin sozo -- --manifest-path crates/dojo-core/Scarb.toml test $@ +cargo run -r --bin sozo -- --manifest-path crates/dojo/core/Scarb.toml test $@ cargo run -r --bin sozo -- --manifest-path examples/spawn-and-move/Scarb.toml test $@ diff --git a/scripts/rebuild_test_artifacts.sh b/scripts/rebuild_test_artifacts.sh index f4d4784108..4035437344 100755 --- a/scripts/rebuild_test_artifacts.sh +++ b/scripts/rebuild_test_artifacts.sh @@ -4,32 +4,36 @@ # cairo artifacts ONLY if they don't exist. # This script gives an easy way to remove those artifacts. -# A Katana instance must be running on http://localhost:8000. -# cargo run --bin katana +cargo build -r --bin katana + +# some formatting: +cargo +nightly-2024-08-28 fmt --all -- "$@" + +scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt +scarb --manifest-path examples/simple/Scarb.toml fmt +scarb --manifest-path crates/dojo/core/Scarb.toml fmt +scarb --manifest-path crates/dojo/core-cairo-test/Scarb.toml fmt cargo build -r --bin sozo # Cleanup rm -rf examples/spawn-and-move/target -rm -rf examples/spawn-and-move/manifests/ - rm -rf crates/torii/types-test/target -rm -rf crates/torii/types-test/manifests +rm -rf crates/dojo/lang/src/manifest_test_data/compiler_cairo/target -rm -rf crates/dojo-lang/src/manifest_test_data/compiler_cairo/target -rm -rf crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests +# Ensure the world bindings are up to date. +cargo run --bin dojo-world-abigen -r -cargo run --bin dojo-world-abigen +cargo +nightly-2024-08-28 fmt --all -- "$@" # Fix the cairo test to re-generate the code that is expected to be tested. -CAIRO_FIX_TESTS=1 cargo test --package dojo-lang plugin && \ -CAIRO_FIX_TESTS=1 cargo test --package dojo-lang semantics +# CAIRO_FIX_TESTS=1 cargo test --package dojo-lang plugin && \ +# CAIRO_FIX_TESTS=1 cargo test --package dojo-lang semantics # Re-run the minimal tests, this will re-build the projects + generate the build artifacts. ./target/release/sozo build --manifest-path examples/spawn-and-move/Scarb.toml ./target/release/sozo build --manifest-path examples/spawn-and-move/Scarb.toml -P release ./target/release/sozo build --manifest-path crates/torii/types-test/Scarb.toml -./target/release/sozo build --manifest-path crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml # Generates the database for testing by migrating the spawn and move example. cargo generate-test-db @@ -38,5 +42,3 @@ rm -rf /tmp/spawn-and-move-db rm -rf /tmp/types-test-db tar xzf spawn-and-move-db.tar.gz -C /tmp/ tar xzf types-test-db.tar.gz -C /tmp/ - -./target/release/sozo --offline migrate apply --manifest-path examples/spawn-and-move/Scarb.toml diff --git a/spawn-and-move-db.tar.gz b/spawn-and-move-db.tar.gz index 935df0c037..2a44ce43ae 100644 Binary files a/spawn-and-move-db.tar.gz and b/spawn-and-move-db.tar.gz differ diff --git a/types-test-db.tar.gz b/types-test-db.tar.gz index d9f699a895..b373ed5947 100644 Binary files a/types-test-db.tar.gz and b/types-test-db.tar.gz differ diff --git a/xtask/generate-test-db/Cargo.toml b/xtask/generate-test-db/Cargo.toml index 4ad6f23e42..fce4c59f69 100644 --- a/xtask/generate-test-db/Cargo.toml +++ b/xtask/generate-test-db/Cargo.toml @@ -6,6 +6,7 @@ repository.workspace = true version.workspace = true [dependencies] +anyhow.workspace = true dojo-test-utils.workspace = true dojo-utils.workspace = true katana-runner.workspace = true @@ -14,3 +15,5 @@ scarb.workspace = true sozo-ops = { workspace = true, features = [ "test-utils" ] } starknet.workspace = true tokio.workspace = true +sozo-scarbext.workspace = true +dojo-world.workspace = true diff --git a/xtask/generate-test-db/src/main.rs b/xtask/generate-test-db/src/main.rs index bd36fc4144..8f4b34de58 100644 --- a/xtask/generate-test-db/src/main.rs +++ b/xtask/generate-test-db/src/main.rs @@ -1,16 +1,21 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; +use std::str::FromStr; +use anyhow::Result; use dojo_test_utils::compiler::CompilerTestSetup; use dojo_utils::TxnConfig; +use dojo_world::contracts::WorldContract; +use dojo_world::diff::{Manifest, WorldDiff}; use katana_runner::{KatanaRunner, KatanaRunnerConfig}; use scarb::compiler::Profile; -use sozo_ops::migration::MigrationOutput; +use sozo_ops::migrate::{Migration, MigrationUi}; +use sozo_scarbext::WorkspaceExt; +use starknet::core::types::Felt; -type Result = std::result::Result>; - -async fn migrate_spawn_and_move(db_path: &Path) -> Result { +async fn migrate_spawn_and_move(db_path: &Path) -> Result { + println!("migrate spawn_and_move"); let cfg = KatanaRunnerConfig { db_dir: Some(db_path.to_path_buf()), n_accounts: 10, @@ -20,27 +25,44 @@ async fn migrate_spawn_and_move(db_path: &Path) -> Result { let runner = KatanaRunner::new_with_config(cfg)?; // setup scarb workspace - let setup = CompilerTestSetup::from_examples("crates/dojo-core", "examples/"); + let setup = CompilerTestSetup::from_examples("crates/dojo/core", "examples/"); let cfg = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(cfg.manifest_path(), &cfg)?; - let output = sozo_ops::migration::migrate( - &ws, - None, + let mut txn_config: TxnConfig = TxnConfig::init_wait(); + txn_config.wait = true; + + let profile_config = ws.load_profile_config()?; + + let world_local = ws.load_world_local()?; + let world_address = if let Some(env) = &profile_config.env { + env.world_address().map_or_else( + || world_local.deterministic_world_address(), + |wa| Ok(Felt::from_str(wa).unwrap()), + ) + } else { + world_local.deterministic_world_address() + } + .unwrap(); + + let world_diff = + WorldDiff::new_from_chain(world_address, world_local, &runner.provider()).await?; + + let result = Migration::new( + world_diff, + WorldContract::new(world_address, &runner.account(0)), + txn_config, + profile_config, runner.url().to_string(), - runner.account(0), - "dojo_examples", - false, - TxnConfig::init_wait(), - None, ) + .migrate(&mut MigrationUi::None) .await?; - // We know it's always successful as the migration is applied with dry-run set to false. - Ok(output.unwrap()) + Ok(result.manifest) } -async fn migrate_types_test(db_path: &Path) -> Result { +async fn migrate_types_test(db_path: &Path) -> Result { + println!("migrate types_test"); let cfg = KatanaRunnerConfig { db_dir: Some(db_path.to_path_buf()), n_accounts: 10, @@ -50,24 +72,40 @@ async fn migrate_types_test(db_path: &Path) -> Result { let runner = KatanaRunner::new_with_config(cfg)?; // setup scarb workspace - let setup = CompilerTestSetup::from_paths("crates/dojo-core", &["crates/torii/types-test"]); + let setup = CompilerTestSetup::from_paths("crates/dojo/core", &["crates/torii/types-test"]); let cfg = setup.build_test_config("types-test", Profile::DEV); let ws = scarb::ops::read_workspace(cfg.manifest_path(), &cfg)?; - let output = sozo_ops::migration::migrate( - &ws, - None, + let mut txn_config: TxnConfig = TxnConfig::init_wait(); + txn_config.wait = true; + + let profile_config = ws.load_profile_config()?; + + let world_local = ws.load_world_local()?; + let world_address = if let Some(env) = &profile_config.env { + env.world_address().map_or_else( + || world_local.deterministic_world_address(), + |wa| Ok(Felt::from_str(wa).unwrap()), + ) + } else { + world_local.deterministic_world_address() + } + .unwrap(); + + let world_diff = + WorldDiff::new_from_chain(world_address, world_local, &runner.provider()).await?; + + let result = Migration::new( + world_diff, + WorldContract::new(world_address, &runner.account(0)), + txn_config, + profile_config, runner.url().to_string(), - runner.account(0), - "types_test", - false, - TxnConfig::init_wait(), - None, ) + .migrate(&mut MigrationUi::None) .await?; - // We know it's always successful as the migration is applied with dry-run set to false. - Ok(output.unwrap()) + Ok(result.manifest) } #[tokio::main]