diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c4875e..c635312 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Install wasm32 target run: rustup target add wasm32-unknown-unknown - name: Compile WASM - run: cargo build --release --target wasm32-unknown-unknown -p wasm + run: cargo build --release --target wasm32-unknown-unknown -p dojo-wasm ensure-c: name: Check C bindings compilation @@ -64,7 +64,42 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Compile C bindings - run: cargo build --release -p c + run: cargo build --release -p dojo-c + + ensure-uniffi: + name: Check UniFFI bindings compilation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # Install system dependencies + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev pkg-config + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + - uses: Swatinem/rust-cache@v2 + - uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Compile UniFFI library + run: cargo build --release -p dojo-uniffi + - name: Build UniFFI bindgen tools + run: | + cargo build --release --bin uniffi-bindgen-swift + cargo build --release --bin uniffi-bindgen-python + cargo build --release --bin uniffi-bindgen-kotlin + - name: Generate Swift bindings + run: ./target/release/uniffi-bindgen-swift + - name: Generate Python bindings + run: ./target/release/uniffi-bindgen-python + - name: Generate Kotlin bindings + run: ./target/release/uniffi-bindgen-kotlin + - name: Verify bindings generated + run: | + test -f bindings/swift/DojoEngine.swift || exit 1 + test -f bindings/python/dojo.py || exit 1 + test -f bindings/kotlin/com/dojoengine/dojo/dojo.kt || exit 1 + echo "✓ All UniFFI bindings generated successfully" clippy: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e37eaf5..df9899b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,6 +67,108 @@ jobs: torii-wasm-no-modules.tar.gz torii-wasm-web.tar.gz + build-uniffi: + name: Build UniFFI bindings + needs: prepare + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux + target: x86_64-unknown-linux-gnu + lib_name: libdojo_uniffi.so + - os: macos-latest + platform: darwin + target: x86_64-apple-darwin + lib_name: libdojo_uniffi.dylib + - os: macos-latest + platform: darwin + target: aarch64-apple-darwin + lib_name: libdojo_uniffi.dylib + - os: windows-latest + platform: windows + target: x86_64-pc-windows-msvc + lib_name: dojo_uniffi.dll + + steps: + - uses: actions/checkout@v3 + + - uses: dtolnay/rust-toolchain@master + name: Rust Toolchain Setup + with: + targets: ${{ matrix.target }} + toolchain: ${{ env.RUST_VERSION }} + + - uses: Swatinem/rust-cache@v1 + with: + cache-on-failure: true + + - uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install system dependencies (Linux) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev pkg-config + + - name: Install target + run: rustup target add ${{ matrix.target }} + + - name: Build UniFFI library + run: cargo build --release --target ${{ matrix.target }} -p dojo-uniffi + + - name: Build bindgen tools + run: | + cargo build --release --target ${{ matrix.target }} --bin uniffi-bindgen-swift + cargo build --release --target ${{ matrix.target }} --bin uniffi-bindgen-python + cargo build --release --target ${{ matrix.target }} --bin uniffi-bindgen-kotlin + + - name: Generate Swift bindings + shell: bash + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + ./target/${{ matrix.target }}/release/uniffi-bindgen-swift.exe + else + ./target/${{ matrix.target }}/release/uniffi-bindgen-swift + fi + + - name: Generate Python bindings + shell: bash + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + ./target/${{ matrix.target }}/release/uniffi-bindgen-python.exe + else + ./target/${{ matrix.target }}/release/uniffi-bindgen-python + fi + + - name: Generate Kotlin bindings + shell: bash + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + ./target/${{ matrix.target }}/release/uniffi-bindgen-kotlin.exe + else + ./target/${{ matrix.target }}/release/uniffi-bindgen-kotlin + fi + + - name: Package UniFFI bindings + shell: bash + run: | + mkdir -p dojo-uniffi-${{ matrix.target }} + cp target/${{ matrix.target }}/release/${{ matrix.lib_name }} dojo-uniffi-${{ matrix.target }}/ + cp -r bindings/swift dojo-uniffi-${{ matrix.target }}/ + cp -r bindings/python dojo-uniffi-${{ matrix.target }}/ + cp -r bindings/kotlin dojo-uniffi-${{ matrix.target }}/ + cp -r examples dojo-uniffi-${{ matrix.target }}/ + tar -czvf dojo-uniffi-${{ matrix.target }}.tar.gz dojo-uniffi-${{ matrix.target }}/ + + - name: Create release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + dojo-uniffi-${{ matrix.target }}.tar.gz + build-and-release: name: ${{ matrix.job.target }} (${{ matrix.job.os }}) needs: prepare diff --git a/Cargo.lock b/Cargo.lock index 87c8b47..4b34f59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - [[package]] name = "adler2" version = "2.0.1" @@ -54,9 +45,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -69,9 +60,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -104,9 +95,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arrayvec" @@ -123,6 +114,48 @@ dependencies = [ "term", ] +[[package]] +name = "askama" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7" +dependencies = [ + "askama_derive", + "itoa", + "percent-encoding", + "serde", + "serde_json", +] + +[[package]] +name = "askama_derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac" +dependencies = [ + "askama_parser", + "basic-toml", + "memchr", + "proc-macro2", + "quote", + "rustc-hash 2.1.1", + "serde", + "serde_derive", + "syn 2.0.107", +] + +[[package]] +name = "askama_parser" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f" +dependencies = [ + "memchr", + "serde", + "serde_derive", + "winnow", +] + [[package]] name = "assert_matches" version = "1.5.0" @@ -148,7 +181,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -159,7 +192,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -176,7 +209,7 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -192,7 +225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", @@ -200,7 +233,7 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.32", "itoa", - "matchit", + "matchit 0.7.3", "memchr", "mime", "percent-encoding", @@ -213,6 +246,39 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18ed336352031311f4e0b4dd2ff392d4fbb370777c9d18d7fc9d7359f73871" +dependencies = [ + "axum-core 0.5.5", + "bytes", + "form_urlencoded", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.7.0", + "hyper-util", + "itoa", + "matchit 0.8.4", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tower 0.5.2", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "axum-core" version = "0.3.4" @@ -231,18 +297,22 @@ dependencies = [ ] [[package]] -name = "backtrace" -version = "0.3.75" +name = "axum-core" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22" dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", + "bytes", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", + "tracing", ] [[package]] @@ -263,6 +333,15 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "basic-toml" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.8.0" @@ -286,9 +365,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitvec" @@ -353,32 +432,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -[[package]] -name = "c" -version = "1.8.3" -dependencies = [ - "anyhow", - "cainome", - "cbindgen", - "chrono", - "crypto-bigint", - "dojo-core", - "dojo-types", - "dojo-world", - "futures", - "lazy_static", - "serde", - "serde_json", - "starknet", - "starknet-crypto", - "stream-cancel", - "tokio", - "tokio-stream", - "torii-client", - "torii-proto", - "url", -] - [[package]] name = "cainome" version = "0.10.1" @@ -400,7 +453,7 @@ dependencies = [ "serde_json", "starknet", "starknet-types-core", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "tracing-subscriber", "url", @@ -416,7 +469,7 @@ dependencies = [ "serde", "serde_with", "starknet", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -427,7 +480,7 @@ checksum = "d272424141f0ced49ca5f40bc4b756235ee6e7c9cf6ab01f7ef5ac010f5f8864" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "unzip-n", ] @@ -441,8 +494,8 @@ dependencies = [ "quote", "serde_json", "starknet", - "syn 2.0.106", - "thiserror 2.0.16", + "syn 2.0.107", + "thiserror 2.0.17", ] [[package]] @@ -460,8 +513,8 @@ dependencies = [ "quote", "serde_json", "starknet", - "syn 2.0.106", - "thiserror 2.0.16", + "syn 2.0.107", + "thiserror 2.0.17", ] [[package]] @@ -479,8 +532,8 @@ dependencies = [ "quote", "serde_json", "starknet", - "syn 2.0.106", - "thiserror 2.0.16", + "syn 2.0.107", + "thiserror 2.0.17", ] [[package]] @@ -531,7 +584,7 @@ dependencies = [ "sha3", "smol_str", "starknet-types-core", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -547,7 +600,7 @@ dependencies = [ "itertools 0.14.0", "num-bigint", "num-traits", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -563,7 +616,7 @@ dependencies = [ "itertools 0.14.0", "num-bigint", "num-traits", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -584,7 +637,7 @@ dependencies = [ "num-bigint", "num-traits", "starknet-types-core", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -617,7 +670,7 @@ dependencies = [ "sha3", "smol_str", "starknet-types-core", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -627,7 +680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cca315cce0937801a772bee5fe92cca28b8172421bdd2f67c96e8288a0dcfb9f" dependencies = [ "hashbrown 0.15.5", - "indexmap 2.11.3", + "indexmap 2.12.0", "itertools 0.14.0", "num-bigint", "num-traits", @@ -638,13 +691,36 @@ dependencies = [ [[package]] name = "camino" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1de8bc0aa9e9385ceb3bf0c152e3a9b9544f6c4a912c8ae504e80c1f0368603" +checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" dependencies = [ "serde_core", ] +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror 2.0.17", +] + [[package]] name = "cbindgen" version = "0.27.0" @@ -652,22 +728,22 @@ source = "git+https://github.com/Larkooo/cbindgen?branch=no-c-forward-enum#1df07 dependencies = [ "clap", "heck 0.4.1", - "indexmap 2.11.3", + "indexmap 2.12.0", "log", "proc-macro2", "quote", "serde", "serde_json", - "syn 2.0.106", + "syn 2.0.107", "tempfile", - "toml", + "toml 0.8.23", ] [[package]] name = "cc" -version = "1.2.37" +version = "1.2.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" dependencies = [ "find-msvc-tools", "shlex", @@ -675,9 +751,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -696,7 +772,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -711,9 +787,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.47" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" dependencies = [ "clap_builder", "clap_derive", @@ -721,9 +797,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.47" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" dependencies = [ "anstream", "anstyle", @@ -733,30 +809,30 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.58" +version = "4.5.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75bf0b32ad2e152de789bb635ea4d3078f6b838ad7974143e99b99f45a04af4a" +checksum = "2348487adcd4631696ced64ccdb40d38ac4d31cae7f2eec8817fcea1b9d1c43c" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "colorchoice" @@ -782,9 +858,9 @@ checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" [[package]] name = "const_format" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" dependencies = [ "const_format_proc_macros", ] @@ -819,6 +895,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -882,9 +968,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ "darling_core", "darling_macro", @@ -892,37 +978,58 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.106", + "syn 2.0.107", +] + +[[package]] +name = "dbus" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190b6255e8ab55a7b568df5a883e9497edc3e4821c06396612048b430e5ad1e9" +dependencies = [ + "libc", + "libdbus-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "dbus-secret-service" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "708b509edf7889e53d7efb0ffadd994cc6c2345ccb62f55cfd6b0682165e4fa6" +dependencies = [ + "dbus", + "zeroize", ] [[package]] name = "deranged" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc" +checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" dependencies = [ "powerfmt", - "serde", + "serde_core", ] [[package]] @@ -947,6 +1054,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -955,7 +1083,33 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", +] + +[[package]] +name = "dojo-c" +version = "1.8.3" +dependencies = [ + "anyhow", + "cainome", + "cbindgen", + "chrono", + "crypto-bigint", + "dojo-core", + "dojo-types", + "dojo-world", + "futures", + "lazy_static", + "serde", + "serde_json", + "starknet", + "starknet-crypto", + "stream-cancel", + "tokio", + "tokio-stream", + "torii-client", + "torii-proto", + "url", ] [[package]] @@ -983,7 +1137,7 @@ dependencies = [ "cainome", "crypto-bigint", "hex", - "indexmap 2.11.3", + "indexmap 2.12.0", "itertools 0.12.1", "num-traits", "regex", @@ -996,6 +1150,84 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "dojo-uniffi" +version = "1.8.3" +dependencies = [ + "anyhow", + "axum 0.8.6", + "base64 0.22.1", + "cainome", + "camino", + "cargo_metadata", + "chrono", + "crypto-bigint", + "directories", + "dojo-core", + "dojo-types", + "dojo-world", + "futures", + "futures-util", + "hex", + "keyring", + "lazy_static", + "num-bigint", + "num-traits", + "open", + "serde", + "serde_json", + "starknet", + "starknet-crypto", + "stream-cancel", + "thiserror 2.0.17", + "tokio", + "tokio-stream", + "torii-client", + "torii-grpc-client", + "torii-proto", + "tower-http 0.6.6", + "uniffi", + "uniffi_bindgen", + "url", + "urlencoding", +] + +[[package]] +name = "dojo-wasm" +version = "1.8.3" +dependencies = [ + "anyhow", + "cainome", + "chrono", + "console_error_panic_hook", + "crypto-bigint", + "dojo-core", + "dojo-types", + "dojo-world", + "futures", + "gloo-timers", + "gloo-utils", + "instant", + "js-sys", + "num-bigint", + "num-traits", + "serde", + "serde-wasm-bindgen", + "serde_json", + "starknet", + "starknet-crypto", + "stream-cancel", + "tokio", + "torii-client", + "torii-proto", + "tsify-next", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test", + "web-sys", +] + [[package]] name = "dojo-world" version = "1.7.1" @@ -1016,7 +1248,7 @@ dependencies = [ "starknet", "starknet-crypto", "thiserror 1.0.69", - "toml", + "toml 0.8.23", "tracing", "url", ] @@ -1055,7 +1287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.0", + "windows-sys 0.61.2", ] [[package]] @@ -1115,9 +1347,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "find-msvc-tools" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" [[package]] name = "fixed-hash" @@ -1145,9 +1377,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", "miniz_oxide", @@ -1174,6 +1406,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + [[package]] name = "funty" version = "2.0.0" @@ -1236,7 +1477,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1271,9 +1512,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ "typenum", "version_check", @@ -1288,29 +1529,29 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "js-sys", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", "wasm-bindgen", ] [[package]] -name = "gimli" -version = "0.31.1" +name = "glob" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "gloo-timers" @@ -1337,6 +1578,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "goblin" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" +dependencies = [ + "log", + "plain", + "scroll", +] + [[package]] name = "good_lp" version = "1.14.0" @@ -1359,7 +1611,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.11.3", + "indexmap 2.12.0", "slab", "tokio", "tokio-util", @@ -1384,6 +1636,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "heck" version = "0.4.1" @@ -1528,6 +1786,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "pin-utils", @@ -1545,12 +1804,12 @@ dependencies = [ "http 1.3.1", "hyper 1.7.0", "hyper-util", - "rustls 0.23.31", + "rustls 0.23.33", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.3", + "tokio-rustls 0.26.4", "tower-service", - "webpki-roots 1.0.2", + "webpki-roots 1.0.3", ] [[package]] @@ -1583,7 +1842,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.0", + "socket2 0.6.1", "tokio", "tower-service", "tracing", @@ -1761,7 +2020,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1777,12 +2036,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.3" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "serde", "serde_core", ] @@ -1814,17 +2073,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "io-uring" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" -dependencies = [ - "bitflags 2.9.4", - "cfg-if", - "libc", -] - [[package]] name = "ipnet" version = "2.11.0" @@ -1841,6 +2089,25 @@ dependencies = [ "serde", ] +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1873,9 +2140,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.80" +version = "0.3.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e" +checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" dependencies = [ "once_cell", "wasm-bindgen", @@ -1890,6 +2157,21 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keyring" +version = "3.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c" +dependencies = [ + "byteorder", + "dbus-secret-service", + "log", + "security-framework 2.11.1", + "security-framework 3.5.1", + "windows-sys 0.60.2", + "zeroize", +] + [[package]] name = "lalrpop" version = "0.22.2" @@ -1924,9 +2206,9 @@ dependencies = [ [[package]] name = "lambdaworks-crypto" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce8f59622ed408c318c9b5eca17f1a1154159e3738b5c4d5a22a0dd3700c906" +checksum = "58b1a1c1102a5a7fbbda117b79fb3a01e033459c738a3c1642269603484fd1c1" dependencies = [ "lambdaworks-math", "rand 0.8.5", @@ -1938,11 +2220,13 @@ dependencies = [ [[package]] name = "lambdaworks-math" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "405d65a26831650ba348a503a2881ed7a0483ef3ec17f66e0fc8e2f9c97fc7ca" +checksum = "018a95aa873eb49896a858dee0d925c33f3978d073c64b08dd4f2c9b35a017c6" dependencies = [ "getrandom 0.2.16", + "num-bigint", + "num-traits", "rand 0.8.5", "serde", "serde_json", @@ -1956,9 +2240,28 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.175" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "libdbus-sys" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cbe856efeb50e4681f010e9aaa2bf0a644e10139e54cde10fc83a307c23bd9f" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "libredox" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +dependencies = [ + "bitflags 2.10.0", + "libc", +] [[package]] name = "linux-raw-sys" @@ -1974,11 +2277,10 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -2009,6 +2311,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "matrixmultiply" version = "0.3.10" @@ -2021,9 +2329,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "microlp" @@ -2051,6 +2359,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -2058,17 +2372,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", - "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "wasi", + "windows-sys 0.61.2", ] [[package]] @@ -2098,13 +2413,23 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2151,15 +2476,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -2178,12 +2494,29 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" +[[package]] +name = "open" +version = "5.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl-probe" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "parity-scale-codec" version = "3.7.5" @@ -2209,14 +2542,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -2224,17 +2557,23 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-link", ] +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -2257,7 +2596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset 0.4.2", - "indexmap 2.11.3", + "indexmap 2.12.0", ] [[package]] @@ -2267,7 +2606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset 0.5.7", - "indexmap 2.11.3", + "indexmap 2.12.0", ] [[package]] @@ -2276,7 +2615,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher", + "siphasher 1.0.1", ] [[package]] @@ -2302,7 +2641,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -2317,6 +2656,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + [[package]] name = "portable-atomic" version = "1.11.1" @@ -2369,7 +2720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -2391,7 +2742,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.5", + "toml_edit 0.23.7", ] [[package]] @@ -2464,7 +2815,7 @@ dependencies = [ "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.106", + "syn 2.0.107", "tempfile", ] @@ -2484,7 +2835,7 @@ dependencies = [ "prost 0.13.5", "prost-types 0.13.5", "regex", - "syn 2.0.106", + "syn 2.0.107", "tempfile", ] @@ -2498,7 +2849,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -2511,7 +2862,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -2544,9 +2895,9 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.1.1", - "rustls 0.23.31", - "socket2 0.6.0", - "thiserror 2.0.16", + "rustls 0.23.33", + "socket2 0.6.1", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -2559,15 +2910,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ "bytes", - "getrandom 0.3.3", + "getrandom 0.3.4", "lru-slab", "rand 0.9.2", "ring", "rustc-hash 2.1.1", - "rustls 0.23.31", + "rustls 0.23.33", "rustls-pki-types", "slab", - "thiserror 2.0.16", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -2582,16 +2933,16 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.0", + "socket2 0.6.1", "tracing", "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -2664,7 +3015,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] @@ -2675,38 +3026,49 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.10.0", +] + +[[package]] +name = "redox_users" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ - "bitflags 2.9.4", + "getrandom 0.2.16", + "libredox", + "thiserror 2.0.17", ] [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "regex" -version = "1.11.2" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -2716,9 +3078,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -2727,15 +3089,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "reqwest" -version = "0.12.23" +version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ "base64 0.22.1", "bytes", @@ -2751,14 +3113,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.31", + "rustls 0.23.33", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.2", "tokio", - "tokio-rustls 0.26.3", + "tokio-rustls 0.26.4", "tower 0.5.2", "tower-http 0.6.6", "tower-service", @@ -2766,7 +3128,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 1.0.2", + "webpki-roots 1.0.3", ] [[package]] @@ -2809,7 +3171,7 @@ version = "0.17.0-pre.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719825638c59fd26a55412a24561c7c5bcf54364c88b9a7a04ba08a6eafaba8d" dependencies = [ - "indexmap 2.11.3", + "indexmap 2.12.0", "lock_api", "oorandom", "parking_lot", @@ -2829,15 +3191,9 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] -[[package]] -name = "rustc-demangle" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -2862,11 +3218,11 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.0", + "windows-sys 0.61.2", ] [[package]] @@ -2885,14 +3241,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.31" +version = "0.23.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.6", + "rustls-webpki 0.103.7", "subtle", "zeroize", ] @@ -2907,7 +3263,7 @@ dependencies = [ "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] @@ -2942,9 +3298,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.6" +version = "0.103.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" dependencies = [ "ring", "rustls-pki-types", @@ -2987,7 +3343,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.61.2", ] [[package]] @@ -3036,7 +3392,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3045,6 +3401,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scroll" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] + [[package]] name = "scrypt" version = "0.10.0" @@ -3063,8 +3439,21 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.4", - "core-foundation", + "bitflags 2.10.0", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" +dependencies = [ + "bitflags 2.10.0", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -3080,11 +3469,21 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +dependencies = [ + "serde", + "serde_core", +] + [[package]] name = "serde" -version = "1.0.225" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", @@ -3103,22 +3502,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.225" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.225" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3129,7 +3528,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3156,6 +3555,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + [[package]] name = "serde_spanned" version = "0.6.9" @@ -3165,6 +3575,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3179,19 +3598,18 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" +checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.11.3", + "indexmap 2.12.0", "schemars 0.9.0", "schemars 1.0.4", - "serde", - "serde_derive", + "serde_core", "serde_json", "serde_with_macros", "time", @@ -3199,14 +3617,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" +checksum = "a7e6c180db0816026a61afa1cff5344fb7ebded7e4d3062772179f2501481c27" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3264,17 +3682,23 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "siphasher" -version = "1.0.1" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] -name = "size-of" -version = "0.1.5" +name = "siphasher" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e36eca171fddeda53901b0a436573b3f2391eaa9189d439b2bd8ea8cebd7e3" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" @@ -3288,6 +3712,12 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "smol_str" version = "0.3.2" @@ -3310,12 +3740,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -3332,9 +3762,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "starknet" @@ -3393,7 +3823,7 @@ dependencies = [ "flate2", "foldhash", "hex", - "indexmap 2.11.3", + "indexmap 2.12.0", "num-traits", "serde", "serde_json", @@ -3413,7 +3843,7 @@ checksum = "b08520b7d80eda7bf1a223e8db4f9bb5779a12846f15ebf8f8d76667eca7f5ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3449,7 +3879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d59e1eb22f4366385b132ba7016faa5a6457f1f23f896f737a06da626455e7b" dependencies = [ "starknet-core", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3492,9 +3922,9 @@ dependencies = [ [[package]] name = "starknet-types-core" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c043ab183b1cb1daab10d592719d27f283e7ef7e7ac8accd243b4e70b4e1c0d8" +checksum = "90d23b1bc014ee4cce40056ab3114bcbcdc2dbc1e845bbfb1f8bd0bab63507d4" dependencies = [ "blake2", "digest", @@ -3506,7 +3936,6 @@ dependencies = [ "num-traits", "rand 0.9.2", "serde", - "size-of", "zeroize", ] @@ -3561,7 +3990,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3583,9 +4012,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" dependencies = [ "proc-macro2", "quote", @@ -3615,7 +4044,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3626,15 +4055,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.22.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.61.0", + "windows-sys 0.61.2", ] [[package]] @@ -3643,7 +4072,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2111ef44dae28680ae9752bb89409e7310ca33a8c621ebe7b106cf5c928b3ac0" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.61.2", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "smawk", ] [[package]] @@ -3657,11 +4095,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.17", ] [[package]] @@ -3672,18 +4110,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3697,11 +4135,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.43" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", + "itoa", "num-conv", "powerfmt", "serde", @@ -3761,22 +4200,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.47.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", - "io-uring", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", - "slab", - "socket2 0.6.0", + "socket2 0.6.1", "tokio-macros", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3791,13 +4227,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3813,11 +4249,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ - "rustls 0.23.31", + "rustls 0.23.33", "tokio", ] @@ -3852,11 +4288,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_edit 0.22.27", ] +[[package]] +name = "toml" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" +dependencies = [ + "indexmap 2.12.0", + "serde_core", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow", +] + [[package]] name = "toml_datetime" version = "0.6.11" @@ -3868,9 +4319,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a197c0ec7d131bfc6f7e82c8442ba1595aeab35da7adbf05b6b73cd06a16b6be" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] @@ -3881,9 +4332,9 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.3", + "indexmap 2.12.0", "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_write", "winnow", @@ -3891,21 +4342,21 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.5" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ad0b7ae9cfeef5605163839cb9221f453399f15cfb5c10be9885fcf56611f9" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.11.3", - "toml_datetime 0.7.1", + "indexmap 2.12.0", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] [[package]] name = "toml_parser" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow", ] @@ -3916,6 +4367,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + [[package]] name = "tonic" version = "0.11.0" @@ -3924,7 +4381,7 @@ checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.6.20", "base64 0.21.7", "bytes", "flate2", @@ -3981,7 +4438,7 @@ dependencies = [ "proc-macro2", "prost-build 0.12.6", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3995,7 +4452,7 @@ dependencies = [ "prost-build 0.13.5", "prost-types 0.13.5", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4162,6 +4619,7 @@ dependencies = [ "tokio", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -4170,7 +4628,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "bytes", "futures-core", "futures-util", @@ -4188,7 +4646,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "bytes", "futures-util", "http 1.3.1", @@ -4232,7 +4690,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4289,9 +4747,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" +checksum = "dd69c5aa8f924c7519d6372789a74eac5b94fb0f8fcf0d4a97eb0bfc3e785f39" dependencies = [ "serde", "stable_deref_trait", @@ -4326,14 +4784,14 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "uint" @@ -4365,6 +4823,153 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "uniffi" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c866f627c3f04c3df068b68bb2d725492caaa539dd313e2a9d26bb85b1a32f4e" +dependencies = [ + "anyhow", + "camino", + "cargo_metadata", + "clap", + "uniffi_bindgen", + "uniffi_build", + "uniffi_core", + "uniffi_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_bindgen" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c8ca600167641ebe7c8ba9254af40492dda3397c528cc3b2f511bd23e8541a5" +dependencies = [ + "anyhow", + "askama", + "camino", + "cargo_metadata", + "fs-err", + "glob", + "goblin", + "heck 0.5.0", + "indexmap 2.12.0", + "once_cell", + "serde", + "tempfile", + "textwrap", + "toml 0.9.8", + "uniffi_internal_macros", + "uniffi_meta", + "uniffi_pipeline", + "uniffi_testing", + "uniffi_udl", +] + +[[package]] +name = "uniffi_build" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e55c05228f4858bb258f651d21d743fcc1fe5a2ec20d3c0f9daefddb105ee4d" +dependencies = [ + "anyhow", + "camino", + "uniffi_bindgen", +] + +[[package]] +name = "uniffi_core" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7a5a038ebffe8f4cf91416b154ef3c2468b18e828b7009e01b1b99938089f9" +dependencies = [ + "anyhow", + "bytes", + "once_cell", + "static_assertions", +] + +[[package]] +name = "uniffi_internal_macros" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c2a6f93e7b73726e2015696ece25ca0ac5a5f1cf8d6a7ab5214dd0a01d2edf" +dependencies = [ + "anyhow", + "indexmap 2.12.0", + "proc-macro2", + "quote", + "syn 2.0.107", +] + +[[package]] +name = "uniffi_macros" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c6309fc36c7992afc03bc0c5b059c656bccbef3f2a4bc362980017f8936141" +dependencies = [ + "camino", + "fs-err", + "once_cell", + "proc-macro2", + "quote", + "serde", + "syn 2.0.107", + "toml 0.9.8", + "uniffi_meta", +] + +[[package]] +name = "uniffi_meta" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a138823392dba19b0aa494872689f97d0ee157de5852e2bec157ce6de9cdc22" +dependencies = [ + "anyhow", + "siphasher 0.3.11", + "uniffi_internal_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_pipeline" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c27c4b515d25f8e53cc918e238c39a79c3144a40eaf2e51c4a7958973422c29" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap 2.12.0", + "tempfile", + "uniffi_internal_macros", +] + +[[package]] +name = "uniffi_testing" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4adb08eb5589849231dc0626ba0f9a1297925fd751f0740fc630ae934dd9c5e" +dependencies = [ + "anyhow", + "camino", + "cargo_metadata", + "fs-err", + "once_cell", +] + +[[package]] +name = "uniffi_udl" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0adacdd848aeed7af4f5af7d2f621d5e82531325d405e29463482becfdeafca" +dependencies = [ + "anyhow", + "textwrap", + "uniffi_meta", + "weedle2", +] + [[package]] name = "untrusted" version = "0.9.0" @@ -4394,6 +4999,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -4453,15 +5064,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" -dependencies = [ - "wasip2", -] - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -4471,47 +5073,11 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "wasm" -version = "1.8.3" -dependencies = [ - "anyhow", - "cainome", - "chrono", - "console_error_panic_hook", - "crypto-bigint", - "dojo-core", - "dojo-types", - "dojo-world", - "futures", - "gloo-timers", - "gloo-utils", - "instant", - "js-sys", - "num-bigint", - "num-traits", - "serde", - "serde-wasm-bindgen", - "serde_json", - "starknet", - "starknet-crypto", - "stream-cancel", - "tokio", - "torii-client", - "torii-proto", - "tsify-next", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test", - "web-sys", -] - [[package]] name = "wasm-bindgen" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819" +checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" dependencies = [ "cfg-if", "once_cell", @@ -4522,23 +5088,23 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c" +checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.53" +version = "0.4.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67" +checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" dependencies = [ "cfg-if", "js-sys", @@ -4549,9 +5115,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0" +checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4559,31 +5125,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32" +checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf" +checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.53" +version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aee0a0f5343de9221a0d233b04520ed8dc2e6728dce180b1dcd9288ec9d9fa3c" +checksum = "4e381134e148c1062f965a42ed1f5ee933eef2927c3f70d1812158f711d39865" dependencies = [ "js-sys", "minicov", @@ -4594,13 +5160,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.53" +version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a369369e4360c2884c3168d22bded735c43cccae97bbc147586d4b480edd138d" +checksum = "b673bca3298fe582aeef8352330ecbad91849f85090805582400850f8270a2e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4618,9 +5184,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.80" +version = "0.3.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc" +checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120" dependencies = [ "js-sys", "wasm-bindgen", @@ -4642,90 +5208,93 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ - "webpki-roots 1.0.2", + "webpki-roots 1.0.3", ] [[package]] name = "webpki-roots" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +checksum = "32b130c0d2d49f8b6889abc456e795e82525204f27c42cf767cf0d7734e089b8" dependencies = [ "rustls-pki-types", ] +[[package]] +name = "weedle2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e" +dependencies = [ + "nom", +] + [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.61.2", ] [[package]] name = "windows-core" -version = "0.62.0" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", - "windows-link 0.2.0", + "windows-link", "windows-result", "windows-strings", ] [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - -[[package]] -name = "windows-link" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-result" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.2.0", + "windows-link", ] [[package]] name = "windows-strings" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -4752,16 +5321,16 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.3", + "windows-targets 0.53.5", ] [[package]] name = "windows-sys" -version = "0.61.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -4782,19 +5351,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.3" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.1.3", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -4805,9 +5374,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -4817,9 +5386,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -4829,9 +5398,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -4841,9 +5410,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -4853,9 +5422,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -4865,9 +5434,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -4877,9 +5446,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -4889,9 +5458,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" @@ -4943,7 +5512,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "synstructure", ] @@ -4964,7 +5533,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4984,15 +5553,29 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] [[package]] name = "zerotrie" @@ -5024,5 +5607,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] diff --git a/Cargo.toml b/Cargo.toml index c558277..c4d5ce3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "crates/dojo-core", "crates/c", "crates/wasm", + "crates/uniffi", ] [workspace.package] @@ -25,7 +26,7 @@ starknet-types-core = { version = "0.2.0", features = ["arbitrary"] } # Core dependencies parking_lot = "0.12.1" -tokio = { version = "1.39.2", default-features = false, features = ["rt"] } +tokio = { version = "1.39.2", default-features = false, features = ["rt", "rt-multi-thread", "macros"] } url = "2.5.0" anyhow = "1.0.89" serde = { version = "1.0.193", features = ["derive"] } @@ -33,6 +34,7 @@ serde_json = "1.0.115" tokio-stream = "0.1.14" futures = "0.3.30" futures-channel = "0.3.30" +futures-util = "0.3" stream-cancel = "0.8.2" cainome = "0.10.1" lazy_static = "1.5.0" @@ -63,6 +65,7 @@ num-traits = "0.2.19" dojo-core = { path = "crates/dojo-core" } c = { path = "crates/c" } wasm = { path = "crates/wasm" } +dojo-uniffi = { path = "crates/uniffi" } [patch.crates-io] crunchy = { git = "https://github.com/nmathewson/crunchy", branch = "cross-compilation-fix" } diff --git a/README.md b/README.md index b99ca31..7daf6e8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,36 @@ # dojo.c -This package provides C and low-level Wasm32 bindings for the Torii Client SDK, as well as for the starknet-rs library. +Multi-language bindings for the Dojo Torii Client SDK, providing seamless integration across multiple platforms and languages. -The approach is to generate a C client using `cbindgen` and a wasm module using `wasm-bindgen` that are interropeable in applications exporting to both native platforms and web browsers. +## Features + +This package provides multiple binding strategies for maximum compatibility: + +- **C/C++ Bindings** - Generated with `cbindgen` for native applications +- **WebAssembly** - Browser and Node.js support via `wasm-bindgen` +- **UniFFI Bindings** - Modern Swift, Kotlin, and Python bindings via Mozilla's UniFFI + +## Project Structure + +``` +dojo.c/ +├── src/ +│ ├── c/ # C FFI implementation +│ ├── wasm/ # WebAssembly implementation +│ ├── uniffi/ # UniFFI implementation +│ │ ├── types/ # Domain types (organized by category) +│ │ ├── client.rs # ToriiClient with queries & subscriptions +│ │ └── README.md # UniFFI-specific documentation +│ ├── dojo.udl # UniFFI interface definition +│ └── lib.rs # Main library entry point +├── src/bin/ # Binding generator binaries +├── scripts/ # Build and generation scripts +├── bindings/ # Generated bindings output +│ ├── swift/ +│ ├── kotlin/ +│ └── python/ +└── example/ # C usage examples +``` ## Building @@ -27,13 +55,79 @@ cargo build --release --target wasm32-unknown-unknown cd pkg && bunx wasm-pack build --release ``` -## Running +## Generating Bindings + +### C/C++ Headers + +Headers are automatically generated during `cargo build`: +- `dojo.h` - C header +- `dojo.hpp` - C++ header +- `dojo.pyx` - Cython definitions + +### UniFFI Bindings (Swift, Kotlin, Python) ```bash -# Building dojo.c +# Build the library first cargo build --release -# Linking dojo.c and building example + +# Generate Swift bindings (iOS/macOS) +cargo run --bin uniffi-bindgen-swift --release -- \ + target/release/libdojo_c.dylib bindings/swift --swift-sources + +# Generate Kotlin bindings (Android) +cargo run --bin uniffi-bindgen-kotlin --release -- \ + target/release/libdojo_c.dylib bindings/kotlin + +# Generate Python bindings +cargo run --bin uniffi-bindgen-python --release -- \ + target/release/libdojo_c.dylib bindings/python +``` + +See [`src/uniffi/README.md`](src/uniffi/README.md) for detailed UniFFI documentation. + +## Language Support Status + +| Language | Status | Notes | +|----------|--------|-------| +| **Swift** | ✅ Fully Functional | All features working, synchronous client | +| **Python** | ✅ Fully Functional | All features working, synchronous client | +| **C/C++** | ✅ Functional | Basic functionality via cbindgen | +| **WebAssembly** | ✅ Functional | Browser and Node.js support | +| **Kotlin** | 🚧 Not Working | UniFFI v0.30 limitations with complex types | + +See `examples/` directory for language-specific examples and documentation. + +## Running Examples + +### C Example + +```bash +# Build dojo.c +cargo build --release +# Compile and link C example clang example/main.c target/release/libdojo_c.dylib -# Running example +# Run example ./a.out ``` + +### Python Example + +```python +from dojo import ToriiClient + +# Create client +client = await ToriiClient("http://localhost:8080") + +# Subscribe to entity updates +def on_entity_update(entity): + print(f"Entity updated: {entity}") + +def on_error(error): + print(f"Error: {error}") + +sub_id = await client.subscribe_entity_updates( + None, # clause + [], # world_addresses + EntityUpdateCallback(on_entity_update, on_error) +) +``` diff --git a/bindings/kotlin/com/dojoengine/dojo/dojo.kt b/bindings/kotlin/com/dojoengine/dojo/dojo.kt new file mode 100644 index 0000000..360551d --- /dev/null +++ b/bindings/kotlin/com/dojoengine/dojo/dojo.kt @@ -0,0 +1,8423 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +@file:Suppress("NAME_SHADOWING") + +package com.dojoengine.dojo + +// Common helper code. +// +// Ideally this would live in a separate .kt file where it can be unittested etc +// in isolation, and perhaps even published as a re-useable package. +// +// However, it's important that the details of how this helper code works (e.g. the +// way that different builtin types are passed across the FFI) exactly match what's +// expected by the Rust code on the other side of the interface. In practice right +// now that means coming from the exact some version of `uniffi` that was used to +// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin +// helpers directly inline like we're doing here. + +import com.sun.jna.Library +import com.sun.jna.IntegerType +import com.sun.jna.Native +import com.sun.jna.Pointer +import com.sun.jna.Structure +import com.sun.jna.Callback +import com.sun.jna.ptr.* +import java.nio.ByteBuffer +import java.nio.ByteOrder +import java.nio.CharBuffer +import java.nio.charset.CodingErrorAction +import java.util.concurrent.atomic.AtomicLong +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicBoolean + +// This is a helper for safely working with byte buffers returned from the Rust code. +// A rust-owned buffer is represented by its capacity, its current length, and a +// pointer to the underlying data. + +/** + * @suppress + */ +@Structure.FieldOrder("capacity", "len", "data") +open class RustBuffer : Structure() { + // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values. + // When dealing with these fields, make sure to call `toULong()`. + @JvmField var capacity: Long = 0 + @JvmField var len: Long = 0 + @JvmField var data: Pointer? = null + + class ByValue: RustBuffer(), Structure.ByValue + class ByReference: RustBuffer(), Structure.ByReference + + internal fun setValue(other: RustBuffer) { + capacity = other.capacity + len = other.len + data = other.data + } + + companion object { + internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status -> + // Note: need to convert the size to a `Long` value to make this work with JVM. + UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc(size.toLong(), status) + }.also { + if(it.data == null) { + throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") + } + } + + internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue { + var buf = RustBuffer.ByValue() + buf.capacity = capacity.toLong() + buf.len = len.toLong() + buf.data = data + return buf + } + + internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status -> + UniffiLib.ffi_dojo_uniffi_rustbuffer_free(buf, status) + } + } + + @Suppress("TooGenericExceptionThrown") + fun asByteBuffer() = + this.data?.getByteBuffer(0, this.len.toLong())?.also { + it.order(ByteOrder.BIG_ENDIAN) + } +} + +// This is a helper for safely passing byte references into the rust code. +// It's not actually used at the moment, because there aren't many things that you +// can take a direct pointer to in the JVM, and if we're going to copy something +// then we might as well copy it into a `RustBuffer`. But it's here for API +// completeness. + +@Structure.FieldOrder("len", "data") +internal open class ForeignBytes : Structure() { + @JvmField var len: Int = 0 + @JvmField var data: Pointer? = null + + class ByValue : ForeignBytes(), Structure.ByValue +} +/** + * The FfiConverter interface handles converter types to and from the FFI + * + * All implementing objects should be public to support external types. When a + * type is external we need to import it's FfiConverter. + * + * @suppress + */ +public interface FfiConverter { + // Convert an FFI type to a Kotlin type + fun lift(value: FfiType): KotlinType + + // Convert an Kotlin type to an FFI type + fun lower(value: KotlinType): FfiType + + // Read a Kotlin type from a `ByteBuffer` + fun read(buf: ByteBuffer): KotlinType + + // Calculate bytes to allocate when creating a `RustBuffer` + // + // This must return at least as many bytes as the write() function will + // write. It can return more bytes than needed, for example when writing + // Strings we can't know the exact bytes needed until we the UTF-8 + // encoding, so we pessimistically allocate the largest size possible (3 + // bytes per codepoint). Allocating extra bytes is not really a big deal + // because the `RustBuffer` is short-lived. + fun allocationSize(value: KotlinType): ULong + + // Write a Kotlin type to a `ByteBuffer` + fun write(value: KotlinType, buf: ByteBuffer) + + // Lower a value into a `RustBuffer` + // + // This method lowers a value into a `RustBuffer` rather than the normal + // FfiType. It's used by the callback interface code. Callback interface + // returns are always serialized into a `RustBuffer` regardless of their + // normal FFI type. + fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue { + val rbuf = RustBuffer.alloc(allocationSize(value)) + try { + val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also { + it.order(ByteOrder.BIG_ENDIAN) + } + write(value, bbuf) + rbuf.writeField("len", bbuf.position().toLong()) + return rbuf + } catch (e: Throwable) { + RustBuffer.free(rbuf) + throw e + } + } + + // Lift a value from a `RustBuffer`. + // + // This here mostly because of the symmetry with `lowerIntoRustBuffer()`. + // It's currently only used by the `FfiConverterRustBuffer` class below. + fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType { + val byteBuf = rbuf.asByteBuffer()!! + try { + val item = read(byteBuf) + if (byteBuf.hasRemaining()) { + throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!") + } + return item + } finally { + RustBuffer.free(rbuf) + } + } +} + +/** + * FfiConverter that uses `RustBuffer` as the FfiType + * + * @suppress + */ +public interface FfiConverterRustBuffer: FfiConverter { + override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value) + override fun lower(value: KotlinType) = lowerIntoRustBuffer(value) +} +// A handful of classes and functions to support the generated data structures. +// This would be a good candidate for isolating in its own ffi-support lib. + +internal const val UNIFFI_CALL_SUCCESS = 0.toByte() +internal const val UNIFFI_CALL_ERROR = 1.toByte() +internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte() + +@Structure.FieldOrder("code", "error_buf") +internal open class UniffiRustCallStatus : Structure() { + @JvmField var code: Byte = 0 + @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue() + + class ByValue: UniffiRustCallStatus(), Structure.ByValue + + fun isSuccess(): Boolean { + return code == UNIFFI_CALL_SUCCESS + } + + fun isError(): Boolean { + return code == UNIFFI_CALL_ERROR + } + + fun isPanic(): Boolean { + return code == UNIFFI_CALL_UNEXPECTED_ERROR + } + + companion object { + fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue { + val callStatus = UniffiRustCallStatus.ByValue() + callStatus.code = code + callStatus.error_buf = errorBuf + return callStatus + } + } +} + +class InternalException(message: String) : kotlin.Exception(message) + +/** + * Each top-level error class has a companion object that can lift the error from the call status's rust buffer + * + * @suppress + */ +interface UniffiRustCallStatusErrorHandler { + fun lift(error_buf: RustBuffer.ByValue): E; +} + +// Helpers for calling Rust +// In practice we usually need to be synchronized to call this safely, so it doesn't +// synchronize itself + +// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err +private inline fun uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler, callback: (UniffiRustCallStatus) -> U): U { + var status = UniffiRustCallStatus() + val return_value = callback(status) + uniffiCheckCallStatus(errorHandler, status) + return return_value +} + +// Check UniffiRustCallStatus and throw an error if the call wasn't successful +private fun uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler, status: UniffiRustCallStatus) { + if (status.isSuccess()) { + return + } else if (status.isError()) { + throw errorHandler.lift(status.error_buf) + } else if (status.isPanic()) { + // when the rust code sees a panic, it tries to construct a rustbuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if (status.error_buf.len > 0) { + throw InternalException(FfiConverterString.lift(status.error_buf)) + } else { + throw InternalException("Rust panic") + } + } else { + throw InternalException("Unknown rust call status: $status.code") + } +} + +/** + * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR + * + * @suppress + */ +object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): InternalException { + RustBuffer.free(error_buf) + return InternalException("Unexpected CALL_ERROR") + } +} + +// Call a rust function that returns a plain value +private inline fun uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U { + return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback) +} + +internal inline fun uniffiTraitInterfaceCall( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } +} + +internal inline fun uniffiTraitInterfaceCallWithError( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, + lowerError: (E) -> RustBuffer.ByValue +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + if (e is E) { + callStatus.code = UNIFFI_CALL_ERROR + callStatus.error_buf = lowerError(e) + } else { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } + } +} +// Initial value and increment amount for handles. +// These ensure that Kotlin-generated handles always have the lowest bit set +private const val UNIFFI_HANDLEMAP_INITIAL = 1.toLong() +private const val UNIFFI_HANDLEMAP_DELTA = 2.toLong() + +// Map handles to objects +// +// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code. +internal class UniffiHandleMap { + private val map = ConcurrentHashMap() + // Start + private val counter = java.util.concurrent.atomic.AtomicLong(UNIFFI_HANDLEMAP_INITIAL) + + val size: Int + get() = map.size + + // Insert a new object into the handle map and get a handle for it + fun insert(obj: T): Long { + val handle = counter.getAndAdd(UNIFFI_HANDLEMAP_DELTA) + map.put(handle, obj) + return handle + } + + // Clone a handle, creating a new one + fun clone(handle: Long): Long { + val obj = map.get(handle) ?: throw InternalException("UniffiHandleMap.clone: Invalid handle") + return insert(obj) + } + + // Get an object from the handle map + fun get(handle: Long): T { + return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle") + } + + // Remove an entry from the handlemap and get the Kotlin object back + fun remove(handle: Long): T { + return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle") + } +} + +// Contains loading, initialization code, +// and the FFI Function declarations in a com.sun.jna.Library. +@Synchronized +private fun findLibraryName(componentName: String): String { + val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride") + if (libOverride != null) { + return libOverride + } + return "dojo_uniffi" +} + +// Define FFI callback types +internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback { + fun callback(`data`: Long,`pollResult`: Byte,) +} +internal interface UniffiForeignFutureDroppedCallback : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceClone : com.sun.jna.Callback { + fun callback(`handle`: Long,) + : Long +} +@Structure.FieldOrder("handle", "free") +internal open class UniffiForeignFutureDroppedCallbackStruct( + @JvmField internal var `handle`: Long = 0.toLong(), + @JvmField internal var `free`: UniffiForeignFutureDroppedCallback? = null, +) : Structure() { + class UniffiByValue( + `handle`: Long = 0.toLong(), + `free`: UniffiForeignFutureDroppedCallback? = null, + ): UniffiForeignFutureDroppedCallbackStruct(`handle`,`free`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureDroppedCallbackStruct) { + `handle` = other.`handle` + `free` = other.`free` + } + +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF32( + @JvmField internal var `returnValue`: Float = 0.0f, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Float = 0.0f, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF64( + @JvmField internal var `returnValue`: Double = 0.0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Double = 0.0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultRustBuffer( + @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultRustBuffer) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultRustBuffer.UniffiByValue,) +} +@Structure.FieldOrder("callStatus") +internal open class UniffiForeignFutureResultVoid( + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultVoid(`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultVoid) { + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultVoid.UniffiByValue,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEntityUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEntityUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEntityUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEventUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEventUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEventUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTransactionUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTransactionUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTransactionUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} + +// A JNA Library to expose the extern-C FFI definitions. +// This is an implementation detail which will be called internally by the public API. + +// For large crates we prevent `MethodTooLargeException` (see #2340) +// N.B. the name of the extension is very misleading, since it is +// rather `InterfaceTooLargeException`, caused by too many methods +// in the interface for large crates. +// +// By splitting the otherwise huge interface into two parts +// * UniffiLib (this) +// * IntegrityCheckingUniffiLib +// And all checksum methods are put into `IntegrityCheckingUniffiLib` +// we allow for ~2x as many methods in the UniffiLib interface. +// +// Note: above all written when we used JNA's `loadIndirect` etc. +// We now use JNA's "direct mapping" - unclear if same considerations apply exactly. +internal object IntegrityCheckingUniffiLib { + init { + Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCheckContractApiVersion(this) + uniffiCheckApiChecksums(this) + } + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_activities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_controllers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_entities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_sql( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_tokens( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_transactions( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_worlds( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error( + ): Short + external fun ffi_dojo_uniffi_uniffi_contract_version( + ): Int + + +} + +internal object UniffiLib { + + // The Cleaner for the whole library + internal val CLEANER: UniffiCleaner by lazy { + UniffiCleaner.create() + } + + + init { + Native.register(UniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCallbackInterfaceEntityUpdateCallback.register(this) + uniffiCallbackInterfaceEventUpdateCallback.register(this) + uniffiCallbackInterfaceTokenBalanceUpdateCallback.register(this) + uniffiCallbackInterfaceTokenUpdateCallback.register(this) + uniffiCallbackInterfaceTransactionUpdateCallback.register(this) + + } + external fun uniffi_dojo_uniffi_fn_clone_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_free_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new(`toriiUrl`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config(`toriiUrl`: RustBuffer.ByValue,`maxMessageSize`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_activities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_aggregations(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription(`ptr`: Long,`subscriptionId`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_method_toriiclient_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_controllers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_entities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_event_messages(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message(`ptr`: Long,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch(`ptr`: Long,`messages`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_sql(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates(`ptr`: Long,`clause`: RustBuffer.ByValue,`worldAddresses`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates(`ptr`: Long,`keys`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`accountAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates(`ptr`: Long,`filter`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_balances(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_tokens(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_transactions(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_worlds(`ptr`: Long,`worldAddresses`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEntityUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEventUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTransactionUpdateCallback, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Float +external fun ffi_dojo_uniffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Double +external fun ffi_dojo_uniffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit + + +} + +private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) { + // Get the bindings contract version from our ComponentInterface + val bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + val scaffolding_contract_version = lib.ffi_dojo_uniffi_uniffi_contract_version() + if (bindings_contract_version != scaffolding_contract_version) { + throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project") + } +} +@Suppress("UNUSED_PARAMETER") +private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements() != 45327.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities() != 43349.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations() != 12858.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription() != 31182.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts() != 1861.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers() != 55573.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities() != 50647.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages() != 35425.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements() != 61773.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message() != 30179.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch() != 2146.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql() != 38286.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events() != 44694.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates() != 17350.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates() != 63983.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates() != 26741.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates() != 54836.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates() != 10040.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances() != 1716.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts() != 49563.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers() != 10363.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens() != 10630.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions() != 46460.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds() != 23254.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new() != 18057.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config() != 42232.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update() != 15850.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error() != 340.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update() != 13627.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error() != 61050.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update() != 10763.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error() != 46610.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update() != 40037.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error() != 14408.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update() != 11896.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error() != 18113.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +/** + * @suppress + */ +public fun uniffiEnsureInitialized() { + IntegrityCheckingUniffiLib + // UniffiLib() initialized as objects are used, but we still need to explicitly + // reference it so initialization across crates works as expected. + UniffiLib +} + +// Async support + +// Public interface members begin here. + + +// Interface implemented by anything that can contain an object reference. +// +// Such types expose a `destroy()` method that must be called to cleanly +// dispose of the contained objects. Failure to call this method may result +// in memory leaks. +// +// The easiest way to ensure this method is called is to use the `.use` +// helper method to execute a block and destroy the object at the end. +interface Disposable { + fun destroy() + companion object { + fun destroy(vararg args: Any?) { + for (arg in args) { + when (arg) { + is Disposable -> arg.destroy() + is ArrayList<*> -> { + for (idx in arg.indices) { + val element = arg[idx] + if (element is Disposable) { + element.destroy() + } + } + } + is Map<*, *> -> { + for (element in arg.values) { + if (element is Disposable) { + element.destroy() + } + } + } + is Iterable<*> -> { + for (element in arg) { + if (element is Disposable) { + element.destroy() + } + } + } + } + } + } + } +} + +/** + * @suppress + */ +inline fun T.use(block: (T) -> R) = + try { + block(this) + } finally { + try { + // N.B. our implementation is on the nullable type `Disposable?`. + this?.destroy() + } catch (e: Throwable) { + // swallow + } + } + +/** + * Placeholder object used to signal that we're constructing an interface with a FFI handle. + * + * This is the first argument for interface constructors that input a raw handle. It exists is that + * so we can avoid signature conflicts when an interface has a regular constructor than inputs a + * Long. + * + * @suppress + * */ +object UniffiWithHandle + +/** + * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly. + * + * @suppress + * */ +object NoHandle// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +internal const val IDX_CALLBACK_FREE = 0 +// Callback return codes +internal const val UNIFFI_CALLBACK_SUCCESS = 0 +internal const val UNIFFI_CALLBACK_ERROR = 1 +internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 + +/** + * @suppress + */ +public abstract class FfiConverterCallbackInterface: FfiConverter { + internal val handleMap = UniffiHandleMap() + + internal fun drop(handle: Long) { + handleMap.remove(handle) + } + + override fun lift(value: Long): CallbackInterface { + return handleMap.get(value) + } + + override fun read(buf: ByteBuffer) = lift(buf.getLong()) + + override fun lower(value: CallbackInterface) = handleMap.insert(value) + + override fun allocationSize(value: CallbackInterface) = 8UL + + override fun write(value: CallbackInterface, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} +/** + * The cleaner interface for Object finalization code to run. + * This is the entry point to any implementation that we're using. + * + * The cleaner registers objects and returns cleanables, so now we are + * defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the + * different implmentations available at compile time. + * + * @suppress + */ +interface UniffiCleaner { + interface Cleanable { + fun clean() + } + + fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable + + companion object +} + +// The fallback Jna cleaner, which is available for both Android, and the JVM. +private class UniffiJnaCleaner : UniffiCleaner { + private val cleaner = com.sun.jna.internal.Cleaner.getCleaner() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + UniffiJnaCleanable(cleaner.register(value, cleanUpTask)) +} + +private class UniffiJnaCleanable( + private val cleanable: com.sun.jna.internal.Cleaner.Cleanable, +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + + +// We decide at uniffi binding generation time whether we were +// using Android or not. +// There are further runtime checks to chose the correct implementation +// of the cleaner. +private fun UniffiCleaner.Companion.create(): UniffiCleaner = + try { + // For safety's sake: if the library hasn't been run in android_cleaner = true + // mode, but is being run on Android, then we still need to think about + // Android API versions. + // So we check if java.lang.ref.Cleaner is there, and use that… + java.lang.Class.forName("java.lang.ref.Cleaner") + JavaLangRefCleaner() + } catch (e: ClassNotFoundException) { + // … otherwise, fallback to the JNA cleaner. + UniffiJnaCleaner() + } + +private class JavaLangRefCleaner : UniffiCleaner { + val cleaner = java.lang.ref.Cleaner.create() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + JavaLangRefCleanable(cleaner.register(value, cleanUpTask)) +} + +private class JavaLangRefCleanable( + val cleanable: java.lang.ref.Cleaner.Cleanable +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + +/** + * @suppress + */ +public object FfiConverterUByte: FfiConverter { + override fun lift(value: Byte): UByte { + return value.toUByte() + } + + override fun read(buf: ByteBuffer): UByte { + return lift(buf.get()) + } + + override fun lower(value: UByte): Byte { + return value.toByte() + } + + override fun allocationSize(value: UByte) = 1UL + + override fun write(value: UByte, buf: ByteBuffer) { + buf.put(value.toByte()) + } +} + +/** + * @suppress + */ +public object FfiConverterByte: FfiConverter { + override fun lift(value: Byte): Byte { + return value + } + + override fun read(buf: ByteBuffer): Byte { + return buf.get() + } + + override fun lower(value: Byte): Byte { + return value + } + + override fun allocationSize(value: Byte) = 1UL + + override fun write(value: Byte, buf: ByteBuffer) { + buf.put(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUShort: FfiConverter { + override fun lift(value: Short): UShort { + return value.toUShort() + } + + override fun read(buf: ByteBuffer): UShort { + return lift(buf.getShort()) + } + + override fun lower(value: UShort): Short { + return value.toShort() + } + + override fun allocationSize(value: UShort) = 2UL + + override fun write(value: UShort, buf: ByteBuffer) { + buf.putShort(value.toShort()) + } +} + +/** + * @suppress + */ +public object FfiConverterShort: FfiConverter { + override fun lift(value: Short): Short { + return value + } + + override fun read(buf: ByteBuffer): Short { + return buf.getShort() + } + + override fun lower(value: Short): Short { + return value + } + + override fun allocationSize(value: Short) = 2UL + + override fun write(value: Short, buf: ByteBuffer) { + buf.putShort(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUInt: FfiConverter { + override fun lift(value: Int): UInt { + return value.toUInt() + } + + override fun read(buf: ByteBuffer): UInt { + return lift(buf.getInt()) + } + + override fun lower(value: UInt): Int { + return value.toInt() + } + + override fun allocationSize(value: UInt) = 4UL + + override fun write(value: UInt, buf: ByteBuffer) { + buf.putInt(value.toInt()) + } +} + +/** + * @suppress + */ +public object FfiConverterInt: FfiConverter { + override fun lift(value: Int): Int { + return value + } + + override fun read(buf: ByteBuffer): Int { + return buf.getInt() + } + + override fun lower(value: Int): Int { + return value + } + + override fun allocationSize(value: Int) = 4UL + + override fun write(value: Int, buf: ByteBuffer) { + buf.putInt(value) + } +} + +/** + * @suppress + */ +public object FfiConverterULong: FfiConverter { + override fun lift(value: Long): ULong { + return value.toULong() + } + + override fun read(buf: ByteBuffer): ULong { + return lift(buf.getLong()) + } + + override fun lower(value: ULong): Long { + return value.toLong() + } + + override fun allocationSize(value: ULong) = 8UL + + override fun write(value: ULong, buf: ByteBuffer) { + buf.putLong(value.toLong()) + } +} + +/** + * @suppress + */ +public object FfiConverterLong: FfiConverter { + override fun lift(value: Long): Long { + return value + } + + override fun read(buf: ByteBuffer): Long { + return buf.getLong() + } + + override fun lower(value: Long): Long { + return value + } + + override fun allocationSize(value: Long) = 8UL + + override fun write(value: Long, buf: ByteBuffer) { + buf.putLong(value) + } +} + +/** + * @suppress + */ +public object FfiConverterDouble: FfiConverter { + override fun lift(value: Double): Double { + return value + } + + override fun read(buf: ByteBuffer): Double { + return buf.getDouble() + } + + override fun lower(value: Double): Double { + return value + } + + override fun allocationSize(value: Double) = 8UL + + override fun write(value: Double, buf: ByteBuffer) { + buf.putDouble(value) + } +} + +/** + * @suppress + */ +public object FfiConverterBoolean: FfiConverter { + override fun lift(value: Byte): Boolean { + return value.toInt() != 0 + } + + override fun read(buf: ByteBuffer): Boolean { + return lift(buf.get()) + } + + override fun lower(value: Boolean): Byte { + return if (value) 1.toByte() else 0.toByte() + } + + override fun allocationSize(value: Boolean) = 1UL + + override fun write(value: Boolean, buf: ByteBuffer) { + buf.put(lower(value)) + } +} + +/** + * @suppress + */ +public object FfiConverterString: FfiConverter { + // Note: we don't inherit from FfiConverterRustBuffer, because we use a + // special encoding when lowering/lifting. We can use `RustBuffer.len` to + // store our length and avoid writing it out to the buffer. + override fun lift(value: RustBuffer.ByValue): String { + try { + val byteArr = ByteArray(value.len.toInt()) + value.asByteBuffer()!!.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } finally { + RustBuffer.free(value) + } + } + + override fun read(buf: ByteBuffer): String { + val len = buf.getInt() + val byteArr = ByteArray(len) + buf.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } + + fun toUtf8(value: String): ByteBuffer { + // Make sure we don't have invalid UTF-16, check for lone surrogates. + return Charsets.UTF_8.newEncoder().run { + onMalformedInput(CodingErrorAction.REPORT) + encode(CharBuffer.wrap(value)) + } + } + + override fun lower(value: String): RustBuffer.ByValue { + val byteBuf = toUtf8(value) + // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us + // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`. + val rbuf = RustBuffer.alloc(byteBuf.limit().toULong()) + rbuf.asByteBuffer()!!.put(byteBuf) + return rbuf + } + + // We aren't sure exactly how many bytes our string will be once it's UTF-8 + // encoded. Allocate 3 bytes per UTF-16 code unit which will always be + // enough. + override fun allocationSize(value: String): ULong { + val sizeForLength = 4UL + val sizeForString = value.length.toULong() * 3UL + return sizeForLength + sizeForString + } + + override fun write(value: String, buf: ByteBuffer) { + val byteBuf = toUtf8(value) + buf.putInt(byteBuf.limit()) + buf.put(byteBuf) + } +} + + +// This template implements a class for working with a Rust struct via a handle +// to the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque handle to the underlying Rust struct. +// Method calls need to read this handle from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its handle should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the handle, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the handle, but is interrupted +// before it can pass the handle over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read handle value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +// +public interface ToriiClientInterface { + + fun `achievements`(`query`: AchievementQuery): PageAchievement + + fun `activities`(`query`: ActivityQuery): PageActivity + + fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry + + fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + + fun `contracts`(`query`: ContractQuery): List + + fun `controllers`(`query`: ControllerQuery): PageController + + fun `entities`(`query`: Query): PageEntity + + fun `eventMessages`(`query`: Query): PageEntity + + fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement + + fun `publishMessage`(`message`: Message): kotlin.String + + fun `publishMessageBatch`(`messages`: List): List + + fun `sql`(`query`: kotlin.String): List + + fun `starknetEvents`(`query`: EventQuery): PageEvent + + fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong + + fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong + + fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong + + fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong + + fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong + + fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance + + fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract + + fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer + + fun `tokens`(`query`: TokenQuery): PageToken + + fun `transactions`(`query`: TransactionQuery): PageTransaction + + fun `worlds`(`worldAddresses`: List): List + + companion object +} + +open class ToriiClient: Disposable, AutoCloseable, ToriiClientInterface +{ + + @Suppress("UNUSED_PARAMETER") + /** + * @suppress + */ + constructor(withHandle: UniffiWithHandle, handle: Long) { + this.handle = handle + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + + /** + * @suppress + * + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noHandle: NoHandle) { + this.handle = 0 + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + constructor(`toriiUrl`: kotlin.String) : + this(UniffiWithHandle, + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new( + + FfiConverterString.lower(`toriiUrl`),_status) +} + ) + + protected val handle: Long + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithHandle(block: (handle: Long) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the handle being freed concurrently. + try { + return block(this.uniffiCloneHandle()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val handle: Long) : Runnable { + override fun run() { + if (handle == 0.toLong()) { + // Fake object created with `NoHandle`, don't try to free. + return; + } + uniffiRustCall { status -> + UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient(handle, status) + } + } + } + + /** + * @suppress + */ + fun uniffiCloneHandle(): Long { + if (handle == 0.toLong()) { + throw InternalException("uniffiCloneHandle() called on NoHandle object"); + } + return uniffiRustCall() { status -> + UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient(handle, status) + } + } + + + @Throws(DojoException::class)override fun `achievements`(`query`: AchievementQuery): PageAchievement { + return FfiConverterTypePageAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements( + it, + FfiConverterTypeAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `activities`(`query`: ActivityQuery): PageActivity { + return FfiConverterTypePageActivity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities( + it, + FfiConverterTypeActivityQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry { + return FfiConverterTypePageAggregationEntry.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations( + it, + FfiConverterTypeAggregationQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + = + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription( + it, + FfiConverterULong.lower(`subscriptionId`),_status) +} + } + + + + + @Throws(DojoException::class)override fun `contracts`(`query`: ContractQuery): List { + return FfiConverterSequenceTypeContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts( + it, + FfiConverterTypeContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `controllers`(`query`: ControllerQuery): PageController { + return FfiConverterTypePageController.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers( + it, + FfiConverterTypeControllerQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `entities`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `eventMessages`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement { + return FfiConverterTypePagePlayerAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements( + it, + FfiConverterTypePlayerAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessage`(`message`: Message): kotlin.String { + return FfiConverterString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message( + it, + FfiConverterTypeMessage.lower(`message`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessageBatch`(`messages`: List): List { + return FfiConverterSequenceString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch( + it, + FfiConverterSequenceTypeMessage.lower(`messages`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `sql`(`query`: kotlin.String): List { + return FfiConverterSequenceTypeSqlRow.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql( + it, + FfiConverterString.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `starknetEvents`(`query`: EventQuery): PageEvent { + return FfiConverterTypePageEvent.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events( + it, + FfiConverterTypeEventQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates( + it, + FfiConverterOptionalTypeClause.lower(`clause`),FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),FfiConverterTypeEntityUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates( + it, + FfiConverterSequenceTypeKeysClause.lower(`keys`),FfiConverterTypeEventUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeFieldElement.lower(`accountAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenBalanceUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates( + it, + FfiConverterOptionalTypeTransactionFilter.lower(`filter`),FfiConverterTypeTransactionUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance { + return FfiConverterTypePageTokenBalance.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances( + it, + FfiConverterTypeTokenBalanceQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract { + return FfiConverterTypePageTokenContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts( + it, + FfiConverterTypeTokenContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer { + return FfiConverterTypePageTokenTransfer.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers( + it, + FfiConverterTypeTokenTransferQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokens`(`query`: TokenQuery): PageToken { + return FfiConverterTypePageToken.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens( + it, + FfiConverterTypeTokenQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `transactions`(`query`: TransactionQuery): PageTransaction { + return FfiConverterTypePageTransaction.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions( + it, + FfiConverterTypeTransactionQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `worlds`(`worldAddresses`: List): List { + return FfiConverterSequenceTypeWorld.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds( + it, + FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),_status) +} + } + ) + } + + + + + + + + + companion object { + + @Throws(DojoException::class) fun `newWithConfig`(`toriiUrl`: kotlin.String, `maxMessageSize`: kotlin.ULong): ToriiClient { + return FfiConverterTypeToriiClient.lift( + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config( + + FfiConverterString.lower(`toriiUrl`),FfiConverterULong.lower(`maxMessageSize`),_status) +} + ) + } + + + + } + +} + + +/** + * @suppress + */ +public object FfiConverterTypeToriiClient: FfiConverter { + override fun lower(value: ToriiClient): Long { + return value.uniffiCloneHandle() + } + + override fun lift(value: Long): ToriiClient { + return ToriiClient(UniffiWithHandle, value) + } + + override fun read(buf: ByteBuffer): ToriiClient { + return lift(buf.getLong()) + } + + override fun allocationSize(value: ToriiClient) = 8UL + + override fun write(value: ToriiClient, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} + + + +data class Achievement ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `entityId`: kotlin.String + , + val `hidden`: kotlin.Boolean + , + val `index`: kotlin.UInt + , + val `points`: kotlin.UInt + , + val `start`: kotlin.String + , + val `end`: kotlin.String + , + val `group`: kotlin.String + , + val `icon`: kotlin.String + , + val `title`: kotlin.String + , + val `description`: kotlin.String + , + val `tasks`: List + , + val `data`: kotlin.String? + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Achievement { + return Achievement( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeAchievementTask.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Achievement) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterBoolean.allocationSize(value.`hidden`) + + FfiConverterUInt.allocationSize(value.`index`) + + FfiConverterUInt.allocationSize(value.`points`) + + FfiConverterString.allocationSize(value.`start`) + + FfiConverterString.allocationSize(value.`end`) + + FfiConverterString.allocationSize(value.`group`) + + FfiConverterString.allocationSize(value.`icon`) + + FfiConverterString.allocationSize(value.`title`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterSequenceTypeAchievementTask.allocationSize(value.`tasks`) + + FfiConverterOptionalString.allocationSize(value.`data`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Achievement, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterBoolean.write(value.`hidden`, buf) + FfiConverterUInt.write(value.`index`, buf) + FfiConverterUInt.write(value.`points`, buf) + FfiConverterString.write(value.`start`, buf) + FfiConverterString.write(value.`end`, buf) + FfiConverterString.write(value.`group`, buf) + FfiConverterString.write(value.`icon`, buf) + FfiConverterString.write(value.`title`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterSequenceTypeAchievementTask.write(value.`tasks`, buf) + FfiConverterOptionalString.write(value.`data`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementProgression ( + val `id`: kotlin.String + , + val `achievementId`: kotlin.String + , + val `taskId`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `playerId`: FieldElement + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + , + val `completedAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementProgression: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementProgression { + return AchievementProgression( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementProgression) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`achievementId`) + + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`playerId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterOptionalULong.allocationSize(value.`completedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AchievementProgression, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`achievementId`, buf) + FfiConverterString.write(value.`taskId`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`playerId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterOptionalULong.write(value.`completedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `hidden`: kotlin.Boolean? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementQuery { + return AchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterOptionalBoolean.allocationSize(value.`hidden`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterOptionalBoolean.write(value.`hidden`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AchievementTask ( + val `taskId`: kotlin.String + , + val `description`: kotlin.String + , + val `total`: kotlin.UInt + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementTask: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementTask { + return AchievementTask( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementTask) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterUInt.allocationSize(value.`total`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: AchievementTask, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterUInt.write(value.`total`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ActionCount ( + val `actionName`: kotlin.String + , + val `count`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActionCount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActionCount { + return ActionCount( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: ActionCount) = ( + FfiConverterString.allocationSize(value.`actionName`) + + FfiConverterUInt.allocationSize(value.`count`) + ) + + override fun write(value: ActionCount, buf: ByteBuffer) { + FfiConverterString.write(value.`actionName`, buf) + FfiConverterUInt.write(value.`count`, buf) + } +} + + + +data class Activity ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `callerAddress`: FieldElement + , + val `sessionStart`: kotlin.ULong + , + val `sessionEnd`: kotlin.ULong + , + val `actionCount`: kotlin.UInt + , + val `actions`: List + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Activity { + return Activity( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterSequenceTypeActionCount.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Activity) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + + FfiConverterULong.allocationSize(value.`sessionStart`) + + FfiConverterULong.allocationSize(value.`sessionEnd`) + + FfiConverterUInt.allocationSize(value.`actionCount`) + + FfiConverterSequenceTypeActionCount.allocationSize(value.`actions`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Activity, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + FfiConverterULong.write(value.`sessionStart`, buf) + FfiConverterULong.write(value.`sessionEnd`, buf) + FfiConverterUInt.write(value.`actionCount`, buf) + FfiConverterSequenceTypeActionCount.write(value.`actions`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class ActivityQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `callerAddresses`: List + , + val `fromTime`: kotlin.ULong? + , + val `toTime`: kotlin.ULong? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivityQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActivityQuery { + return ActivityQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: ActivityQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterOptionalULong.allocationSize(value.`fromTime`) + + FfiConverterOptionalULong.allocationSize(value.`toTime`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: ActivityQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterOptionalULong.write(value.`fromTime`, buf) + FfiConverterOptionalULong.write(value.`toTime`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AggregationEntry ( + val `id`: kotlin.String + , + val `aggregatorId`: kotlin.String + , + val `entityId`: kotlin.String + , + val `value`: U256 + , + val `displayValue`: kotlin.String + , + val `position`: kotlin.ULong + , + val `modelId`: kotlin.String + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationEntry { + return AggregationEntry( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AggregationEntry) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`aggregatorId`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterTypeU256.allocationSize(value.`value`) + + FfiConverterString.allocationSize(value.`displayValue`) + + FfiConverterULong.allocationSize(value.`position`) + + FfiConverterString.allocationSize(value.`modelId`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AggregationEntry, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`aggregatorId`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterTypeU256.write(value.`value`, buf) + FfiConverterString.write(value.`displayValue`, buf) + FfiConverterULong.write(value.`position`, buf) + FfiConverterString.write(value.`modelId`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AggregationQuery ( + val `aggregatorIds`: List + , + val `entityIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationQuery { + return AggregationQuery( + FfiConverterSequenceString.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AggregationQuery) = ( + FfiConverterSequenceString.allocationSize(value.`aggregatorIds`) + + FfiConverterSequenceString.allocationSize(value.`entityIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AggregationQuery, buf: ByteBuffer) { + FfiConverterSequenceString.write(value.`aggregatorIds`, buf) + FfiConverterSequenceString.write(value.`entityIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AttributeFilter ( + val `traitName`: kotlin.String + , + val `traitValue`: kotlin.String + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAttributeFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AttributeFilter { + return AttributeFilter( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: AttributeFilter) = ( + FfiConverterString.allocationSize(value.`traitName`) + + FfiConverterString.allocationSize(value.`traitValue`) + ) + + override fun write(value: AttributeFilter, buf: ByteBuffer) { + FfiConverterString.write(value.`traitName`, buf) + FfiConverterString.write(value.`traitValue`, buf) + } +} + + + +data class CompositeClause ( + val `operator`: LogicalOperator + , + val `clauses`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeCompositeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CompositeClause { + return CompositeClause( + FfiConverterTypeLogicalOperator.read(buf), + FfiConverterSequenceTypeClause.read(buf), + ) + } + + override fun allocationSize(value: CompositeClause) = ( + FfiConverterTypeLogicalOperator.allocationSize(value.`operator`) + + FfiConverterSequenceTypeClause.allocationSize(value.`clauses`) + ) + + override fun write(value: CompositeClause, buf: ByteBuffer) { + FfiConverterTypeLogicalOperator.write(value.`operator`, buf) + FfiConverterSequenceTypeClause.write(value.`clauses`, buf) + } +} + + + +data class Contract ( + val `contractAddress`: FieldElement + , + val `contractType`: ContractType + , + val `head`: kotlin.ULong? + , + val `tps`: kotlin.ULong? + , + val `lastBlockTimestamp`: kotlin.ULong? + , + val `lastPendingBlockTx`: FieldElement? + , + val `updatedAt`: kotlin.ULong + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Contract { + return Contract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeContractType.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Contract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeContractType.allocationSize(value.`contractType`) + + FfiConverterOptionalULong.allocationSize(value.`head`) + + FfiConverterOptionalULong.allocationSize(value.`tps`) + + FfiConverterOptionalULong.allocationSize(value.`lastBlockTimestamp`) + + FfiConverterOptionalTypeFieldElement.allocationSize(value.`lastPendingBlockTx`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: Contract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeContractType.write(value.`contractType`, buf) + FfiConverterOptionalULong.write(value.`head`, buf) + FfiConverterOptionalULong.write(value.`tps`, buf) + FfiConverterOptionalULong.write(value.`lastBlockTimestamp`, buf) + FfiConverterOptionalTypeFieldElement.write(value.`lastPendingBlockTx`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ContractQuery { + return ContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + ) + } + + override fun allocationSize(value: ContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + ) + + override fun write(value: ContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + } +} + + + +data class Controller ( + val `address`: FieldElement + , + val `username`: kotlin.String + , + val `deployedAtTimestamp`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Controller { + return Controller( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Controller) = ( + FfiConverterTypeFieldElement.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`username`) + + FfiConverterULong.allocationSize(value.`deployedAtTimestamp`) + ) + + override fun write(value: Controller, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`address`, buf) + FfiConverterString.write(value.`username`, buf) + FfiConverterULong.write(value.`deployedAtTimestamp`, buf) + } +} + + + +data class ControllerQuery ( + val `pagination`: Pagination + , + val `contractAddresses`: List + , + val `usernames`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeControllerQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ControllerQuery { + return ControllerQuery( + FfiConverterTypePagination.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: ControllerQuery) = ( + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`usernames`) + ) + + override fun write(value: ControllerQuery, buf: ByteBuffer) { + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`usernames`, buf) + } +} + + + +data class Entity ( + val `worldAddress`: FieldElement + , + val `hashedKeys`: FieldElement + , + val `models`: List + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + , + val `executedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Entity { + return Entity( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeStruct.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Entity) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`hashedKeys`) + + FfiConverterSequenceTypeStruct.allocationSize(value.`models`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`executedAt`) + ) + + override fun write(value: Entity, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeFieldElement.write(value.`hashedKeys`, buf) + FfiConverterSequenceTypeStruct.write(value.`models`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + } +} + + + +data class EnumOption ( + val `name`: kotlin.String + , + val `ty`: Ty + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumOption: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumOption { + return EnumOption( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + ) + } + + override fun allocationSize(value: EnumOption) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + ) + + override fun write(value: EnumOption, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + } +} + + + +data class EnumType ( + val `name`: kotlin.String + , + val `option`: kotlin.UByte + , + val `options`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumType { + return EnumType( + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterSequenceTypeEnumOption.read(buf), + ) + } + + override fun allocationSize(value: EnumType) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterUByte.allocationSize(value.`option`) + + FfiConverterSequenceTypeEnumOption.allocationSize(value.`options`) + ) + + override fun write(value: EnumType, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterUByte.write(value.`option`, buf) + FfiConverterSequenceTypeEnumOption.write(value.`options`, buf) + } +} + + + +data class Event ( + val `keys`: List + , + val `data`: List + , + val `transactionHash`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Event { + return Event( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Event) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`data`) + + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + ) + + override fun write(value: Event, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`data`, buf) + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + } +} + + + +data class EventQuery ( + val `keys`: KeysClause? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEventQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EventQuery { + return EventQuery( + FfiConverterOptionalTypeKeysClause.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: EventQuery) = ( + FfiConverterOptionalTypeKeysClause.allocationSize(value.`keys`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: EventQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeKeysClause.write(value.`keys`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class FixedSizeArray ( + val `array`: List + , + val `size`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeFixedSizeArray: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FixedSizeArray { + return FixedSizeArray( + FfiConverterSequenceTypeTy.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: FixedSizeArray) = ( + FfiConverterSequenceTypeTy.allocationSize(value.`array`) + + FfiConverterUInt.allocationSize(value.`size`) + ) + + override fun write(value: FixedSizeArray, buf: ByteBuffer) { + FfiConverterSequenceTypeTy.write(value.`array`, buf) + FfiConverterUInt.write(value.`size`, buf) + } +} + + + +data class KeysClause ( + val `keys`: List + , + val `patternMatching`: PatternMatching + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause { + return KeysClause( + FfiConverterSequenceOptionalTypeFieldElement.read(buf), + FfiConverterTypePatternMatching.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: KeysClause) = ( + FfiConverterSequenceOptionalTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterTypePatternMatching.allocationSize(value.`patternMatching`) + + FfiConverterSequenceString.allocationSize(value.`models`) + ) + + override fun write(value: KeysClause, buf: ByteBuffer) { + FfiConverterSequenceOptionalTypeFieldElement.write(value.`keys`, buf) + FfiConverterTypePatternMatching.write(value.`patternMatching`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + } +} + + + +data class Member ( + val `name`: kotlin.String + , + val `ty`: Ty + , + val `key`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMember: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Member { + return Member( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Member) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + + FfiConverterBoolean.allocationSize(value.`key`) + ) + + override fun write(value: Member, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + FfiConverterBoolean.write(value.`key`, buf) + } +} + + + +data class MemberClause ( + val `model`: kotlin.String + , + val `member`: kotlin.String + , + val `operator`: ComparisonOperator + , + val `value`: MemberValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): MemberClause { + return MemberClause( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeComparisonOperator.read(buf), + FfiConverterTypeMemberValue.read(buf), + ) + } + + override fun allocationSize(value: MemberClause) = ( + FfiConverterString.allocationSize(value.`model`) + + FfiConverterString.allocationSize(value.`member`) + + FfiConverterTypeComparisonOperator.allocationSize(value.`operator`) + + FfiConverterTypeMemberValue.allocationSize(value.`value`) + ) + + override fun write(value: MemberClause, buf: ByteBuffer) { + FfiConverterString.write(value.`model`, buf) + FfiConverterString.write(value.`member`, buf) + FfiConverterTypeComparisonOperator.write(value.`operator`, buf) + FfiConverterTypeMemberValue.write(value.`value`, buf) + } +} + + + +data class Message ( + val `message`: kotlin.String + , + val `signature`: List + , + val `worldAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMessage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Message { + return Message( + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Message) = ( + FfiConverterString.allocationSize(value.`message`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + ) + + override fun write(value: Message, buf: ByteBuffer) { + FfiConverterString.write(value.`message`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + } +} + + + +data class Model ( + val `worldAddress`: FieldElement + , + val `schema`: Ty + , + val `namespace`: kotlin.String + , + val `name`: kotlin.String + , + val `selector`: FieldElement + , + val `packedSize`: kotlin.UInt + , + val `unpackedSize`: kotlin.UInt + , + val `classHash`: FieldElement + , + val `contractAddress`: FieldElement + , + val `layout`: kotlin.String + , + val `useLegacyStore`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeModel: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Model { + return Model( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Model) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeTy.allocationSize(value.`schema`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeFieldElement.allocationSize(value.`selector`) + + FfiConverterUInt.allocationSize(value.`packedSize`) + + FfiConverterUInt.allocationSize(value.`unpackedSize`) + + FfiConverterTypeFieldElement.allocationSize(value.`classHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`layout`) + + FfiConverterBoolean.allocationSize(value.`useLegacyStore`) + ) + + override fun write(value: Model, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeTy.write(value.`schema`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeFieldElement.write(value.`selector`, buf) + FfiConverterUInt.write(value.`packedSize`, buf) + FfiConverterUInt.write(value.`unpackedSize`, buf) + FfiConverterTypeFieldElement.write(value.`classHash`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`layout`, buf) + FfiConverterBoolean.write(value.`useLegacyStore`, buf) + } +} + + + +data class OrderBy ( + val `field`: kotlin.String + , + val `direction`: OrderDirection + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeOrderBy: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): OrderBy { + return OrderBy( + FfiConverterString.read(buf), + FfiConverterTypeOrderDirection.read(buf), + ) + } + + override fun allocationSize(value: OrderBy) = ( + FfiConverterString.allocationSize(value.`field`) + + FfiConverterTypeOrderDirection.allocationSize(value.`direction`) + ) + + override fun write(value: OrderBy, buf: ByteBuffer) { + FfiConverterString.write(value.`field`, buf) + FfiConverterTypeOrderDirection.write(value.`direction`, buf) + } +} + + + +data class PageAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAchievement { + return PageAchievement( + FfiConverterSequenceTypeAchievement.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAchievement) = ( + FfiConverterSequenceTypeAchievement.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypeAchievement.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageActivity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageActivity { + return PageActivity( + FfiConverterSequenceTypeActivity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageActivity) = ( + FfiConverterSequenceTypeActivity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageActivity, buf: ByteBuffer) { + FfiConverterSequenceTypeActivity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageAggregationEntry ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAggregationEntry { + return PageAggregationEntry( + FfiConverterSequenceTypeAggregationEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAggregationEntry) = ( + FfiConverterSequenceTypeAggregationEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAggregationEntry, buf: ByteBuffer) { + FfiConverterSequenceTypeAggregationEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageController ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageController { + return PageController( + FfiConverterSequenceTypeController.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageController) = ( + FfiConverterSequenceTypeController.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageController, buf: ByteBuffer) { + FfiConverterSequenceTypeController.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEntity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEntity { + return PageEntity( + FfiConverterSequenceTypeEntity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEntity) = ( + FfiConverterSequenceTypeEntity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEntity, buf: ByteBuffer) { + FfiConverterSequenceTypeEntity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEvent ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEvent { + return PageEvent( + FfiConverterSequenceTypeEvent.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEvent) = ( + FfiConverterSequenceTypeEvent.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEvent, buf: ByteBuffer) { + FfiConverterSequenceTypeEvent.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PagePlayerAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagePlayerAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PagePlayerAchievement { + return PagePlayerAchievement( + FfiConverterSequenceTypePlayerAchievementEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PagePlayerAchievement) = ( + FfiConverterSequenceTypePlayerAchievementEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PagePlayerAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypePlayerAchievementEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageToken ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageToken { + return PageToken( + FfiConverterSequenceTypeToken.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageToken) = ( + FfiConverterSequenceTypeToken.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageToken, buf: ByteBuffer) { + FfiConverterSequenceTypeToken.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenBalance ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenBalance { + return PageTokenBalance( + FfiConverterSequenceTypeTokenBalance.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenBalance) = ( + FfiConverterSequenceTypeTokenBalance.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenBalance, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenBalance.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenContract ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenContract { + return PageTokenContract( + FfiConverterSequenceTypeTokenContract.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenContract) = ( + FfiConverterSequenceTypeTokenContract.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenContract, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenContract.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenTransfer ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenTransfer { + return PageTokenTransfer( + FfiConverterSequenceTypeTokenTransfer.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenTransfer) = ( + FfiConverterSequenceTypeTokenTransfer.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenTransfer, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenTransfer.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTransaction ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTransaction { + return PageTransaction( + FfiConverterSequenceTypeTransaction.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTransaction) = ( + FfiConverterSequenceTypeTransaction.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTransaction, buf: ByteBuffer) { + FfiConverterSequenceTypeTransaction.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class Pagination ( + val `cursor`: kotlin.String? + , + val `limit`: kotlin.UInt? + , + val `direction`: PaginationDirection + , + val `orderBy`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagination: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Pagination { + return Pagination( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterTypePaginationDirection.read(buf), + FfiConverterSequenceTypeOrderBy.read(buf), + ) + } + + override fun allocationSize(value: Pagination) = ( + FfiConverterOptionalString.allocationSize(value.`cursor`) + + FfiConverterOptionalUInt.allocationSize(value.`limit`) + + FfiConverterTypePaginationDirection.allocationSize(value.`direction`) + + FfiConverterSequenceTypeOrderBy.allocationSize(value.`orderBy`) + ) + + override fun write(value: Pagination, buf: ByteBuffer) { + FfiConverterOptionalString.write(value.`cursor`, buf) + FfiConverterOptionalUInt.write(value.`limit`, buf) + FfiConverterTypePaginationDirection.write(value.`direction`, buf) + FfiConverterSequenceTypeOrderBy.write(value.`orderBy`, buf) + } +} + + + +data class PlayerAchievementEntry ( + val `playerAddress`: FieldElement + , + val `stats`: PlayerAchievementStats + , + val `achievements`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementEntry { + return PlayerAchievementEntry( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypePlayerAchievementStats.read(buf), + FfiConverterSequenceTypePlayerAchievementProgress.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementEntry) = ( + FfiConverterTypeFieldElement.allocationSize(value.`playerAddress`) + + FfiConverterTypePlayerAchievementStats.allocationSize(value.`stats`) + + FfiConverterSequenceTypePlayerAchievementProgress.allocationSize(value.`achievements`) + ) + + override fun write(value: PlayerAchievementEntry, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`playerAddress`, buf) + FfiConverterTypePlayerAchievementStats.write(value.`stats`, buf) + FfiConverterSequenceTypePlayerAchievementProgress.write(value.`achievements`, buf) + } +} + + + +data class PlayerAchievementProgress ( + val `achievement`: Achievement + , + val `taskProgress`: List + , + val `completed`: kotlin.Boolean + , + val `progressPercentage`: kotlin.Double + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementProgress { + return PlayerAchievementProgress( + FfiConverterTypeAchievement.read(buf), + FfiConverterSequenceTypeTaskProgress.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterDouble.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementProgress) = ( + FfiConverterTypeAchievement.allocationSize(value.`achievement`) + + FfiConverterSequenceTypeTaskProgress.allocationSize(value.`taskProgress`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterDouble.allocationSize(value.`progressPercentage`) + ) + + override fun write(value: PlayerAchievementProgress, buf: ByteBuffer) { + FfiConverterTypeAchievement.write(value.`achievement`, buf) + FfiConverterSequenceTypeTaskProgress.write(value.`taskProgress`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterDouble.write(value.`progressPercentage`, buf) + } +} + + + +data class PlayerAchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `playerAddresses`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementQuery { + return PlayerAchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`playerAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: PlayerAchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`playerAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class PlayerAchievementStats ( + val `totalPoints`: kotlin.UInt + , + val `completedAchievements`: kotlin.UInt + , + val `totalAchievements`: kotlin.UInt + , + val `completionPercentage`: kotlin.Double + , + val `lastAchievementAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementStats: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementStats { + return PlayerAchievementStats( + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementStats) = ( + FfiConverterUInt.allocationSize(value.`totalPoints`) + + FfiConverterUInt.allocationSize(value.`completedAchievements`) + + FfiConverterUInt.allocationSize(value.`totalAchievements`) + + FfiConverterDouble.allocationSize(value.`completionPercentage`) + + FfiConverterOptionalULong.allocationSize(value.`lastAchievementAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: PlayerAchievementStats, buf: ByteBuffer) { + FfiConverterUInt.write(value.`totalPoints`, buf) + FfiConverterUInt.write(value.`completedAchievements`, buf) + FfiConverterUInt.write(value.`totalAchievements`, buf) + FfiConverterDouble.write(value.`completionPercentage`, buf) + FfiConverterOptionalULong.write(value.`lastAchievementAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class Query ( + val `worldAddresses`: List + , + val `pagination`: Pagination + , + val `clause`: Clause? + , + val `noHashedKeys`: kotlin.Boolean + , + val `models`: List + , + val `historical`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Query { + return Query( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + FfiConverterOptionalTypeClause.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Query) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterOptionalTypeClause.allocationSize(value.`clause`) + + FfiConverterBoolean.allocationSize(value.`noHashedKeys`) + + FfiConverterSequenceString.allocationSize(value.`models`) + + FfiConverterBoolean.allocationSize(value.`historical`) + ) + + override fun write(value: Query, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterOptionalTypeClause.write(value.`clause`, buf) + FfiConverterBoolean.write(value.`noHashedKeys`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + FfiConverterBoolean.write(value.`historical`, buf) + } +} + + + +data class Signature ( + val `r`: FieldElement + , + val `s`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSignature: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Signature { + return Signature( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Signature) = ( + FfiConverterTypeFieldElement.allocationSize(value.`r`) + + FfiConverterTypeFieldElement.allocationSize(value.`s`) + ) + + override fun write(value: Signature, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`r`, buf) + FfiConverterTypeFieldElement.write(value.`s`, buf) + } +} + + + +data class SqlField ( + val `name`: kotlin.String + , + val `value`: SqlValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlField: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlField { + return SqlField( + FfiConverterString.read(buf), + FfiConverterTypeSqlValue.read(buf), + ) + } + + override fun allocationSize(value: SqlField) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeSqlValue.allocationSize(value.`value`) + ) + + override fun write(value: SqlField, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeSqlValue.write(value.`value`, buf) + } +} + + + +data class SqlRow ( + val `fields`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlRow: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlRow { + return SqlRow( + FfiConverterSequenceTypeSqlField.read(buf), + ) + } + + override fun allocationSize(value: SqlRow) = ( + FfiConverterSequenceTypeSqlField.allocationSize(value.`fields`) + ) + + override fun write(value: SqlRow, buf: ByteBuffer) { + FfiConverterSequenceTypeSqlField.write(value.`fields`, buf) + } +} + + + +data class Struct ( + val `name`: kotlin.String + , + val `children`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeStruct: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Struct { + return Struct( + FfiConverterString.read(buf), + FfiConverterSequenceTypeMember.read(buf), + ) + } + + override fun allocationSize(value: Struct) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterSequenceTypeMember.allocationSize(value.`children`) + ) + + override fun write(value: Struct, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterSequenceTypeMember.write(value.`children`, buf) + } +} + + + +data class TaskProgress ( + val `taskId`: kotlin.String + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTaskProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TaskProgress { + return TaskProgress( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: TaskProgress) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + ) + + override fun write(value: TaskProgress, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + } +} + + + +data class Token ( + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Token { + return Token( + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: Token) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: Token, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenBalance ( + val `balance`: U256 + , + val `accountAddress`: FieldElement + , + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalance { + return TokenBalance( + FfiConverterTypeU256.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenBalance) = ( + FfiConverterTypeU256.allocationSize(value.`balance`) + + FfiConverterTypeFieldElement.allocationSize(value.`accountAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + ) + + override fun write(value: TokenBalance, buf: ByteBuffer) { + FfiConverterTypeU256.write(value.`balance`, buf) + FfiConverterTypeFieldElement.write(value.`accountAddress`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + } +} + + + +data class TokenBalanceQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalanceQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalanceQuery { + return TokenBalanceQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenBalanceQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenBalanceQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenContract ( + val `contractAddress`: FieldElement + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `tokenMetadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContract { + return TokenContract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenContract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterString.allocationSize(value.`tokenMetadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: TokenContract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterString.write(value.`tokenMetadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContractQuery { + return TokenContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenQuery ( + val `contractAddresses`: List + , + val `tokenIds`: List + , + val `attributeFilters`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenQuery { + return TokenQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterSequenceTypeAttributeFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterSequenceTypeAttributeFilter.allocationSize(value.`attributeFilters`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterSequenceTypeAttributeFilter.write(value.`attributeFilters`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenTransfer ( + val `id`: kotlin.String + , + val `contractAddress`: FieldElement + , + val `fromAddress`: FieldElement + , + val `toAddress`: FieldElement + , + val `amount`: U256 + , + val `tokenId`: U256? + , + val `executedAt`: kotlin.ULong + , + val `eventId`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransfer { + return TokenTransfer( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterULong.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: TokenTransfer) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`fromAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`toAddress`) + + FfiConverterTypeU256.allocationSize(value.`amount`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterULong.allocationSize(value.`executedAt`) + + FfiConverterOptionalString.allocationSize(value.`eventId`) + ) + + override fun write(value: TokenTransfer, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeFieldElement.write(value.`fromAddress`, buf) + FfiConverterTypeFieldElement.write(value.`toAddress`, buf) + FfiConverterTypeU256.write(value.`amount`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + FfiConverterOptionalString.write(value.`eventId`, buf) + } +} + + + +data class TokenTransferQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransferQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransferQuery { + return TokenTransferQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenTransferQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenTransferQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class Transaction ( + val `transactionHash`: FieldElement + , + val `senderAddress`: FieldElement + , + val `calldata`: List + , + val `maxFee`: FieldElement + , + val `signature`: List + , + val `nonce`: FieldElement + , + val `blockNumber`: kotlin.ULong + , + val `transactionType`: kotlin.String + , + val `blockTimestamp`: kotlin.ULong + , + val `calls`: List + , + val `uniqueModels`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Transaction { + return Transaction( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterSequenceTypeTransactionCall.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Transaction) = ( + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`senderAddress`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeFieldElement.allocationSize(value.`maxFee`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`nonce`) + + FfiConverterULong.allocationSize(value.`blockNumber`) + + FfiConverterString.allocationSize(value.`transactionType`) + + FfiConverterULong.allocationSize(value.`blockTimestamp`) + + FfiConverterSequenceTypeTransactionCall.allocationSize(value.`calls`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`uniqueModels`) + ) + + override fun write(value: Transaction, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + FfiConverterTypeFieldElement.write(value.`senderAddress`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeFieldElement.write(value.`maxFee`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`nonce`, buf) + FfiConverterULong.write(value.`blockNumber`, buf) + FfiConverterString.write(value.`transactionType`, buf) + FfiConverterULong.write(value.`blockTimestamp`, buf) + FfiConverterSequenceTypeTransactionCall.write(value.`calls`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`uniqueModels`, buf) + } +} + + + +data class TransactionCall ( + val `contractAddress`: FieldElement + , + val `entrypoint`: kotlin.String + , + val `calldata`: List + , + val `callType`: CallType + , + val `callerAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionCall: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionCall { + return TransactionCall( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeCallType.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: TransactionCall) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`entrypoint`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeCallType.allocationSize(value.`callType`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + ) + + override fun write(value: TransactionCall, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`entrypoint`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeCallType.write(value.`callType`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + } +} + + + +data class TransactionFilter ( + val `transactionHashes`: List + , + val `callerAddresses`: List + , + val `contractAddresses`: List + , + val `entrypoints`: List + , + val `modelSelectors`: List + , + val `fromBlock`: kotlin.ULong? + , + val `toBlock`: kotlin.ULong? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter { + return TransactionFilter( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + ) + } + + override fun allocationSize(value: TransactionFilter) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`transactionHashes`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`entrypoints`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`modelSelectors`) + + FfiConverterOptionalULong.allocationSize(value.`fromBlock`) + + FfiConverterOptionalULong.allocationSize(value.`toBlock`) + ) + + override fun write(value: TransactionFilter, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`transactionHashes`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`entrypoints`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`modelSelectors`, buf) + FfiConverterOptionalULong.write(value.`fromBlock`, buf) + FfiConverterOptionalULong.write(value.`toBlock`, buf) + } +} + + + +data class TransactionQuery ( + val `filter`: TransactionFilter? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionQuery { + return TransactionQuery( + FfiConverterOptionalTypeTransactionFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TransactionQuery) = ( + FfiConverterOptionalTypeTransactionFilter.allocationSize(value.`filter`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TransactionQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeTransactionFilter.write(value.`filter`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class World ( + val `worldAddress`: FieldElement + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeWorld: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): World { + return World( + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeModel.read(buf), + ) + } + + override fun allocationSize(value: World) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterSequenceTypeModel.allocationSize(value.`models`) + ) + + override fun write(value: World, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterSequenceTypeModel.write(value.`models`, buf) + } +} + + + + +enum class CallType { + + EXECUTE, + EXECUTE_FROM_OUTSIDE; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeCallType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + CallType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: CallType) = 4UL + + override fun write(value: CallType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Clause { + + data class HashedKeys( + val `keys`: List) : Clause() + + { + + + companion object + } + + data class Keys( + val `clause`: KeysClause) : Clause() + + { + + + companion object + } + + data class Member( + val `clause`: MemberClause) : Clause() + + { + + + companion object + } + + data class Composite( + val `clause`: CompositeClause) : Clause() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeClause : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Clause { + return when(buf.getInt()) { + 1 -> Clause.HashedKeys( + FfiConverterSequenceTypeFieldElement.read(buf), + ) + 2 -> Clause.Keys( + FfiConverterTypeKeysClause.read(buf), + ) + 3 -> Clause.Member( + FfiConverterTypeMemberClause.read(buf), + ) + 4 -> Clause.Composite( + FfiConverterTypeCompositeClause.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Clause) = when(value) { + is Clause.HashedKeys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + ) + } + is Clause.Keys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeKeysClause.allocationSize(value.`clause`) + ) + } + is Clause.Member -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeMemberClause.allocationSize(value.`clause`) + ) + } + is Clause.Composite -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeCompositeClause.allocationSize(value.`clause`) + ) + } + } + + override fun write(value: Clause, buf: ByteBuffer) { + when(value) { + is Clause.HashedKeys -> { + buf.putInt(1) + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + Unit + } + is Clause.Keys -> { + buf.putInt(2) + FfiConverterTypeKeysClause.write(value.`clause`, buf) + Unit + } + is Clause.Member -> { + buf.putInt(3) + FfiConverterTypeMemberClause.write(value.`clause`, buf) + Unit + } + is Clause.Composite -> { + buf.putInt(4) + FfiConverterTypeCompositeClause.write(value.`clause`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class ComparisonOperator { + + EQ, + NEQ, + GT, + GTE, + LT, + LTE, + IN, + NOT_IN, + CONTAINS, + CONTAINS_ALL, + CONTAINS_ANY, + ARRAY_LENGTH_EQ, + ARRAY_LENGTH_GT, + ARRAY_LENGTH_LT; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeComparisonOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ComparisonOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ComparisonOperator) = 4UL + + override fun write(value: ComparisonOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class ContractType { + + WORLD, + ERC20, + ERC721, + ERC1155, + UDC, + OTHER; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeContractType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ContractType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ContractType) = 4UL + + override fun write(value: ContractType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + + +sealed class DojoException(message: String): kotlin.Exception(message) { + + class ClientException(message: String) : DojoException(message) + + class SerializationException(message: String) : DojoException(message) + + class NetworkException(message: String) : DojoException(message) + + class InvalidInput(message: String) : DojoException(message) + + class ConnectionException(message: String) : DojoException(message) + + class PublishException(message: String) : DojoException(message) + + class QueryException(message: String) : DojoException(message) + + class SubscriptionException(message: String) : DojoException(message) + + + companion object ErrorHandler : UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): DojoException = FfiConverterTypeDojoError.lift(error_buf) + } +} + +/** + * @suppress + */ +public object FfiConverterTypeDojoError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): DojoException { + + return when(buf.getInt()) { + 1 -> DojoException.ClientException(FfiConverterString.read(buf)) + 2 -> DojoException.SerializationException(FfiConverterString.read(buf)) + 3 -> DojoException.NetworkException(FfiConverterString.read(buf)) + 4 -> DojoException.InvalidInput(FfiConverterString.read(buf)) + 5 -> DojoException.ConnectionException(FfiConverterString.read(buf)) + 6 -> DojoException.PublishException(FfiConverterString.read(buf)) + 7 -> DojoException.QueryException(FfiConverterString.read(buf)) + 8 -> DojoException.SubscriptionException(FfiConverterString.read(buf)) + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") + } + + } + + override fun allocationSize(value: DojoException): ULong { + return 4UL + } + + override fun write(value: DojoException, buf: ByteBuffer) { + when(value) { + is DojoException.ClientException -> { + buf.putInt(1) + Unit + } + is DojoException.SerializationException -> { + buf.putInt(2) + Unit + } + is DojoException.NetworkException -> { + buf.putInt(3) + Unit + } + is DojoException.InvalidInput -> { + buf.putInt(4) + Unit + } + is DojoException.ConnectionException -> { + buf.putInt(5) + Unit + } + is DojoException.PublishException -> { + buf.putInt(6) + Unit + } + is DojoException.QueryException -> { + buf.putInt(7) + Unit + } + is DojoException.SubscriptionException -> { + buf.putInt(8) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } + +} + + + + +enum class LogicalOperator { + + AND, + OR; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeLogicalOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + LogicalOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: LogicalOperator) = 4UL + + override fun write(value: LogicalOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class MemberValue { + + data class Primitive( + val `value`: Primitive) : MemberValue() + + { + + + companion object + } + + data class String( + val `value`: kotlin.String) : MemberValue() + + { + + + companion object + } + + data class List( + val `values`: List) : MemberValue() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): MemberValue { + return when(buf.getInt()) { + 1 -> MemberValue.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> MemberValue.String( + FfiConverterString.read(buf), + ) + 3 -> MemberValue.List( + FfiConverterSequenceTypeMemberValue.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: MemberValue) = when(value) { + is MemberValue.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is MemberValue.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is MemberValue.List -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeMemberValue.allocationSize(value.`values`) + ) + } + } + + override fun write(value: MemberValue, buf: ByteBuffer) { + when(value) { + is MemberValue.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is MemberValue.String -> { + buf.putInt(2) + FfiConverterString.write(value.`value`, buf) + Unit + } + is MemberValue.List -> { + buf.putInt(3) + FfiConverterSequenceTypeMemberValue.write(value.`values`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class OrderDirection { + + ASC, + DESC; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeOrderDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + OrderDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: OrderDirection) = 4UL + + override fun write(value: OrderDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PaginationDirection { + + FORWARD, + BACKWARD; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePaginationDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PaginationDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PaginationDirection) = 4UL + + override fun write(value: PaginationDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PatternMatching { + + FIXED_LEN, + VARIABLE_LEN; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePatternMatching: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PatternMatching.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PatternMatching) = 4UL + + override fun write(value: PatternMatching, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Primitive { + + data class I8( + val `value`: kotlin.Byte) : Primitive() + + { + + + companion object + } + + data class I16( + val `value`: kotlin.Short) : Primitive() + + { + + + companion object + } + + data class I32( + val `value`: kotlin.Int) : Primitive() + + { + + + companion object + } + + data class I64( + val `value`: kotlin.Long) : Primitive() + + { + + + companion object + } + + data class I128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U8( + val `value`: kotlin.UByte) : Primitive() + + { + + + companion object + } + + data class U16( + val `value`: kotlin.UShort) : Primitive() + + { + + + companion object + } + + data class U32( + val `value`: kotlin.UInt) : Primitive() + + { + + + companion object + } + + data class U64( + val `value`: kotlin.ULong) : Primitive() + + { + + + companion object + } + + data class U128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U256( + val `value`: U256) : Primitive() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : Primitive() + + { + + + companion object + } + + data class Felt252( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ClassHash( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ContractAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class EthAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePrimitive : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Primitive { + return when(buf.getInt()) { + 1 -> Primitive.I8( + FfiConverterByte.read(buf), + ) + 2 -> Primitive.I16( + FfiConverterShort.read(buf), + ) + 3 -> Primitive.I32( + FfiConverterInt.read(buf), + ) + 4 -> Primitive.I64( + FfiConverterLong.read(buf), + ) + 5 -> Primitive.I128( + FfiConverterSequenceUByte.read(buf), + ) + 6 -> Primitive.U8( + FfiConverterUByte.read(buf), + ) + 7 -> Primitive.U16( + FfiConverterUShort.read(buf), + ) + 8 -> Primitive.U32( + FfiConverterUInt.read(buf), + ) + 9 -> Primitive.U64( + FfiConverterULong.read(buf), + ) + 10 -> Primitive.U128( + FfiConverterSequenceUByte.read(buf), + ) + 11 -> Primitive.U256( + FfiConverterTypeU256.read(buf), + ) + 12 -> Primitive.Bool( + FfiConverterBoolean.read(buf), + ) + 13 -> Primitive.Felt252( + FfiConverterTypeFieldElement.read(buf), + ) + 14 -> Primitive.ClassHash( + FfiConverterTypeFieldElement.read(buf), + ) + 15 -> Primitive.ContractAddress( + FfiConverterTypeFieldElement.read(buf), + ) + 16 -> Primitive.EthAddress( + FfiConverterTypeFieldElement.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Primitive) = when(value) { + is Primitive.I8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterByte.allocationSize(value.`value`) + ) + } + is Primitive.I16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterShort.allocationSize(value.`value`) + ) + } + is Primitive.I32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterInt.allocationSize(value.`value`) + ) + } + is Primitive.I64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is Primitive.I128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUByte.allocationSize(value.`value`) + ) + } + is Primitive.U16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUShort.allocationSize(value.`value`) + ) + } + is Primitive.U32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUInt.allocationSize(value.`value`) + ) + } + is Primitive.U64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is Primitive.U128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U256 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeU256.allocationSize(value.`value`) + ) + } + is Primitive.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is Primitive.Felt252 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ClassHash -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ContractAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.EthAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Primitive, buf: ByteBuffer) { + when(value) { + is Primitive.I8 -> { + buf.putInt(1) + FfiConverterByte.write(value.`value`, buf) + Unit + } + is Primitive.I16 -> { + buf.putInt(2) + FfiConverterShort.write(value.`value`, buf) + Unit + } + is Primitive.I32 -> { + buf.putInt(3) + FfiConverterInt.write(value.`value`, buf) + Unit + } + is Primitive.I64 -> { + buf.putInt(4) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is Primitive.I128 -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U8 -> { + buf.putInt(6) + FfiConverterUByte.write(value.`value`, buf) + Unit + } + is Primitive.U16 -> { + buf.putInt(7) + FfiConverterUShort.write(value.`value`, buf) + Unit + } + is Primitive.U32 -> { + buf.putInt(8) + FfiConverterUInt.write(value.`value`, buf) + Unit + } + is Primitive.U64 -> { + buf.putInt(9) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is Primitive.U128 -> { + buf.putInt(10) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U256 -> { + buf.putInt(11) + FfiConverterTypeU256.write(value.`value`, buf) + Unit + } + is Primitive.Bool -> { + buf.putInt(12) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is Primitive.Felt252 -> { + buf.putInt(13) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ClassHash -> { + buf.putInt(14) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ContractAddress -> { + buf.putInt(15) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.EthAddress -> { + buf.putInt(16) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class SqlValue { + + data class Text( + val `value`: kotlin.String) : SqlValue() + + { + + + companion object + } + + data class Integer( + val `value`: kotlin.Long) : SqlValue() + + { + + + companion object + } + + data class Real( + val `value`: kotlin.Double) : SqlValue() + + { + + + companion object + } + + data class Blob( + val `value`: List) : SqlValue() + + { + + + companion object + } + + object Null : SqlValue() + + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): SqlValue { + return when(buf.getInt()) { + 1 -> SqlValue.Text( + FfiConverterString.read(buf), + ) + 2 -> SqlValue.Integer( + FfiConverterLong.read(buf), + ) + 3 -> SqlValue.Real( + FfiConverterDouble.read(buf), + ) + 4 -> SqlValue.Blob( + FfiConverterSequenceUByte.read(buf), + ) + 5 -> SqlValue.Null + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: SqlValue) = when(value) { + is SqlValue.Text -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is SqlValue.Integer -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is SqlValue.Real -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterDouble.allocationSize(value.`value`) + ) + } + is SqlValue.Blob -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is SqlValue.Null -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + } + + override fun write(value: SqlValue, buf: ByteBuffer) { + when(value) { + is SqlValue.Text -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is SqlValue.Integer -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is SqlValue.Real -> { + buf.putInt(3) + FfiConverterDouble.write(value.`value`, buf) + Unit + } + is SqlValue.Blob -> { + buf.putInt(4) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is SqlValue.Null -> { + buf.putInt(5) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class Ty { + + data class Primitive( + val `value`: Primitive) : Ty() + + { + + + companion object + } + + data class Struct( + val `value`: Struct) : Ty() + + { + + + companion object + } + + data class Enum( + val `value`: EnumType) : Ty() + + { + + + companion object + } + + data class Tuple( + val `values`: List) : Ty() + + { + + + companion object + } + + data class Array( + val `values`: List) : Ty() + + { + + + companion object + } + + data class FixedSizeArray( + val `value`: FixedSizeArray) : Ty() + + { + + + companion object + } + + data class ByteArray( + val `value`: kotlin.String) : Ty() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTy : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Ty { + return when(buf.getInt()) { + 1 -> Ty.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> Ty.Struct( + FfiConverterTypeStruct.read(buf), + ) + 3 -> Ty.Enum( + FfiConverterTypeEnumType.read(buf), + ) + 4 -> Ty.Tuple( + FfiConverterSequenceTypeTy.read(buf), + ) + 5 -> Ty.Array( + FfiConverterSequenceTypeTy.read(buf), + ) + 6 -> Ty.FixedSizeArray( + FfiConverterTypeFixedSizeArray.read(buf), + ) + 7 -> Ty.ByteArray( + FfiConverterString.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Ty) = when(value) { + is Ty.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is Ty.Struct -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeStruct.allocationSize(value.`value`) + ) + } + is Ty.Enum -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeEnumType.allocationSize(value.`value`) + ) + } + is Ty.Tuple -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.Array -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.FixedSizeArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFixedSizeArray.allocationSize(value.`value`) + ) + } + is Ty.ByteArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Ty, buf: ByteBuffer) { + when(value) { + is Ty.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is Ty.Struct -> { + buf.putInt(2) + FfiConverterTypeStruct.write(value.`value`, buf) + Unit + } + is Ty.Enum -> { + buf.putInt(3) + FfiConverterTypeEnumType.write(value.`value`, buf) + Unit + } + is Ty.Tuple -> { + buf.putInt(4) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.Array -> { + buf.putInt(5) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.FixedSizeArray -> { + buf.putInt(6) + FfiConverterTypeFixedSizeArray.write(value.`value`, buf) + Unit + } + is Ty.ByteArray -> { + buf.putInt(7) + FfiConverterString.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class ValueType { + + data class String( + val `value`: kotlin.String) : ValueType() + + { + + + companion object + } + + data class Int( + val `value`: kotlin.Long) : ValueType() + + { + + + companion object + } + + data class UInt( + val `value`: kotlin.ULong) : ValueType() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : ValueType() + + { + + + companion object + } + + data class Bytes( + val `value`: List) : ValueType() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeValueType : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): ValueType { + return when(buf.getInt()) { + 1 -> ValueType.String( + FfiConverterString.read(buf), + ) + 2 -> ValueType.Int( + FfiConverterLong.read(buf), + ) + 3 -> ValueType.UInt( + FfiConverterULong.read(buf), + ) + 4 -> ValueType.Bool( + FfiConverterBoolean.read(buf), + ) + 5 -> ValueType.Bytes( + FfiConverterSequenceUByte.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: ValueType) = when(value) { + is ValueType.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is ValueType.Int -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is ValueType.UInt -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is ValueType.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is ValueType.Bytes -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + } + + override fun write(value: ValueType, buf: ByteBuffer) { + when(value) { + is ValueType.String -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is ValueType.Int -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is ValueType.UInt -> { + buf.putInt(3) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is ValueType.Bool -> { + buf.putInt(4) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is ValueType.Bytes -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + + +public interface EntityUpdateCallback { + + fun `onUpdate`(`entity`: Entity) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEntityUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEntity.lift(`entity`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEntityUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEntityUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEntityUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEntityUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface EventUpdateCallback { + + fun `onUpdate`(`event`: Event) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEventUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEvent.lift(`event`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEventUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEventUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEventUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEventUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenBalanceUpdateCallback { + + fun `onUpdate`(`balance`: TokenBalance) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenBalanceUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTokenBalance.lift(`balance`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenBalanceUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenBalanceUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenBalanceUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenUpdateCallback { + + fun `onUpdate`(`token`: Token) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeToken.lift(`token`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TransactionUpdateCallback { + + fun `onUpdate`(`transaction`: Transaction) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTransactionUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTransaction.lift(`transaction`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTransactionUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTransactionUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTransactionUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTransactionUpdateCallback: FfiConverterCallbackInterface() + + + + +/** + * @suppress + */ +public object FfiConverterOptionalUInt: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.UInt? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterUInt.read(buf) + } + + override fun allocationSize(value: kotlin.UInt?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterUInt.allocationSize(value) + } + } + + override fun write(value: kotlin.UInt?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterUInt.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalULong: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.ULong? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterULong.read(buf) + } + + override fun allocationSize(value: kotlin.ULong?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterULong.allocationSize(value) + } + } + + override fun write(value: kotlin.ULong?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterULong.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalBoolean: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.Boolean? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterBoolean.read(buf) + } + + override fun allocationSize(value: kotlin.Boolean?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterBoolean.allocationSize(value) + } + } + + override fun write(value: kotlin.Boolean?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterBoolean.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalString: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.String? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterString.read(buf) + } + + override fun allocationSize(value: kotlin.String?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterString.allocationSize(value) + } + } + + override fun write(value: kotlin.String?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterString.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeKeysClause.read(buf) + } + + override fun allocationSize(value: KeysClause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeKeysClause.allocationSize(value) + } + } + + override fun write(value: KeysClause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeKeysClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeTransactionFilter.read(buf) + } + + override fun allocationSize(value: TransactionFilter?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeTransactionFilter.allocationSize(value) + } + } + + override fun write(value: TransactionFilter?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeTransactionFilter.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Clause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeClause.read(buf) + } + + override fun allocationSize(value: Clause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeClause.allocationSize(value) + } + } + + override fun write(value: Clause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeFieldElement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FieldElement? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeFieldElement.read(buf) + } + + override fun allocationSize(value: FieldElement?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeFieldElement.allocationSize(value) + } + } + + override fun write(value: FieldElement?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeFieldElement.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeU256: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): U256? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeU256.read(buf) + } + + override fun allocationSize(value: U256?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeU256.allocationSize(value) + } + } + + override fun write(value: U256?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeU256.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceUByte: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterUByte.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterUByte.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterUByte.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceString: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterString.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterString.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievementTask: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievementTask.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievementTask.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievementTask.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActionCount: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActionCount.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActionCount.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActionCount.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActivity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActivity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActivity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActivity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAggregationEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAggregationEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAggregationEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAggregationEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAttributeFilter: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAttributeFilter.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAttributeFilter.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAttributeFilter.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeController: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeController.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeController.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeController.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEntity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEntity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEntity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEntity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEnumOption: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEnumOption.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEnumOption.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEnumOption.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEvent: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEvent.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEvent.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEvent.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeKeysClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeKeysClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeKeysClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeKeysClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMember: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMember.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMember.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMember.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMessage: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMessage.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMessage.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMessage.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeModel: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeModel.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeModel.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeModel.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeOrderBy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeOrderBy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeOrderBy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeOrderBy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlField: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlField.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlField.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlField.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlRow: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlRow.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlRow.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlRow.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeStruct: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeStruct.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeStruct.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeStruct.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTaskProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTaskProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTaskProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTaskProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeToken: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeToken.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeToken.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeToken.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenBalance: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenBalance.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenBalance.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenBalance.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenTransfer: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenTransfer.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenTransfer.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenTransfer.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransaction: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransaction.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransaction.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransaction.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransactionCall: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransactionCall.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransactionCall.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransactionCall.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeWorld: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeWorld.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeWorld.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeWorld.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContractType: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContractType.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContractType.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContractType.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMemberValue: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMemberValue.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMemberValue.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMemberValue.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceOptionalTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterOptionalTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterOptionalTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterOptionalTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeU256: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeU256.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeU256.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeU256.write(it, buf) + } + } +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias FieldElement = kotlin.String +public typealias FfiConverterTypeFieldElement = FfiConverterString + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias U256 = kotlin.String +public typealias FfiConverterTypeU256 = FfiConverterString + diff --git a/bindings/python/__pycache__/dojo.cpython-313.pyc b/bindings/python/__pycache__/dojo.cpython-313.pyc new file mode 100644 index 0000000..62efdab Binary files /dev/null and b/bindings/python/__pycache__/dojo.cpython-313.pyc differ diff --git a/bindings/python/dojo.py b/bindings/python/dojo.py new file mode 100644 index 0000000..bf62c91 --- /dev/null +++ b/bindings/python/dojo.py @@ -0,0 +1,8810 @@ +# This file was autogenerated by some hot garbage in the `uniffi` crate. +# Trust me, you don't want to mess with it! + +# Common helper code. +# +# Ideally this would live in a separate .py file where it can be unittested etc +# in isolation, and perhaps even published as a re-useable package. +# +# However, it's important that the details of how this helper code works (e.g. the +# way that different builtin types are passed across the FFI) exactly match what's +# expected by the rust code on the other side of the interface. In practice right +# now that means coming from the exact some version of `uniffi` that was used to +# compile the rust component. The easiest way to ensure this is to bundle the Python +# helpers directly inline like we're doing here. + +from __future__ import annotations +import os +import sys +import ctypes +from dataclasses import dataclass +import enum +import struct +import contextlib +import datetime +import threading +import itertools +import traceback +import typing +import platform + + +# Used for default argument values +_DEFAULT = object() # type: typing.Any + + +class _UniffiRustBuffer(ctypes.Structure): + _fields_ = [ + ("capacity", ctypes.c_uint64), + ("len", ctypes.c_uint64), + ("data", ctypes.POINTER(ctypes.c_char)), + ] + + @staticmethod + def default(): + return _UniffiRustBuffer(0, 0, None) + + @staticmethod + def alloc(size): + return _uniffi_rust_call(_UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc, size) + + @staticmethod + def reserve(rbuf, additional): + return _uniffi_rust_call(_UniffiLib.ffi_dojo_uniffi_rustbuffer_reserve, rbuf, additional) + + def free(self): + return _uniffi_rust_call(_UniffiLib.ffi_dojo_uniffi_rustbuffer_free, self) + + def __str__(self): + return "_UniffiRustBuffer(capacity={}, len={}, data={})".format( + self.capacity, + self.len, + self.data[0:self.len] + ) + + @contextlib.contextmanager + def alloc_with_builder(*args): + """Context-manger to allocate a buffer using a _UniffiRustBufferBuilder. + + The allocated buffer will be automatically freed if an error occurs, ensuring that + we don't accidentally leak it. + """ + builder = _UniffiRustBufferBuilder() + try: + yield builder + except: + builder.discard() + raise + + @contextlib.contextmanager + def consume_with_stream(self): + """Context-manager to consume a buffer using a _UniffiRustBufferStream. + + The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't + leak it even if an error occurs. + """ + try: + s = _UniffiRustBufferStream.from_rust_buffer(self) + yield s + if s.remaining() != 0: + raise RuntimeError(f"junk data left in buffer at end of consume_with_stream {s.remaining()}") + finally: + self.free() + + @contextlib.contextmanager + def read_with_stream(self): + """Context-manager to read a buffer using a _UniffiRustBufferStream. + + This is like consume_with_stream, but doesn't free the buffer afterwards. + It should only be used with borrowed `_UniffiRustBuffer` data. + """ + s = _UniffiRustBufferStream.from_rust_buffer(self) + yield s + if s.remaining() != 0: + raise RuntimeError(f"junk data left in buffer at end of read_with_stream {s.remaining()}") + +class _UniffiForeignBytes(ctypes.Structure): + _fields_ = [ + ("len", ctypes.c_int32), + ("data", ctypes.POINTER(ctypes.c_char)), + ] + + def __str__(self): + return "_UniffiForeignBytes(len={}, data={})".format(self.len, self.data[0:self.len]) + + +class _UniffiRustBufferStream: + """ + Helper for structured reading of bytes from a _UniffiRustBuffer + """ + + def __init__(self, data, len): + self.data = data + self.len = len + self.offset = 0 + + @classmethod + def from_rust_buffer(cls, buf): + return cls(buf.data, buf.len) + + def remaining(self): + return self.len - self.offset + + def _unpack_from(self, size, format): + if self.offset + size > self.len: + raise InternalError("read past end of rust buffer") + value = struct.unpack(format, self.data[self.offset:self.offset+size])[0] + self.offset += size + return value + + def read(self, size): + if self.offset + size > self.len: + raise InternalError("read past end of rust buffer") + data = self.data[self.offset:self.offset+size] + self.offset += size + return data + + def read_i8(self): + return self._unpack_from(1, ">b") + + def read_u8(self): + return self._unpack_from(1, ">B") + + def read_i16(self): + return self._unpack_from(2, ">h") + + def read_u16(self): + return self._unpack_from(2, ">H") + + def read_i32(self): + return self._unpack_from(4, ">i") + + def read_u32(self): + return self._unpack_from(4, ">I") + + def read_i64(self): + return self._unpack_from(8, ">q") + + def read_u64(self): + return self._unpack_from(8, ">Q") + + def read_float(self): + v = self._unpack_from(4, ">f") + return v + + def read_double(self): + return self._unpack_from(8, ">d") + +class _UniffiRustBufferBuilder: + """ + Helper for structured writing of bytes into a _UniffiRustBuffer. + """ + + def __init__(self): + self.rbuf = _UniffiRustBuffer.alloc(16) + self.rbuf.len = 0 + + def finalize(self): + rbuf = self.rbuf + self.rbuf = None + return rbuf + + def discard(self): + if self.rbuf is not None: + rbuf = self.finalize() + rbuf.free() + + @contextlib.contextmanager + def _reserve(self, num_bytes): + if self.rbuf.len + num_bytes > self.rbuf.capacity: + self.rbuf = _UniffiRustBuffer.reserve(self.rbuf, num_bytes) + yield None + self.rbuf.len += num_bytes + + def _pack_into(self, size, format, value): + with self._reserve(size): + # XXX TODO: I feel like I should be able to use `struct.pack_into` here but can't figure it out. + for i, byte in enumerate(struct.pack(format, value)): + self.rbuf.data[self.rbuf.len + i] = byte + + def write(self, value): + with self._reserve(len(value)): + for i, byte in enumerate(value): + self.rbuf.data[self.rbuf.len + i] = byte + + def write_i8(self, v): + self._pack_into(1, ">b", v) + + def write_u8(self, v): + self._pack_into(1, ">B", v) + + def write_i16(self, v): + self._pack_into(2, ">h", v) + + def write_u16(self, v): + self._pack_into(2, ">H", v) + + def write_i32(self, v): + self._pack_into(4, ">i", v) + + def write_u32(self, v): + self._pack_into(4, ">I", v) + + def write_i64(self, v): + self._pack_into(8, ">q", v) + + def write_u64(self, v): + self._pack_into(8, ">Q", v) + + def write_float(self, v): + self._pack_into(4, ">f", v) + + def write_double(self, v): + self._pack_into(8, ">d", v) + + def write_c_size_t(self, v): + self._pack_into(ctypes.sizeof(ctypes.c_size_t) , "@N", v) +# A handful of classes and functions to support the generated data structures. +# This would be a good candidate for isolating in its own ffi-support lib. + +class InternalError(Exception): + pass + +class _UniffiRustCallStatus(ctypes.Structure): + """ + Error runtime. + """ + _fields_ = [ + ("code", ctypes.c_int8), + ("error_buf", _UniffiRustBuffer), + ] + + # These match the values from the uniffi::rustcalls module + CALL_SUCCESS = 0 + CALL_ERROR = 1 + CALL_UNEXPECTED_ERROR = 2 + + @staticmethod + def default(): + return _UniffiRustCallStatus(code=_UniffiRustCallStatus.CALL_SUCCESS, error_buf=_UniffiRustBuffer.default()) + + def __str__(self): + if self.code == _UniffiRustCallStatus.CALL_SUCCESS: + return "_UniffiRustCallStatus(CALL_SUCCESS)" + elif self.code == _UniffiRustCallStatus.CALL_ERROR: + return "_UniffiRustCallStatus(CALL_ERROR)" + elif self.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR: + return "_UniffiRustCallStatus(CALL_UNEXPECTED_ERROR)" + else: + return "_UniffiRustCallStatus()" + +def _uniffi_rust_call(fn, *args): + # Call a rust function + return _uniffi_rust_call_with_error(None, fn, *args) + +def _uniffi_rust_call_with_error(error_ffi_converter, fn, *args): + # Call a rust function and handle any errors + # + # This function is used for rust calls that return Result<> and therefore can set the CALL_ERROR status code. + # error_ffi_converter must be set to the _UniffiConverter for the error class that corresponds to the result. + call_status = _UniffiRustCallStatus.default() + + args_with_error = args + (ctypes.byref(call_status),) + result = fn(*args_with_error) + _uniffi_check_call_status(error_ffi_converter, call_status) + return result + +def _uniffi_check_call_status(error_ffi_converter, call_status): + if call_status.code == _UniffiRustCallStatus.CALL_SUCCESS: + pass + elif call_status.code == _UniffiRustCallStatus.CALL_ERROR: + if error_ffi_converter is None: + call_status.error_buf.free() + raise InternalError("_uniffi_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None") + else: + raise error_ffi_converter.lift(call_status.error_buf) + elif call_status.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR: + # When the rust code sees a panic, it tries to construct a _UniffiRustBuffer + # with the message. But if that code panics, then it just sends back + # an empty buffer. + if call_status.error_buf.len > 0: + msg = _UniffiFfiConverterString.lift(call_status.error_buf) + else: + msg = "Unknown rust panic" + raise InternalError(msg) + else: + raise InternalError("Invalid _UniffiRustCallStatus code: {}".format( + call_status.code)) + +def _uniffi_trait_interface_call(call_status, make_call, write_return_value): + try: + return write_return_value(make_call()) + except Exception as e: + call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR + call_status.error_buf = _UniffiFfiConverterString.lower(repr(e)) + +def _uniffi_trait_interface_call_with_error(call_status, make_call, write_return_value, error_type, lower_error): + try: + try: + return write_return_value(make_call()) + except error_type as e: + call_status.code = _UniffiRustCallStatus.CALL_ERROR + call_status.error_buf = lower_error(e) + except Exception as e: + call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR + call_status.error_buf = _UniffiFfiConverterString.lower(repr(e)) +# Initial value and increment amount for handles. +# These ensure that Python-generated handles always have the lowest bit set +_UNIFFI_HANDLEMAP_INITIAL = 1 +_UNIFFI_HANDLEMAP_DELTA = 2 + +class _UniffiHandleMap: + """ + A map where inserting, getting and removing data is synchronized with a lock. + """ + + def __init__(self): + # type Handle = int + self._map = {} # type: Dict[Handle, Any] + self._lock = threading.Lock() + self._counter = _UNIFFI_HANDLEMAP_INITIAL + + def insert(self, obj): + with self._lock: + return self._insert(obj) + + """Low-level insert, this assumes `self._lock` is held.""" + def _insert(self, obj): + handle = self._counter + self._counter += _UNIFFI_HANDLEMAP_DELTA + self._map[handle] = obj + return handle + + def get(self, handle): + try: + with self._lock: + return self._map[handle] + except KeyError: + raise InternalError(f"_UniffiHandleMap.get: Invalid handle {handle}") + + def clone(self, handle): + try: + with self._lock: + obj = self._map[handle] + return self._insert(obj) + except KeyError: + raise InternalError(f"_UniffiHandleMap.clone: Invalid handle {handle}") + + def remove(self, handle): + try: + with self._lock: + return self._map.pop(handle) + except KeyError: + raise InternalError(f"_UniffiHandleMap.remove: Invalid handle: {handle}") + + def __len__(self): + return len(self._map) +# Types conforming to `_UniffiConverterPrimitive` pass themselves directly over the FFI. +class _UniffiConverterPrimitive: + @classmethod + def lift(cls, value): + return value + + @classmethod + def lower(cls, value): + return value + +class _UniffiConverterPrimitiveInt(_UniffiConverterPrimitive): + @classmethod + def check_lower(cls, value): + try: + value = value.__index__() + except Exception: + raise TypeError("'{}' object cannot be interpreted as an integer".format(type(value).__name__)) + if not isinstance(value, int): + raise TypeError("__index__ returned non-int (type {})".format(type(value).__name__)) + if not cls.VALUE_MIN <= value < cls.VALUE_MAX: + raise ValueError("{} requires {} <= value < {}".format(cls.CLASS_NAME, cls.VALUE_MIN, cls.VALUE_MAX)) + +class _UniffiConverterPrimitiveFloat(_UniffiConverterPrimitive): + @classmethod + def check_lower(cls, value): + try: + value = value.__float__() + except Exception: + raise TypeError("must be real number, not {}".format(type(value).__name__)) + if not isinstance(value, float): + raise TypeError("__float__ returned non-float (type {})".format(type(value).__name__)) + +# Helper class for wrapper types that will always go through a _UniffiRustBuffer. +# Classes should inherit from this and implement the `read` and `write` static methods. +class _UniffiConverterRustBuffer: + @classmethod + def lift(cls, rbuf): + with rbuf.consume_with_stream() as stream: + return cls.read(stream) + + @classmethod + def lower(cls, value): + with _UniffiRustBuffer.alloc_with_builder() as builder: + cls.write(value, builder) + return builder.finalize()# Magic number for the Rust proxy to call using the same mechanism as every other method, +# to free the callback once it's dropped by Rust. +_UNIFFI_IDX_CALLBACK_FREE = 0 +# Return codes for callback calls +_UNIFFI_CALLBACK_SUCCESS = 0 +_UNIFFI_CALLBACK_ERROR = 1 +_UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 + +class _UniffiCallbackInterfaceFfiConverter: + _handle_map = _UniffiHandleMap() + + @classmethod + def lift(cls, handle): + return cls._handle_map.get(handle) + + @classmethod + def read(cls, buf): + handle = buf.read_u64() + cls.lift(handle) + + @classmethod + def check_lower(cls, cb): + pass + + @classmethod + def lower(cls, cb): + handle = cls._handle_map.insert(cb) + return handle + + @classmethod + def write(cls, cb, buf): + buf.write_u64(cls.lower(cb)) + +# Contains loading, initialization code, and the FFI Function declarations. +# Define some ctypes FFI types that we use in the library + +""" +Function pointer for a Rust task, which a callback function that takes a opaque pointer +""" +_UNIFFI_RUST_TASK = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int8) + +def _uniffi_future_callback_t(return_type): + """ + Factory function to create callback function types for async functions + """ + return ctypes.CFUNCTYPE(None, ctypes.c_uint64, return_type, _UniffiRustCallStatus) + +def _uniffi_load_indirect(): + """ + This is how we find and load the dynamic library provided by the component. + For now we just look it up by name. + """ + if sys.platform == "darwin": + libname = "lib{}.dylib" + elif sys.platform.startswith("win"): + # As of python3.8, ctypes does not seem to search $PATH when loading DLLs. + # We could use `os.add_dll_directory` to configure the search path, but + # it doesn't feel right to mess with application-wide settings. Let's + # assume that the `.dll` is next to the `.py` file and load by full path. + libname = os.path.join( + os.path.dirname(__file__), + "{}.dll", + ) + else: + # Anything else must be an ELF platform - Linux, *BSD, Solaris/illumos + libname = "lib{}.so" + + libname = libname.format("dojo_uniffi") + path = os.path.join(os.path.dirname(__file__), libname) + lib = ctypes.cdll.LoadLibrary(path) + return lib + +def _uniffi_check_contract_api_version(lib): + # Get the bindings contract version from our ComponentInterface + bindings_contract_version = 30 + # Get the scaffolding contract version by calling the into the dylib + scaffolding_contract_version = lib.ffi_dojo_uniffi_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version: + raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + +def _uniffi_check_api_checksums(lib): + if lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new() != 18057: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config() != 42232: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements() != 43588: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities() != 59928: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations() != 13428: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription() != 28338: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts() != 57071: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers() != 33273: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities() != 32398: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages() != 18258: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements() != 47939: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message() != 64193: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch() != 10937: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql() != 38880: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events() != 49963: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates() != 65064: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates() != 51028: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates() != 40716: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates() != 57382: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates() != 39990: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances() != 8144: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts() != 39069: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers() != 14518: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens() != 45937: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions() != 2466: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds() != 39277: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + +# A ctypes library to expose the extern-C FFI definitions. +# This is an implementation detail which will be called internally by the public API. + +_UniffiLib = _uniffi_load_indirect() +_UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc.restype = _UniffiRustBuffer +_UniffiLib.ffi_dojo_uniffi_rustbuffer_from_bytes.argtypes = ( + _UniffiForeignBytes, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rustbuffer_from_bytes.restype = _UniffiRustBuffer +_UniffiLib.ffi_dojo_uniffi_rustbuffer_free.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rustbuffer_free.restype = None +_UniffiLib.ffi_dojo_uniffi_rustbuffer_reserve.argtypes = ( + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rustbuffer_reserve.restype = _UniffiRustBuffer +_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8, +) +_UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiForeignFutureDroppedCallbackStruct(ctypes.Structure): + _fields_ = [ + ("handle", ctypes.c_uint64), + ("free", _UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK), + ] +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u8.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u8.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u8.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u8.restype = ctypes.c_uint8 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u8.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i8.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i8.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i8.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i8.restype = ctypes.c_int8 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i8.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i8.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u16.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u16.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u16.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u16.restype = ctypes.c_uint16 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u16.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i16.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i16.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i16.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i16.restype = ctypes.c_int16 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i16.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i16.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u32.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u32.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u32.restype = ctypes.c_uint32 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i32.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i32.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i32.restype = ctypes.c_int32 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u64.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_u64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_u64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u64.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_u64.restype = ctypes.c_uint64 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_u64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i64.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_i64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_i64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i64.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_i64.restype = ctypes.c_int64 +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_i64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_f32.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_f32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_f32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_f32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_f32.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_f32.restype = ctypes.c_float +_UniffiLib.ffi_dojo_uniffi_rust_future_free_f32.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_f32.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_f64.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_f64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_f64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_f64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_f64.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_f64.restype = ctypes.c_double +_UniffiLib.ffi_dojo_uniffi_rust_future_free_f64.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_f64.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_rust_buffer.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_rust_buffer.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_rust_buffer.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_rust_buffer.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_rust_buffer.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer +_UniffiLib.ffi_dojo_uniffi_rust_future_free_rust_buffer.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_rust_buffer.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_void.argtypes = ( + ctypes.c_uint64, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_poll_void.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_void.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_cancel_void.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_void.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.ffi_dojo_uniffi_rust_future_complete_void.restype = None +_UniffiLib.ffi_dojo_uniffi_rust_future_free_void.argtypes = ( + ctypes.c_uint64, +) +_UniffiLib.ffi_dojo_uniffi_rust_future_free_void.restype = None +_UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient.argtypes = ( + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient.restype = None +_UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_ENTITY_UPDATE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64, +) +_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_ENTITY_UPDATE_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiVTableCallbackInterfaceDojoEntityUpdateCallback(ctypes.Structure): + _fields_ = [ + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_ENTITY_UPDATE_CALLBACK), + ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_ENTITY_UPDATE_CALLBACK), + ("on_update", _UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD0), + ("on_error", _UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD1), + ] +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceDojoEntityUpdateCallback), +) +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback.restype = None +_UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_EVENT_UPDATE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64, +) +_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_EVENT_UPDATE_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiVTableCallbackInterfaceDojoEventUpdateCallback(ctypes.Structure): + _fields_ = [ + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_EVENT_UPDATE_CALLBACK), + ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_EVENT_UPDATE_CALLBACK), + ("on_update", _UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD0), + ("on_error", _UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD1), + ] +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceDojoEventUpdateCallback), +) +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback.restype = None +_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64, +) +_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiVTableCallbackInterfaceDojoTokenBalanceUpdateCallback(ctypes.Structure): + _fields_ = [ + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK), + ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK), + ("on_update", _UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD0), + ("on_error", _UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD1), + ] +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceDojoTokenBalanceUpdateCallback), +) +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback.restype = None +_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_UPDATE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64, +) +_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_UPDATE_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiVTableCallbackInterfaceDojoTokenUpdateCallback(ctypes.Structure): + _fields_ = [ + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_UPDATE_CALLBACK), + ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_UPDATE_CALLBACK), + ("on_update", _UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD0), + ("on_error", _UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD1), + ] +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceDojoTokenUpdateCallback), +) +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback.restype = None +_UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TRANSACTION_UPDATE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64, +) +_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TRANSACTION_UPDATE_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +) +class _UniffiVTableCallbackInterfaceDojoTransactionUpdateCallback(ctypes.Structure): + _fields_ = [ + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TRANSACTION_UPDATE_CALLBACK), + ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TRANSACTION_UPDATE_CALLBACK), + ("on_update", _UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD0), + ("on_error", _UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD1), + ] +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceDojoTransactionUpdateCallback), +) +_UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback.restype = None +_UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config.argtypes = ( + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription.argtypes = ( + ctypes.c_uint64, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription.restype = None +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates.restype = ctypes.c_uint64 +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions.restype = _UniffiRustBuffer +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds.argtypes = ( + ctypes.c_uint64, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds.restype = _UniffiRustBuffer +_UniffiLib.ffi_dojo_uniffi_uniffi_contract_version.argtypes = ( +) +_UniffiLib.ffi_dojo_uniffi_uniffi_contract_version.restype = ctypes.c_uint32 +_UniffiLib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions.restype = ctypes.c_uint16 +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds.argtypes = ( +) +_UniffiLib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds.restype = ctypes.c_uint16 + +_uniffi_check_contract_api_version(_UniffiLib) +# _uniffi_check_api_checksums(_UniffiLib) + + + +# Public interface members begin here. + + +class _UniffiFfiConverterString: + @staticmethod + def check_lower(value): + if not isinstance(value, str): + raise TypeError("argument must be str, not {}".format(type(value).__name__)) + return value + + @staticmethod + def read(buf): + size = buf.read_i32() + if size < 0: + raise InternalError("Unexpected negative string length") + utf8_bytes = buf.read(size) + return utf8_bytes.decode("utf-8") + + @staticmethod + def write(value, buf): + utf8_bytes = value.encode("utf-8") + buf.write_i32(len(utf8_bytes)) + buf.write(utf8_bytes) + + @staticmethod + def lift(buf): + with buf.consume_with_stream() as stream: + return stream.read(stream.remaining()).decode("utf-8") + + @staticmethod + def lower(value): + with _UniffiRustBuffer.alloc_with_builder() as builder: + builder.write(value.encode("utf-8")) + return builder.finalize() + + +class _UniffiFfiConverterTypeFieldElement: + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value, buf) + + @staticmethod + def read(buf): + return _UniffiFfiConverterString.read(buf) + + @staticmethod + def lift(value): + return _UniffiFfiConverterString.lift(value) + + @staticmethod + def check_lower(value): + return _UniffiFfiConverterString.check_lower(value) + + @staticmethod + def lower(value): + return _UniffiFfiConverterString.lower(value) + + +FieldElement = str + +class _UniffiFfiConverterBoolean: + @classmethod + def check_lower(cls, value): + return not not value + + @classmethod + def lower(cls, value): + return 1 if value else 0 + + @staticmethod + def lift(value): + return value != 0 + + @classmethod + def read(cls, buf): + return cls.lift(buf.read_u8()) + + @classmethod + def write(cls, value, buf): + buf.write_u8(value) + +class _UniffiFfiConverterUInt32(_UniffiConverterPrimitiveInt): + CLASS_NAME = "u32" + VALUE_MIN = 0 + VALUE_MAX = 2**32 + + @staticmethod + def read(buf): + return buf.read_u32() + + @staticmethod + def write(value, buf): + buf.write_u32(value) + +class _UniffiFfiConverterFloat64(_UniffiConverterPrimitiveFloat): + @staticmethod + def read(buf): + return buf.read_double() + + @staticmethod + def write(value, buf): + buf.write_double(value) + +class _UniffiFfiConverterUInt64(_UniffiConverterPrimitiveInt): + CLASS_NAME = "u64" + VALUE_MIN = 0 + VALUE_MAX = 2**64 + + @staticmethod + def read(buf): + return buf.read_u64() + + @staticmethod + def write(value, buf): + buf.write_u64(value) + +@dataclass +class AchievementTask: + def __init__(self, *, task_id:str, description:str, total:int, total_completions:int, completion_rate:float, created_at:int): + self.task_id = task_id + self.description = description + self.total = total + self.total_completions = total_completions + self.completion_rate = completion_rate + self.created_at = created_at + + + + + def __str__(self): + return "AchievementTask(task_id={}, description={}, total={}, total_completions={}, completion_rate={}, created_at={})".format(self.task_id, self.description, self.total, self.total_completions, self.completion_rate, self.created_at) + def __eq__(self, other): + if self.task_id != other.task_id: + return False + if self.description != other.description: + return False + if self.total != other.total: + return False + if self.total_completions != other.total_completions: + return False + if self.completion_rate != other.completion_rate: + return False + if self.created_at != other.created_at: + return False + return True + +class _UniffiFfiConverterTypeAchievementTask(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AchievementTask( + task_id=_UniffiFfiConverterString.read(buf), + description=_UniffiFfiConverterString.read(buf), + total=_UniffiFfiConverterUInt32.read(buf), + total_completions=_UniffiFfiConverterUInt32.read(buf), + completion_rate=_UniffiFfiConverterFloat64.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.task_id) + _UniffiFfiConverterString.check_lower(value.description) + _UniffiFfiConverterUInt32.check_lower(value.total) + _UniffiFfiConverterUInt32.check_lower(value.total_completions) + _UniffiFfiConverterFloat64.check_lower(value.completion_rate) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.task_id, buf) + _UniffiFfiConverterString.write(value.description, buf) + _UniffiFfiConverterUInt32.write(value.total, buf) + _UniffiFfiConverterUInt32.write(value.total_completions, buf) + _UniffiFfiConverterFloat64.write(value.completion_rate, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + +class _UniffiFfiConverterSequenceTypeAchievementTask(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeAchievementTask.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeAchievementTask.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeAchievementTask.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterOptionalString(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterString.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterString.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterString.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class Achievement: + def __init__(self, *, id:str, world_address:FieldElement, namespace:str, entity_id:str, hidden:bool, index:int, points:int, start:str, end:str, group:str, icon:str, title:str, description:str, tasks:typing.List[AchievementTask], data:typing.Optional[str], total_completions:int, completion_rate:float, created_at:int, updated_at:int): + self.id = id + self.world_address = world_address + self.namespace = namespace + self.entity_id = entity_id + self.hidden = hidden + self.index = index + self.points = points + self.start = start + self.end = end + self.group = group + self.icon = icon + self.title = title + self.description = description + self.tasks = tasks + self.data = data + self.total_completions = total_completions + self.completion_rate = completion_rate + self.created_at = created_at + self.updated_at = updated_at + + + + + def __str__(self): + return "Achievement(id={}, world_address={}, namespace={}, entity_id={}, hidden={}, index={}, points={}, start={}, end={}, group={}, icon={}, title={}, description={}, tasks={}, data={}, total_completions={}, completion_rate={}, created_at={}, updated_at={})".format(self.id, self.world_address, self.namespace, self.entity_id, self.hidden, self.index, self.points, self.start, self.end, self.group, self.icon, self.title, self.description, self.tasks, self.data, self.total_completions, self.completion_rate, self.created_at, self.updated_at) + def __eq__(self, other): + if self.id != other.id: + return False + if self.world_address != other.world_address: + return False + if self.namespace != other.namespace: + return False + if self.entity_id != other.entity_id: + return False + if self.hidden != other.hidden: + return False + if self.index != other.index: + return False + if self.points != other.points: + return False + if self.start != other.start: + return False + if self.end != other.end: + return False + if self.group != other.group: + return False + if self.icon != other.icon: + return False + if self.title != other.title: + return False + if self.description != other.description: + return False + if self.tasks != other.tasks: + return False + if self.data != other.data: + return False + if self.total_completions != other.total_completions: + return False + if self.completion_rate != other.completion_rate: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + return True + +class _UniffiFfiConverterTypeAchievement(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Achievement( + id=_UniffiFfiConverterString.read(buf), + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + namespace=_UniffiFfiConverterString.read(buf), + entity_id=_UniffiFfiConverterString.read(buf), + hidden=_UniffiFfiConverterBoolean.read(buf), + index=_UniffiFfiConverterUInt32.read(buf), + points=_UniffiFfiConverterUInt32.read(buf), + start=_UniffiFfiConverterString.read(buf), + end=_UniffiFfiConverterString.read(buf), + group=_UniffiFfiConverterString.read(buf), + icon=_UniffiFfiConverterString.read(buf), + title=_UniffiFfiConverterString.read(buf), + description=_UniffiFfiConverterString.read(buf), + tasks=_UniffiFfiConverterSequenceTypeAchievementTask.read(buf), + data=_UniffiFfiConverterOptionalString.read(buf), + total_completions=_UniffiFfiConverterUInt32.read(buf), + completion_rate=_UniffiFfiConverterFloat64.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.id) + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterString.check_lower(value.namespace) + _UniffiFfiConverterString.check_lower(value.entity_id) + _UniffiFfiConverterBoolean.check_lower(value.hidden) + _UniffiFfiConverterUInt32.check_lower(value.index) + _UniffiFfiConverterUInt32.check_lower(value.points) + _UniffiFfiConverterString.check_lower(value.start) + _UniffiFfiConverterString.check_lower(value.end) + _UniffiFfiConverterString.check_lower(value.group) + _UniffiFfiConverterString.check_lower(value.icon) + _UniffiFfiConverterString.check_lower(value.title) + _UniffiFfiConverterString.check_lower(value.description) + _UniffiFfiConverterSequenceTypeAchievementTask.check_lower(value.tasks) + _UniffiFfiConverterOptionalString.check_lower(value.data) + _UniffiFfiConverterUInt32.check_lower(value.total_completions) + _UniffiFfiConverterFloat64.check_lower(value.completion_rate) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.id, buf) + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterString.write(value.namespace, buf) + _UniffiFfiConverterString.write(value.entity_id, buf) + _UniffiFfiConverterBoolean.write(value.hidden, buf) + _UniffiFfiConverterUInt32.write(value.index, buf) + _UniffiFfiConverterUInt32.write(value.points, buf) + _UniffiFfiConverterString.write(value.start, buf) + _UniffiFfiConverterString.write(value.end, buf) + _UniffiFfiConverterString.write(value.group, buf) + _UniffiFfiConverterString.write(value.icon, buf) + _UniffiFfiConverterString.write(value.title, buf) + _UniffiFfiConverterString.write(value.description, buf) + _UniffiFfiConverterSequenceTypeAchievementTask.write(value.tasks, buf) + _UniffiFfiConverterOptionalString.write(value.data, buf) + _UniffiFfiConverterUInt32.write(value.total_completions, buf) + _UniffiFfiConverterFloat64.write(value.completion_rate, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + +class _UniffiFfiConverterOptionalUInt64(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterUInt64.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterUInt64.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterUInt64.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class AchievementProgression: + def __init__(self, *, id:str, achievement_id:str, task_id:str, world_address:FieldElement, namespace:str, player_id:FieldElement, count:int, completed:bool, completed_at:typing.Optional[int], created_at:int, updated_at:int): + self.id = id + self.achievement_id = achievement_id + self.task_id = task_id + self.world_address = world_address + self.namespace = namespace + self.player_id = player_id + self.count = count + self.completed = completed + self.completed_at = completed_at + self.created_at = created_at + self.updated_at = updated_at + + + + + def __str__(self): + return "AchievementProgression(id={}, achievement_id={}, task_id={}, world_address={}, namespace={}, player_id={}, count={}, completed={}, completed_at={}, created_at={}, updated_at={})".format(self.id, self.achievement_id, self.task_id, self.world_address, self.namespace, self.player_id, self.count, self.completed, self.completed_at, self.created_at, self.updated_at) + def __eq__(self, other): + if self.id != other.id: + return False + if self.achievement_id != other.achievement_id: + return False + if self.task_id != other.task_id: + return False + if self.world_address != other.world_address: + return False + if self.namespace != other.namespace: + return False + if self.player_id != other.player_id: + return False + if self.count != other.count: + return False + if self.completed != other.completed: + return False + if self.completed_at != other.completed_at: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + return True + +class _UniffiFfiConverterTypeAchievementProgression(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AchievementProgression( + id=_UniffiFfiConverterString.read(buf), + achievement_id=_UniffiFfiConverterString.read(buf), + task_id=_UniffiFfiConverterString.read(buf), + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + namespace=_UniffiFfiConverterString.read(buf), + player_id=_UniffiFfiConverterTypeFieldElement.read(buf), + count=_UniffiFfiConverterUInt32.read(buf), + completed=_UniffiFfiConverterBoolean.read(buf), + completed_at=_UniffiFfiConverterOptionalUInt64.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.id) + _UniffiFfiConverterString.check_lower(value.achievement_id) + _UniffiFfiConverterString.check_lower(value.task_id) + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterString.check_lower(value.namespace) + _UniffiFfiConverterTypeFieldElement.check_lower(value.player_id) + _UniffiFfiConverterUInt32.check_lower(value.count) + _UniffiFfiConverterBoolean.check_lower(value.completed) + _UniffiFfiConverterOptionalUInt64.check_lower(value.completed_at) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.id, buf) + _UniffiFfiConverterString.write(value.achievement_id, buf) + _UniffiFfiConverterString.write(value.task_id, buf) + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterString.write(value.namespace, buf) + _UniffiFfiConverterTypeFieldElement.write(value.player_id, buf) + _UniffiFfiConverterUInt32.write(value.count, buf) + _UniffiFfiConverterBoolean.write(value.completed, buf) + _UniffiFfiConverterOptionalUInt64.write(value.completed_at, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + +class _UniffiFfiConverterSequenceTypeFieldElement(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeFieldElement.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeFieldElement.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeFieldElement.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterSequenceString(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterString.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterString.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterString.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterOptionalBoolean(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterBoolean.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterBoolean.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterBoolean.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +class _UniffiFfiConverterOptionalUInt32(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterUInt32.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterUInt32.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterUInt32.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + + + + +class PaginationDirection(enum.Enum): + + FORWARD = 0 + + BACKWARD = 1 + + + +class _UniffiFfiConverterTypePaginationDirection(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return PaginationDirection.FORWARD + if variant == 2: + return PaginationDirection.BACKWARD + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == PaginationDirection.FORWARD: + return + if value == PaginationDirection.BACKWARD: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == PaginationDirection.FORWARD: + buf.write_i32(1) + if value == PaginationDirection.BACKWARD: + buf.write_i32(2) + + + + + + + + +class OrderDirection(enum.Enum): + + ASC = 0 + + DESC = 1 + + + +class _UniffiFfiConverterTypeOrderDirection(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return OrderDirection.ASC + if variant == 2: + return OrderDirection.DESC + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == OrderDirection.ASC: + return + if value == OrderDirection.DESC: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == OrderDirection.ASC: + buf.write_i32(1) + if value == OrderDirection.DESC: + buf.write_i32(2) + + + +@dataclass +class OrderBy: + def __init__(self, *, field:str, direction:OrderDirection): + self.field = field + self.direction = direction + + + + + def __str__(self): + return "OrderBy(field={}, direction={})".format(self.field, self.direction) + def __eq__(self, other): + if self.field != other.field: + return False + if self.direction != other.direction: + return False + return True + +class _UniffiFfiConverterTypeOrderBy(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return OrderBy( + field=_UniffiFfiConverterString.read(buf), + direction=_UniffiFfiConverterTypeOrderDirection.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.field) + _UniffiFfiConverterTypeOrderDirection.check_lower(value.direction) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.field, buf) + _UniffiFfiConverterTypeOrderDirection.write(value.direction, buf) + +class _UniffiFfiConverterSequenceTypeOrderBy(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeOrderBy.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeOrderBy.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeOrderBy.read(buf) for i in range(count) + ] + +@dataclass +class Pagination: + def __init__(self, *, cursor:typing.Optional[str], limit:typing.Optional[int], direction:PaginationDirection, order_by:typing.List[OrderBy]): + self.cursor = cursor + self.limit = limit + self.direction = direction + self.order_by = order_by + + + + + def __str__(self): + return "Pagination(cursor={}, limit={}, direction={}, order_by={})".format(self.cursor, self.limit, self.direction, self.order_by) + def __eq__(self, other): + if self.cursor != other.cursor: + return False + if self.limit != other.limit: + return False + if self.direction != other.direction: + return False + if self.order_by != other.order_by: + return False + return True + +class _UniffiFfiConverterTypePagination(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Pagination( + cursor=_UniffiFfiConverterOptionalString.read(buf), + limit=_UniffiFfiConverterOptionalUInt32.read(buf), + direction=_UniffiFfiConverterTypePaginationDirection.read(buf), + order_by=_UniffiFfiConverterSequenceTypeOrderBy.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterOptionalString.check_lower(value.cursor) + _UniffiFfiConverterOptionalUInt32.check_lower(value.limit) + _UniffiFfiConverterTypePaginationDirection.check_lower(value.direction) + _UniffiFfiConverterSequenceTypeOrderBy.check_lower(value.order_by) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterOptionalString.write(value.cursor, buf) + _UniffiFfiConverterOptionalUInt32.write(value.limit, buf) + _UniffiFfiConverterTypePaginationDirection.write(value.direction, buf) + _UniffiFfiConverterSequenceTypeOrderBy.write(value.order_by, buf) + +@dataclass +class AchievementQuery: + def __init__(self, *, world_addresses:typing.List[FieldElement], namespaces:typing.List[str], hidden:typing.Optional[bool], pagination:Pagination): + self.world_addresses = world_addresses + self.namespaces = namespaces + self.hidden = hidden + self.pagination = pagination + + + + + def __str__(self): + return "AchievementQuery(world_addresses={}, namespaces={}, hidden={}, pagination={})".format(self.world_addresses, self.namespaces, self.hidden, self.pagination) + def __eq__(self, other): + if self.world_addresses != other.world_addresses: + return False + if self.namespaces != other.namespaces: + return False + if self.hidden != other.hidden: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeAchievementQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AchievementQuery( + world_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + namespaces=_UniffiFfiConverterSequenceString.read(buf), + hidden=_UniffiFfiConverterOptionalBoolean.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.world_addresses) + _UniffiFfiConverterSequenceString.check_lower(value.namespaces) + _UniffiFfiConverterOptionalBoolean.check_lower(value.hidden) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.world_addresses, buf) + _UniffiFfiConverterSequenceString.write(value.namespaces, buf) + _UniffiFfiConverterOptionalBoolean.write(value.hidden, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class ActionCount: + def __init__(self, *, action_name:str, count:int): + self.action_name = action_name + self.count = count + + + + + def __str__(self): + return "ActionCount(action_name={}, count={})".format(self.action_name, self.count) + def __eq__(self, other): + if self.action_name != other.action_name: + return False + if self.count != other.count: + return False + return True + +class _UniffiFfiConverterTypeActionCount(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ActionCount( + action_name=_UniffiFfiConverterString.read(buf), + count=_UniffiFfiConverterUInt32.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.action_name) + _UniffiFfiConverterUInt32.check_lower(value.count) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.action_name, buf) + _UniffiFfiConverterUInt32.write(value.count, buf) + +class _UniffiFfiConverterSequenceTypeActionCount(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeActionCount.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeActionCount.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeActionCount.read(buf) for i in range(count) + ] + +@dataclass +class Activity: + def __init__(self, *, id:str, world_address:FieldElement, namespace:str, caller_address:FieldElement, session_start:int, session_end:int, action_count:int, actions:typing.List[ActionCount], updated_at:int): + self.id = id + self.world_address = world_address + self.namespace = namespace + self.caller_address = caller_address + self.session_start = session_start + self.session_end = session_end + self.action_count = action_count + self.actions = actions + self.updated_at = updated_at + + + + + def __str__(self): + return "Activity(id={}, world_address={}, namespace={}, caller_address={}, session_start={}, session_end={}, action_count={}, actions={}, updated_at={})".format(self.id, self.world_address, self.namespace, self.caller_address, self.session_start, self.session_end, self.action_count, self.actions, self.updated_at) + def __eq__(self, other): + if self.id != other.id: + return False + if self.world_address != other.world_address: + return False + if self.namespace != other.namespace: + return False + if self.caller_address != other.caller_address: + return False + if self.session_start != other.session_start: + return False + if self.session_end != other.session_end: + return False + if self.action_count != other.action_count: + return False + if self.actions != other.actions: + return False + if self.updated_at != other.updated_at: + return False + return True + +class _UniffiFfiConverterTypeActivity(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Activity( + id=_UniffiFfiConverterString.read(buf), + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + namespace=_UniffiFfiConverterString.read(buf), + caller_address=_UniffiFfiConverterTypeFieldElement.read(buf), + session_start=_UniffiFfiConverterUInt64.read(buf), + session_end=_UniffiFfiConverterUInt64.read(buf), + action_count=_UniffiFfiConverterUInt32.read(buf), + actions=_UniffiFfiConverterSequenceTypeActionCount.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.id) + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterString.check_lower(value.namespace) + _UniffiFfiConverterTypeFieldElement.check_lower(value.caller_address) + _UniffiFfiConverterUInt64.check_lower(value.session_start) + _UniffiFfiConverterUInt64.check_lower(value.session_end) + _UniffiFfiConverterUInt32.check_lower(value.action_count) + _UniffiFfiConverterSequenceTypeActionCount.check_lower(value.actions) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.id, buf) + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterString.write(value.namespace, buf) + _UniffiFfiConverterTypeFieldElement.write(value.caller_address, buf) + _UniffiFfiConverterUInt64.write(value.session_start, buf) + _UniffiFfiConverterUInt64.write(value.session_end, buf) + _UniffiFfiConverterUInt32.write(value.action_count, buf) + _UniffiFfiConverterSequenceTypeActionCount.write(value.actions, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + +@dataclass +class ActivityQuery: + def __init__(self, *, world_addresses:typing.List[FieldElement], namespaces:typing.List[str], caller_addresses:typing.List[FieldElement], from_time:typing.Optional[int], to_time:typing.Optional[int], pagination:Pagination): + self.world_addresses = world_addresses + self.namespaces = namespaces + self.caller_addresses = caller_addresses + self.from_time = from_time + self.to_time = to_time + self.pagination = pagination + + + + + def __str__(self): + return "ActivityQuery(world_addresses={}, namespaces={}, caller_addresses={}, from_time={}, to_time={}, pagination={})".format(self.world_addresses, self.namespaces, self.caller_addresses, self.from_time, self.to_time, self.pagination) + def __eq__(self, other): + if self.world_addresses != other.world_addresses: + return False + if self.namespaces != other.namespaces: + return False + if self.caller_addresses != other.caller_addresses: + return False + if self.from_time != other.from_time: + return False + if self.to_time != other.to_time: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeActivityQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ActivityQuery( + world_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + namespaces=_UniffiFfiConverterSequenceString.read(buf), + caller_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + from_time=_UniffiFfiConverterOptionalUInt64.read(buf), + to_time=_UniffiFfiConverterOptionalUInt64.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.world_addresses) + _UniffiFfiConverterSequenceString.check_lower(value.namespaces) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.caller_addresses) + _UniffiFfiConverterOptionalUInt64.check_lower(value.from_time) + _UniffiFfiConverterOptionalUInt64.check_lower(value.to_time) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.world_addresses, buf) + _UniffiFfiConverterSequenceString.write(value.namespaces, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.caller_addresses, buf) + _UniffiFfiConverterOptionalUInt64.write(value.from_time, buf) + _UniffiFfiConverterOptionalUInt64.write(value.to_time, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + + +class _UniffiFfiConverterTypeU256: + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value, buf) + + @staticmethod + def read(buf): + return _UniffiFfiConverterString.read(buf) + + @staticmethod + def lift(value): + return _UniffiFfiConverterString.lift(value) + + @staticmethod + def check_lower(value): + return _UniffiFfiConverterString.check_lower(value) + + @staticmethod + def lower(value): + return _UniffiFfiConverterString.lower(value) + + +U256 = str + +@dataclass +class AggregationEntry: + def __init__(self, *, id:str, aggregator_id:str, entity_id:str, value:U256, display_value:str, position:int, model_id:str, created_at:int, updated_at:int): + self.id = id + self.aggregator_id = aggregator_id + self.entity_id = entity_id + self.value = value + self.display_value = display_value + self.position = position + self.model_id = model_id + self.created_at = created_at + self.updated_at = updated_at + + + + + def __str__(self): + return "AggregationEntry(id={}, aggregator_id={}, entity_id={}, value={}, display_value={}, position={}, model_id={}, created_at={}, updated_at={})".format(self.id, self.aggregator_id, self.entity_id, self.value, self.display_value, self.position, self.model_id, self.created_at, self.updated_at) + def __eq__(self, other): + if self.id != other.id: + return False + if self.aggregator_id != other.aggregator_id: + return False + if self.entity_id != other.entity_id: + return False + if self.value != other.value: + return False + if self.display_value != other.display_value: + return False + if self.position != other.position: + return False + if self.model_id != other.model_id: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + return True + +class _UniffiFfiConverterTypeAggregationEntry(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AggregationEntry( + id=_UniffiFfiConverterString.read(buf), + aggregator_id=_UniffiFfiConverterString.read(buf), + entity_id=_UniffiFfiConverterString.read(buf), + value=_UniffiFfiConverterTypeU256.read(buf), + display_value=_UniffiFfiConverterString.read(buf), + position=_UniffiFfiConverterUInt64.read(buf), + model_id=_UniffiFfiConverterString.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.id) + _UniffiFfiConverterString.check_lower(value.aggregator_id) + _UniffiFfiConverterString.check_lower(value.entity_id) + _UniffiFfiConverterTypeU256.check_lower(value.value) + _UniffiFfiConverterString.check_lower(value.display_value) + _UniffiFfiConverterUInt64.check_lower(value.position) + _UniffiFfiConverterString.check_lower(value.model_id) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.id, buf) + _UniffiFfiConverterString.write(value.aggregator_id, buf) + _UniffiFfiConverterString.write(value.entity_id, buf) + _UniffiFfiConverterTypeU256.write(value.value, buf) + _UniffiFfiConverterString.write(value.display_value, buf) + _UniffiFfiConverterUInt64.write(value.position, buf) + _UniffiFfiConverterString.write(value.model_id, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + +@dataclass +class AggregationQuery: + def __init__(self, *, aggregator_ids:typing.List[str], entity_ids:typing.List[str], pagination:Pagination): + self.aggregator_ids = aggregator_ids + self.entity_ids = entity_ids + self.pagination = pagination + + + + + def __str__(self): + return "AggregationQuery(aggregator_ids={}, entity_ids={}, pagination={})".format(self.aggregator_ids, self.entity_ids, self.pagination) + def __eq__(self, other): + if self.aggregator_ids != other.aggregator_ids: + return False + if self.entity_ids != other.entity_ids: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeAggregationQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AggregationQuery( + aggregator_ids=_UniffiFfiConverterSequenceString.read(buf), + entity_ids=_UniffiFfiConverterSequenceString.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceString.check_lower(value.aggregator_ids) + _UniffiFfiConverterSequenceString.check_lower(value.entity_ids) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceString.write(value.aggregator_ids, buf) + _UniffiFfiConverterSequenceString.write(value.entity_ids, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class AttributeFilter: + def __init__(self, *, trait_name:str, trait_value:str): + self.trait_name = trait_name + self.trait_value = trait_value + + + + + def __str__(self): + return "AttributeFilter(trait_name={}, trait_value={})".format(self.trait_name, self.trait_value) + def __eq__(self, other): + if self.trait_name != other.trait_name: + return False + if self.trait_value != other.trait_value: + return False + return True + +class _UniffiFfiConverterTypeAttributeFilter(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return AttributeFilter( + trait_name=_UniffiFfiConverterString.read(buf), + trait_value=_UniffiFfiConverterString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.trait_name) + _UniffiFfiConverterString.check_lower(value.trait_value) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.trait_name, buf) + _UniffiFfiConverterString.write(value.trait_value, buf) + + + + + + +class LogicalOperator(enum.Enum): + + AND = 0 + + OR = 1 + + + +class _UniffiFfiConverterTypeLogicalOperator(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return LogicalOperator.AND + if variant == 2: + return LogicalOperator.OR + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == LogicalOperator.AND: + return + if value == LogicalOperator.OR: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == LogicalOperator.AND: + buf.write_i32(1) + if value == LogicalOperator.OR: + buf.write_i32(2) + + + +class _UniffiFfiConverterOptionalTypeFieldElement(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterTypeFieldElement.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterTypeFieldElement.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterTypeFieldElement.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +class _UniffiFfiConverterSequenceOptionalTypeFieldElement(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterOptionalTypeFieldElement.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterOptionalTypeFieldElement.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterOptionalTypeFieldElement.read(buf) for i in range(count) + ] + + + + + + +class PatternMatching(enum.Enum): + + FIXED_LEN = 0 + + VARIABLE_LEN = 1 + + + +class _UniffiFfiConverterTypePatternMatching(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return PatternMatching.FIXED_LEN + if variant == 2: + return PatternMatching.VARIABLE_LEN + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == PatternMatching.FIXED_LEN: + return + if value == PatternMatching.VARIABLE_LEN: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == PatternMatching.FIXED_LEN: + buf.write_i32(1) + if value == PatternMatching.VARIABLE_LEN: + buf.write_i32(2) + + + +@dataclass +class KeysClause: + def __init__(self, *, keys:typing.List[typing.Optional[FieldElement]], pattern_matching:PatternMatching, models:typing.List[str]): + self.keys = keys + self.pattern_matching = pattern_matching + self.models = models + + + + + def __str__(self): + return "KeysClause(keys={}, pattern_matching={}, models={})".format(self.keys, self.pattern_matching, self.models) + def __eq__(self, other): + if self.keys != other.keys: + return False + if self.pattern_matching != other.pattern_matching: + return False + if self.models != other.models: + return False + return True + +class _UniffiFfiConverterTypeKeysClause(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return KeysClause( + keys=_UniffiFfiConverterSequenceOptionalTypeFieldElement.read(buf), + pattern_matching=_UniffiFfiConverterTypePatternMatching.read(buf), + models=_UniffiFfiConverterSequenceString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceOptionalTypeFieldElement.check_lower(value.keys) + _UniffiFfiConverterTypePatternMatching.check_lower(value.pattern_matching) + _UniffiFfiConverterSequenceString.check_lower(value.models) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceOptionalTypeFieldElement.write(value.keys, buf) + _UniffiFfiConverterTypePatternMatching.write(value.pattern_matching, buf) + _UniffiFfiConverterSequenceString.write(value.models, buf) + + + + + + +class ComparisonOperator(enum.Enum): + + EQ = 0 + + NEQ = 1 + + GT = 2 + + GTE = 3 + + LT = 4 + + LTE = 5 + + IN = 6 + + NOT_IN = 7 + + CONTAINS = 8 + + CONTAINS_ALL = 9 + + CONTAINS_ANY = 10 + + ARRAY_LENGTH_EQ = 11 + + ARRAY_LENGTH_GT = 12 + + ARRAY_LENGTH_LT = 13 + + + +class _UniffiFfiConverterTypeComparisonOperator(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return ComparisonOperator.EQ + if variant == 2: + return ComparisonOperator.NEQ + if variant == 3: + return ComparisonOperator.GT + if variant == 4: + return ComparisonOperator.GTE + if variant == 5: + return ComparisonOperator.LT + if variant == 6: + return ComparisonOperator.LTE + if variant == 7: + return ComparisonOperator.IN + if variant == 8: + return ComparisonOperator.NOT_IN + if variant == 9: + return ComparisonOperator.CONTAINS + if variant == 10: + return ComparisonOperator.CONTAINS_ALL + if variant == 11: + return ComparisonOperator.CONTAINS_ANY + if variant == 12: + return ComparisonOperator.ARRAY_LENGTH_EQ + if variant == 13: + return ComparisonOperator.ARRAY_LENGTH_GT + if variant == 14: + return ComparisonOperator.ARRAY_LENGTH_LT + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == ComparisonOperator.EQ: + return + if value == ComparisonOperator.NEQ: + return + if value == ComparisonOperator.GT: + return + if value == ComparisonOperator.GTE: + return + if value == ComparisonOperator.LT: + return + if value == ComparisonOperator.LTE: + return + if value == ComparisonOperator.IN: + return + if value == ComparisonOperator.NOT_IN: + return + if value == ComparisonOperator.CONTAINS: + return + if value == ComparisonOperator.CONTAINS_ALL: + return + if value == ComparisonOperator.CONTAINS_ANY: + return + if value == ComparisonOperator.ARRAY_LENGTH_EQ: + return + if value == ComparisonOperator.ARRAY_LENGTH_GT: + return + if value == ComparisonOperator.ARRAY_LENGTH_LT: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == ComparisonOperator.EQ: + buf.write_i32(1) + if value == ComparisonOperator.NEQ: + buf.write_i32(2) + if value == ComparisonOperator.GT: + buf.write_i32(3) + if value == ComparisonOperator.GTE: + buf.write_i32(4) + if value == ComparisonOperator.LT: + buf.write_i32(5) + if value == ComparisonOperator.LTE: + buf.write_i32(6) + if value == ComparisonOperator.IN: + buf.write_i32(7) + if value == ComparisonOperator.NOT_IN: + buf.write_i32(8) + if value == ComparisonOperator.CONTAINS: + buf.write_i32(9) + if value == ComparisonOperator.CONTAINS_ALL: + buf.write_i32(10) + if value == ComparisonOperator.CONTAINS_ANY: + buf.write_i32(11) + if value == ComparisonOperator.ARRAY_LENGTH_EQ: + buf.write_i32(12) + if value == ComparisonOperator.ARRAY_LENGTH_GT: + buf.write_i32(13) + if value == ComparisonOperator.ARRAY_LENGTH_LT: + buf.write_i32(14) + + + +class _UniffiFfiConverterInt8(_UniffiConverterPrimitiveInt): + CLASS_NAME = "i8" + VALUE_MIN = -2**7 + VALUE_MAX = 2**7 + + @staticmethod + def read(buf): + return buf.read_i8() + + @staticmethod + def write(value, buf): + buf.write_i8(value) + +class _UniffiFfiConverterInt16(_UniffiConverterPrimitiveInt): + CLASS_NAME = "i16" + VALUE_MIN = -2**15 + VALUE_MAX = 2**15 + + @staticmethod + def read(buf): + return buf.read_i16() + + @staticmethod + def write(value, buf): + buf.write_i16(value) + +class _UniffiFfiConverterInt32(_UniffiConverterPrimitiveInt): + CLASS_NAME = "i32" + VALUE_MIN = -2**31 + VALUE_MAX = 2**31 + + @staticmethod + def read(buf): + return buf.read_i32() + + @staticmethod + def write(value, buf): + buf.write_i32(value) + +class _UniffiFfiConverterInt64(_UniffiConverterPrimitiveInt): + CLASS_NAME = "i64" + VALUE_MIN = -2**63 + VALUE_MAX = 2**63 + + @staticmethod + def read(buf): + return buf.read_i64() + + @staticmethod + def write(value, buf): + buf.write_i64(value) + +class _UniffiFfiConverterUInt8(_UniffiConverterPrimitiveInt): + CLASS_NAME = "u8" + VALUE_MIN = 0 + VALUE_MAX = 2**8 + + @staticmethod + def read(buf): + return buf.read_u8() + + @staticmethod + def write(value, buf): + buf.write_u8(value) + +class _UniffiFfiConverterSequenceUInt8(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterUInt8.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterUInt8.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterUInt8.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterUInt16(_UniffiConverterPrimitiveInt): + CLASS_NAME = "u16" + VALUE_MIN = 0 + VALUE_MAX = 2**16 + + @staticmethod + def read(buf): + return buf.read_u16() + + @staticmethod + def write(value, buf): + buf.write_u16(value) + + + + + + +class Primitive: + def __init__(self): + raise RuntimeError("Primitive cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class I8: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.I8(value={})".format(self.value) + def __eq__(self, other): + if not other.is_I8(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class I16: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.I16(value={})".format(self.value) + def __eq__(self, other): + if not other.is_I16(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class I32: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.I32(value={})".format(self.value) + def __eq__(self, other): + if not other.is_I32(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class I64: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.I64(value={})".format(self.value) + def __eq__(self, other): + if not other.is_I64(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class I128: + + def __init__(self, value:typing.List[int]): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.I128(value={})".format(self.value) + def __eq__(self, other): + if not other.is_I128(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U8: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U8(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U8(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U16: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U16(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U16(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U32: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U32(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U32(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U64: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U64(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U64(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U128: + + def __init__(self, value:typing.List[int]): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U128(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U128(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U256: + + def __init__(self, value:U256): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.U256(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U256(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class BOOL: + + def __init__(self, value:bool): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.BOOL(value={})".format(self.value) + def __eq__(self, other): + if not other.is_BOOL(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class FELT252: + + def __init__(self, value:FieldElement): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.FELT252(value={})".format(self.value) + def __eq__(self, other): + if not other.is_FELT252(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class CLASS_HASH: + + def __init__(self, value:FieldElement): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.CLASS_HASH(value={})".format(self.value) + def __eq__(self, other): + if not other.is_CLASS_HASH(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class CONTRACT_ADDRESS: + + def __init__(self, value:FieldElement): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.CONTRACT_ADDRESS(value={})".format(self.value) + def __eq__(self, other): + if not other.is_CONTRACT_ADDRESS(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class ETH_ADDRESS: + + def __init__(self, value:FieldElement): + self.value = value + + + pass + + + + + + def __str__(self): + return "Primitive.ETH_ADDRESS(value={})".format(self.value) + def __eq__(self, other): + if not other.is_ETH_ADDRESS(): + return False + if self.value != other.value: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_I8(self) -> bool: + return isinstance(self, Primitive.I8) + def is_i8(self) -> bool: + return isinstance(self, Primitive.I8) + def is_I16(self) -> bool: + return isinstance(self, Primitive.I16) + def is_i16(self) -> bool: + return isinstance(self, Primitive.I16) + def is_I32(self) -> bool: + return isinstance(self, Primitive.I32) + def is_i32(self) -> bool: + return isinstance(self, Primitive.I32) + def is_I64(self) -> bool: + return isinstance(self, Primitive.I64) + def is_i64(self) -> bool: + return isinstance(self, Primitive.I64) + def is_I128(self) -> bool: + return isinstance(self, Primitive.I128) + def is_i128(self) -> bool: + return isinstance(self, Primitive.I128) + def is_U8(self) -> bool: + return isinstance(self, Primitive.U8) + def is_u8(self) -> bool: + return isinstance(self, Primitive.U8) + def is_U16(self) -> bool: + return isinstance(self, Primitive.U16) + def is_u16(self) -> bool: + return isinstance(self, Primitive.U16) + def is_U32(self) -> bool: + return isinstance(self, Primitive.U32) + def is_u32(self) -> bool: + return isinstance(self, Primitive.U32) + def is_U64(self) -> bool: + return isinstance(self, Primitive.U64) + def is_u64(self) -> bool: + return isinstance(self, Primitive.U64) + def is_U128(self) -> bool: + return isinstance(self, Primitive.U128) + def is_u128(self) -> bool: + return isinstance(self, Primitive.U128) + def is_U256(self) -> bool: + return isinstance(self, Primitive.U256) + def is_u256(self) -> bool: + return isinstance(self, Primitive.U256) + def is_BOOL(self) -> bool: + return isinstance(self, Primitive.BOOL) + def is_bool(self) -> bool: + return isinstance(self, Primitive.BOOL) + def is_FELT252(self) -> bool: + return isinstance(self, Primitive.FELT252) + def is_felt252(self) -> bool: + return isinstance(self, Primitive.FELT252) + def is_CLASS_HASH(self) -> bool: + return isinstance(self, Primitive.CLASS_HASH) + def is_class_hash(self) -> bool: + return isinstance(self, Primitive.CLASS_HASH) + def is_CONTRACT_ADDRESS(self) -> bool: + return isinstance(self, Primitive.CONTRACT_ADDRESS) + def is_contract_address(self) -> bool: + return isinstance(self, Primitive.CONTRACT_ADDRESS) + def is_ETH_ADDRESS(self) -> bool: + return isinstance(self, Primitive.ETH_ADDRESS) + def is_eth_address(self) -> bool: + return isinstance(self, Primitive.ETH_ADDRESS) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +Primitive.I8 = type("Primitive.I8", (Primitive.I8, Primitive,), {}) # type: ignore +Primitive.I16 = type("Primitive.I16", (Primitive.I16, Primitive,), {}) # type: ignore +Primitive.I32 = type("Primitive.I32", (Primitive.I32, Primitive,), {}) # type: ignore +Primitive.I64 = type("Primitive.I64", (Primitive.I64, Primitive,), {}) # type: ignore +Primitive.I128 = type("Primitive.I128", (Primitive.I128, Primitive,), {}) # type: ignore +Primitive.U8 = type("Primitive.U8", (Primitive.U8, Primitive,), {}) # type: ignore +Primitive.U16 = type("Primitive.U16", (Primitive.U16, Primitive,), {}) # type: ignore +Primitive.U32 = type("Primitive.U32", (Primitive.U32, Primitive,), {}) # type: ignore +Primitive.U64 = type("Primitive.U64", (Primitive.U64, Primitive,), {}) # type: ignore +Primitive.U128 = type("Primitive.U128", (Primitive.U128, Primitive,), {}) # type: ignore +Primitive.U256 = type("Primitive.U256", (Primitive.U256, Primitive,), {}) # type: ignore +Primitive.BOOL = type("Primitive.BOOL", (Primitive.BOOL, Primitive,), {}) # type: ignore +Primitive.FELT252 = type("Primitive.FELT252", (Primitive.FELT252, Primitive,), {}) # type: ignore +Primitive.CLASS_HASH = type("Primitive.CLASS_HASH", (Primitive.CLASS_HASH, Primitive,), {}) # type: ignore +Primitive.CONTRACT_ADDRESS = type("Primitive.CONTRACT_ADDRESS", (Primitive.CONTRACT_ADDRESS, Primitive,), {}) # type: ignore +Primitive.ETH_ADDRESS = type("Primitive.ETH_ADDRESS", (Primitive.ETH_ADDRESS, Primitive,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypePrimitive(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Primitive.I8( + _UniffiFfiConverterInt8.read(buf), + ) + if variant == 2: + return Primitive.I16( + _UniffiFfiConverterInt16.read(buf), + ) + if variant == 3: + return Primitive.I32( + _UniffiFfiConverterInt32.read(buf), + ) + if variant == 4: + return Primitive.I64( + _UniffiFfiConverterInt64.read(buf), + ) + if variant == 5: + return Primitive.I128( + _UniffiFfiConverterSequenceUInt8.read(buf), + ) + if variant == 6: + return Primitive.U8( + _UniffiFfiConverterUInt8.read(buf), + ) + if variant == 7: + return Primitive.U16( + _UniffiFfiConverterUInt16.read(buf), + ) + if variant == 8: + return Primitive.U32( + _UniffiFfiConverterUInt32.read(buf), + ) + if variant == 9: + return Primitive.U64( + _UniffiFfiConverterUInt64.read(buf), + ) + if variant == 10: + return Primitive.U128( + _UniffiFfiConverterSequenceUInt8.read(buf), + ) + if variant == 11: + return Primitive.U256( + _UniffiFfiConverterTypeU256.read(buf), + ) + if variant == 12: + return Primitive.BOOL( + _UniffiFfiConverterBoolean.read(buf), + ) + if variant == 13: + return Primitive.FELT252( + _UniffiFfiConverterTypeFieldElement.read(buf), + ) + if variant == 14: + return Primitive.CLASS_HASH( + _UniffiFfiConverterTypeFieldElement.read(buf), + ) + if variant == 15: + return Primitive.CONTRACT_ADDRESS( + _UniffiFfiConverterTypeFieldElement.read(buf), + ) + if variant == 16: + return Primitive.ETH_ADDRESS( + _UniffiFfiConverterTypeFieldElement.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_I8(): + _UniffiFfiConverterInt8.check_lower(value.value) + return + if value.is_I16(): + _UniffiFfiConverterInt16.check_lower(value.value) + return + if value.is_I32(): + _UniffiFfiConverterInt32.check_lower(value.value) + return + if value.is_I64(): + _UniffiFfiConverterInt64.check_lower(value.value) + return + if value.is_I128(): + _UniffiFfiConverterSequenceUInt8.check_lower(value.value) + return + if value.is_U8(): + _UniffiFfiConverterUInt8.check_lower(value.value) + return + if value.is_U16(): + _UniffiFfiConverterUInt16.check_lower(value.value) + return + if value.is_U32(): + _UniffiFfiConverterUInt32.check_lower(value.value) + return + if value.is_U64(): + _UniffiFfiConverterUInt64.check_lower(value.value) + return + if value.is_U128(): + _UniffiFfiConverterSequenceUInt8.check_lower(value.value) + return + if value.is_U256(): + _UniffiFfiConverterTypeU256.check_lower(value.value) + return + if value.is_BOOL(): + _UniffiFfiConverterBoolean.check_lower(value.value) + return + if value.is_FELT252(): + _UniffiFfiConverterTypeFieldElement.check_lower(value.value) + return + if value.is_CLASS_HASH(): + _UniffiFfiConverterTypeFieldElement.check_lower(value.value) + return + if value.is_CONTRACT_ADDRESS(): + _UniffiFfiConverterTypeFieldElement.check_lower(value.value) + return + if value.is_ETH_ADDRESS(): + _UniffiFfiConverterTypeFieldElement.check_lower(value.value) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_I8(): + buf.write_i32(1) + _UniffiFfiConverterInt8.write(value.value, buf) + if value.is_I16(): + buf.write_i32(2) + _UniffiFfiConverterInt16.write(value.value, buf) + if value.is_I32(): + buf.write_i32(3) + _UniffiFfiConverterInt32.write(value.value, buf) + if value.is_I64(): + buf.write_i32(4) + _UniffiFfiConverterInt64.write(value.value, buf) + if value.is_I128(): + buf.write_i32(5) + _UniffiFfiConverterSequenceUInt8.write(value.value, buf) + if value.is_U8(): + buf.write_i32(6) + _UniffiFfiConverterUInt8.write(value.value, buf) + if value.is_U16(): + buf.write_i32(7) + _UniffiFfiConverterUInt16.write(value.value, buf) + if value.is_U32(): + buf.write_i32(8) + _UniffiFfiConverterUInt32.write(value.value, buf) + if value.is_U64(): + buf.write_i32(9) + _UniffiFfiConverterUInt64.write(value.value, buf) + if value.is_U128(): + buf.write_i32(10) + _UniffiFfiConverterSequenceUInt8.write(value.value, buf) + if value.is_U256(): + buf.write_i32(11) + _UniffiFfiConverterTypeU256.write(value.value, buf) + if value.is_BOOL(): + buf.write_i32(12) + _UniffiFfiConverterBoolean.write(value.value, buf) + if value.is_FELT252(): + buf.write_i32(13) + _UniffiFfiConverterTypeFieldElement.write(value.value, buf) + if value.is_CLASS_HASH(): + buf.write_i32(14) + _UniffiFfiConverterTypeFieldElement.write(value.value, buf) + if value.is_CONTRACT_ADDRESS(): + buf.write_i32(15) + _UniffiFfiConverterTypeFieldElement.write(value.value, buf) + if value.is_ETH_ADDRESS(): + buf.write_i32(16) + _UniffiFfiConverterTypeFieldElement.write(value.value, buf) + + + +class _UniffiFfiConverterSequenceTypeMemberValue(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeMemberValue.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeMemberValue.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeMemberValue.read(buf) for i in range(count) + ] + + + + + + +class MemberValue: + def __init__(self): + raise RuntimeError("MemberValue cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class PRIMITIVE: + + def __init__(self, value:Primitive): + self.value = value + + + pass + + + + + + def __str__(self): + return "MemberValue.PRIMITIVE(value={})".format(self.value) + def __eq__(self, other): + if not other.is_PRIMITIVE(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class STRING: + + def __init__(self, value:str): + self.value = value + + + pass + + + + + + def __str__(self): + return "MemberValue.STRING(value={})".format(self.value) + def __eq__(self, other): + if not other.is_STRING(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class LIST: + + def __init__(self, values:typing.List[MemberValue]): + self.values = values + + + pass + + + + + + def __str__(self): + return "MemberValue.LIST(values={})".format(self.values) + def __eq__(self, other): + if not other.is_LIST(): + return False + if self.values != other.values: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_PRIMITIVE(self) -> bool: + return isinstance(self, MemberValue.PRIMITIVE) + def is_primitive(self) -> bool: + return isinstance(self, MemberValue.PRIMITIVE) + def is_STRING(self) -> bool: + return isinstance(self, MemberValue.STRING) + def is_string(self) -> bool: + return isinstance(self, MemberValue.STRING) + def is_LIST(self) -> bool: + return isinstance(self, MemberValue.LIST) + def is_list(self) -> bool: + return isinstance(self, MemberValue.LIST) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +MemberValue.PRIMITIVE = type("MemberValue.PRIMITIVE", (MemberValue.PRIMITIVE, MemberValue,), {}) # type: ignore +MemberValue.STRING = type("MemberValue.STRING", (MemberValue.STRING, MemberValue,), {}) # type: ignore +MemberValue.LIST = type("MemberValue.LIST", (MemberValue.LIST, MemberValue,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypeMemberValue(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return MemberValue.PRIMITIVE( + _UniffiFfiConverterTypePrimitive.read(buf), + ) + if variant == 2: + return MemberValue.STRING( + _UniffiFfiConverterString.read(buf), + ) + if variant == 3: + return MemberValue.LIST( + _UniffiFfiConverterSequenceTypeMemberValue.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_PRIMITIVE(): + _UniffiFfiConverterTypePrimitive.check_lower(value.value) + return + if value.is_STRING(): + _UniffiFfiConverterString.check_lower(value.value) + return + if value.is_LIST(): + _UniffiFfiConverterSequenceTypeMemberValue.check_lower(value.values) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_PRIMITIVE(): + buf.write_i32(1) + _UniffiFfiConverterTypePrimitive.write(value.value, buf) + if value.is_STRING(): + buf.write_i32(2) + _UniffiFfiConverterString.write(value.value, buf) + if value.is_LIST(): + buf.write_i32(3) + _UniffiFfiConverterSequenceTypeMemberValue.write(value.values, buf) + + + +@dataclass +class MemberClause: + def __init__(self, *, model:str, member:str, operator:ComparisonOperator, value:MemberValue): + self.model = model + self.member = member + self.operator = operator + self.value = value + + + + + def __str__(self): + return "MemberClause(model={}, member={}, operator={}, value={})".format(self.model, self.member, self.operator, self.value) + def __eq__(self, other): + if self.model != other.model: + return False + if self.member != other.member: + return False + if self.operator != other.operator: + return False + if self.value != other.value: + return False + return True + +class _UniffiFfiConverterTypeMemberClause(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return MemberClause( + model=_UniffiFfiConverterString.read(buf), + member=_UniffiFfiConverterString.read(buf), + operator=_UniffiFfiConverterTypeComparisonOperator.read(buf), + value=_UniffiFfiConverterTypeMemberValue.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.model) + _UniffiFfiConverterString.check_lower(value.member) + _UniffiFfiConverterTypeComparisonOperator.check_lower(value.operator) + _UniffiFfiConverterTypeMemberValue.check_lower(value.value) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.model, buf) + _UniffiFfiConverterString.write(value.member, buf) + _UniffiFfiConverterTypeComparisonOperator.write(value.operator, buf) + _UniffiFfiConverterTypeMemberValue.write(value.value, buf) + + + + + + +class Clause: + def __init__(self): + raise RuntimeError("Clause cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class HASHED_KEYS: + + def __init__(self, keys:typing.List[FieldElement]): + self.keys = keys + + + pass + + + + + + def __str__(self): + return "Clause.HASHED_KEYS(keys={})".format(self.keys) + def __eq__(self, other): + if not other.is_HASHED_KEYS(): + return False + if self.keys != other.keys: + return False + return True + + @dataclass + class KEYS: + + def __init__(self, clause:KeysClause): + self.clause = clause + + + pass + + + + + + def __str__(self): + return "Clause.KEYS(clause={})".format(self.clause) + def __eq__(self, other): + if not other.is_KEYS(): + return False + if self.clause != other.clause: + return False + return True + + @dataclass + class MEMBER: + + def __init__(self, clause:MemberClause): + self.clause = clause + + + pass + + + + + + def __str__(self): + return "Clause.MEMBER(clause={})".format(self.clause) + def __eq__(self, other): + if not other.is_MEMBER(): + return False + if self.clause != other.clause: + return False + return True + + @dataclass + class COMPOSITE: + + def __init__(self, clause:CompositeClause): + self.clause = clause + + + pass + + + + + + def __str__(self): + return "Clause.COMPOSITE(clause={})".format(self.clause) + def __eq__(self, other): + if not other.is_COMPOSITE(): + return False + if self.clause != other.clause: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_HASHED_KEYS(self) -> bool: + return isinstance(self, Clause.HASHED_KEYS) + def is_hashed_keys(self) -> bool: + return isinstance(self, Clause.HASHED_KEYS) + def is_KEYS(self) -> bool: + return isinstance(self, Clause.KEYS) + def is_keys(self) -> bool: + return isinstance(self, Clause.KEYS) + def is_MEMBER(self) -> bool: + return isinstance(self, Clause.MEMBER) + def is_member(self) -> bool: + return isinstance(self, Clause.MEMBER) + def is_COMPOSITE(self) -> bool: + return isinstance(self, Clause.COMPOSITE) + def is_composite(self) -> bool: + return isinstance(self, Clause.COMPOSITE) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +Clause.HASHED_KEYS = type("Clause.HASHED_KEYS", (Clause.HASHED_KEYS, Clause,), {}) # type: ignore +Clause.KEYS = type("Clause.KEYS", (Clause.KEYS, Clause,), {}) # type: ignore +Clause.MEMBER = type("Clause.MEMBER", (Clause.MEMBER, Clause,), {}) # type: ignore +Clause.COMPOSITE = type("Clause.COMPOSITE", (Clause.COMPOSITE, Clause,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypeClause(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Clause.HASHED_KEYS( + _UniffiFfiConverterSequenceTypeFieldElement.read(buf), + ) + if variant == 2: + return Clause.KEYS( + _UniffiFfiConverterTypeKeysClause.read(buf), + ) + if variant == 3: + return Clause.MEMBER( + _UniffiFfiConverterTypeMemberClause.read(buf), + ) + if variant == 4: + return Clause.COMPOSITE( + _UniffiFfiConverterTypeCompositeClause.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_HASHED_KEYS(): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.keys) + return + if value.is_KEYS(): + _UniffiFfiConverterTypeKeysClause.check_lower(value.clause) + return + if value.is_MEMBER(): + _UniffiFfiConverterTypeMemberClause.check_lower(value.clause) + return + if value.is_COMPOSITE(): + _UniffiFfiConverterTypeCompositeClause.check_lower(value.clause) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_HASHED_KEYS(): + buf.write_i32(1) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.keys, buf) + if value.is_KEYS(): + buf.write_i32(2) + _UniffiFfiConverterTypeKeysClause.write(value.clause, buf) + if value.is_MEMBER(): + buf.write_i32(3) + _UniffiFfiConverterTypeMemberClause.write(value.clause, buf) + if value.is_COMPOSITE(): + buf.write_i32(4) + _UniffiFfiConverterTypeCompositeClause.write(value.clause, buf) + + + +class _UniffiFfiConverterSequenceTypeClause(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeClause.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeClause.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeClause.read(buf) for i in range(count) + ] + +@dataclass +class CompositeClause: + def __init__(self, *, operator:LogicalOperator, clauses:typing.List[Clause]): + self.operator = operator + self.clauses = clauses + + + + + def __str__(self): + return "CompositeClause(operator={}, clauses={})".format(self.operator, self.clauses) + def __eq__(self, other): + if self.operator != other.operator: + return False + if self.clauses != other.clauses: + return False + return True + +class _UniffiFfiConverterTypeCompositeClause(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return CompositeClause( + operator=_UniffiFfiConverterTypeLogicalOperator.read(buf), + clauses=_UniffiFfiConverterSequenceTypeClause.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeLogicalOperator.check_lower(value.operator) + _UniffiFfiConverterSequenceTypeClause.check_lower(value.clauses) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeLogicalOperator.write(value.operator, buf) + _UniffiFfiConverterSequenceTypeClause.write(value.clauses, buf) + + + + + + +class ContractType(enum.Enum): + + WORLD = 0 + + ERC20 = 1 + + ERC721 = 2 + + ERC1155 = 3 + + UDC = 4 + + OTHER = 5 + + + +class _UniffiFfiConverterTypeContractType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return ContractType.WORLD + if variant == 2: + return ContractType.ERC20 + if variant == 3: + return ContractType.ERC721 + if variant == 4: + return ContractType.ERC1155 + if variant == 5: + return ContractType.UDC + if variant == 6: + return ContractType.OTHER + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == ContractType.WORLD: + return + if value == ContractType.ERC20: + return + if value == ContractType.ERC721: + return + if value == ContractType.ERC1155: + return + if value == ContractType.UDC: + return + if value == ContractType.OTHER: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == ContractType.WORLD: + buf.write_i32(1) + if value == ContractType.ERC20: + buf.write_i32(2) + if value == ContractType.ERC721: + buf.write_i32(3) + if value == ContractType.ERC1155: + buf.write_i32(4) + if value == ContractType.UDC: + buf.write_i32(5) + if value == ContractType.OTHER: + buf.write_i32(6) + + + +@dataclass +class Contract: + def __init__(self, *, contract_address:FieldElement, contract_type:ContractType, head:typing.Optional[int], tps:typing.Optional[int], last_block_timestamp:typing.Optional[int], last_pending_block_tx:typing.Optional[FieldElement], updated_at:int, created_at:int): + self.contract_address = contract_address + self.contract_type = contract_type + self.head = head + self.tps = tps + self.last_block_timestamp = last_block_timestamp + self.last_pending_block_tx = last_pending_block_tx + self.updated_at = updated_at + self.created_at = created_at + + + + + def __str__(self): + return "Contract(contract_address={}, contract_type={}, head={}, tps={}, last_block_timestamp={}, last_pending_block_tx={}, updated_at={}, created_at={})".format(self.contract_address, self.contract_type, self.head, self.tps, self.last_block_timestamp, self.last_pending_block_tx, self.updated_at, self.created_at) + def __eq__(self, other): + if self.contract_address != other.contract_address: + return False + if self.contract_type != other.contract_type: + return False + if self.head != other.head: + return False + if self.tps != other.tps: + return False + if self.last_block_timestamp != other.last_block_timestamp: + return False + if self.last_pending_block_tx != other.last_pending_block_tx: + return False + if self.updated_at != other.updated_at: + return False + if self.created_at != other.created_at: + return False + return True + +class _UniffiFfiConverterTypeContract(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Contract( + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + contract_type=_UniffiFfiConverterTypeContractType.read(buf), + head=_UniffiFfiConverterOptionalUInt64.read(buf), + tps=_UniffiFfiConverterOptionalUInt64.read(buf), + last_block_timestamp=_UniffiFfiConverterOptionalUInt64.read(buf), + last_pending_block_tx=_UniffiFfiConverterOptionalTypeFieldElement.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterTypeContractType.check_lower(value.contract_type) + _UniffiFfiConverterOptionalUInt64.check_lower(value.head) + _UniffiFfiConverterOptionalUInt64.check_lower(value.tps) + _UniffiFfiConverterOptionalUInt64.check_lower(value.last_block_timestamp) + _UniffiFfiConverterOptionalTypeFieldElement.check_lower(value.last_pending_block_tx) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterTypeContractType.write(value.contract_type, buf) + _UniffiFfiConverterOptionalUInt64.write(value.head, buf) + _UniffiFfiConverterOptionalUInt64.write(value.tps, buf) + _UniffiFfiConverterOptionalUInt64.write(value.last_block_timestamp, buf) + _UniffiFfiConverterOptionalTypeFieldElement.write(value.last_pending_block_tx, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + +class _UniffiFfiConverterSequenceTypeContractType(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeContractType.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeContractType.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeContractType.read(buf) for i in range(count) + ] + +@dataclass +class ContractQuery: + def __init__(self, *, contract_addresses:typing.List[FieldElement], contract_types:typing.List[ContractType]): + self.contract_addresses = contract_addresses + self.contract_types = contract_types + + + + + def __str__(self): + return "ContractQuery(contract_addresses={}, contract_types={})".format(self.contract_addresses, self.contract_types) + def __eq__(self, other): + if self.contract_addresses != other.contract_addresses: + return False + if self.contract_types != other.contract_types: + return False + return True + +class _UniffiFfiConverterTypeContractQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ContractQuery( + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + contract_types=_UniffiFfiConverterSequenceTypeContractType.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceTypeContractType.check_lower(value.contract_types) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceTypeContractType.write(value.contract_types, buf) + +@dataclass +class Controller: + def __init__(self, *, address:FieldElement, username:str, deployed_at_timestamp:int): + self.address = address + self.username = username + self.deployed_at_timestamp = deployed_at_timestamp + + + + + def __str__(self): + return "Controller(address={}, username={}, deployed_at_timestamp={})".format(self.address, self.username, self.deployed_at_timestamp) + def __eq__(self, other): + if self.address != other.address: + return False + if self.username != other.username: + return False + if self.deployed_at_timestamp != other.deployed_at_timestamp: + return False + return True + +class _UniffiFfiConverterTypeController(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Controller( + address=_UniffiFfiConverterTypeFieldElement.read(buf), + username=_UniffiFfiConverterString.read(buf), + deployed_at_timestamp=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.address) + _UniffiFfiConverterString.check_lower(value.username) + _UniffiFfiConverterUInt64.check_lower(value.deployed_at_timestamp) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.address, buf) + _UniffiFfiConverterString.write(value.username, buf) + _UniffiFfiConverterUInt64.write(value.deployed_at_timestamp, buf) + +@dataclass +class ControllerQuery: + def __init__(self, *, pagination:Pagination, contract_addresses:typing.List[FieldElement], usernames:typing.List[str]): + self.pagination = pagination + self.contract_addresses = contract_addresses + self.usernames = usernames + + + + + def __str__(self): + return "ControllerQuery(pagination={}, contract_addresses={}, usernames={})".format(self.pagination, self.contract_addresses, self.usernames) + def __eq__(self, other): + if self.pagination != other.pagination: + return False + if self.contract_addresses != other.contract_addresses: + return False + if self.usernames != other.usernames: + return False + return True + +class _UniffiFfiConverterTypeControllerQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ControllerQuery( + pagination=_UniffiFfiConverterTypePagination.read(buf), + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + usernames=_UniffiFfiConverterSequenceString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceString.check_lower(value.usernames) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceString.write(value.usernames, buf) + +@dataclass +class EnumOption: + def __init__(self, *, name:str, ty:Ty): + self.name = name + self.ty = ty + + + + + def __str__(self): + return "EnumOption(name={}, ty={})".format(self.name, self.ty) + def __eq__(self, other): + if self.name != other.name: + return False + if self.ty != other.ty: + return False + return True + +class _UniffiFfiConverterTypeEnumOption(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return EnumOption( + name=_UniffiFfiConverterString.read(buf), + ty=_UniffiFfiConverterTypeTy.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterTypeTy.check_lower(value.ty) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterTypeTy.write(value.ty, buf) + +class _UniffiFfiConverterSequenceTypeEnumOption(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeEnumOption.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeEnumOption.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeEnumOption.read(buf) for i in range(count) + ] + +@dataclass +class EnumType: + def __init__(self, *, name:str, option:int, options:typing.List[EnumOption]): + self.name = name + self.option = option + self.options = options + + + + + def __str__(self): + return "EnumType(name={}, option={}, options={})".format(self.name, self.option, self.options) + def __eq__(self, other): + if self.name != other.name: + return False + if self.option != other.option: + return False + if self.options != other.options: + return False + return True + +class _UniffiFfiConverterTypeEnumType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return EnumType( + name=_UniffiFfiConverterString.read(buf), + option=_UniffiFfiConverterUInt8.read(buf), + options=_UniffiFfiConverterSequenceTypeEnumOption.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterUInt8.check_lower(value.option) + _UniffiFfiConverterSequenceTypeEnumOption.check_lower(value.options) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterUInt8.write(value.option, buf) + _UniffiFfiConverterSequenceTypeEnumOption.write(value.options, buf) + +class _UniffiFfiConverterSequenceTypeTy(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTy.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTy.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTy.read(buf) for i in range(count) + ] + +@dataclass +class FixedSizeArray: + def __init__(self, *, array:typing.List[Ty], size:int): + self.array = array + self.size = size + + + + + def __str__(self): + return "FixedSizeArray(array={}, size={})".format(self.array, self.size) + def __eq__(self, other): + if self.array != other.array: + return False + if self.size != other.size: + return False + return True + +class _UniffiFfiConverterTypeFixedSizeArray(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return FixedSizeArray( + array=_UniffiFfiConverterSequenceTypeTy.read(buf), + size=_UniffiFfiConverterUInt32.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeTy.check_lower(value.array) + _UniffiFfiConverterUInt32.check_lower(value.size) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeTy.write(value.array, buf) + _UniffiFfiConverterUInt32.write(value.size, buf) + + + + + + +class Ty: + def __init__(self): + raise RuntimeError("Ty cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class PRIMITIVE: + + def __init__(self, value:Primitive): + self.value = value + + + pass + + + + + + def __str__(self): + return "Ty.PRIMITIVE(value={})".format(self.value) + def __eq__(self, other): + if not other.is_PRIMITIVE(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class STRUCT: + + def __init__(self, value:Struct): + self.value = value + + + pass + + + + + + def __str__(self): + return "Ty.STRUCT(value={})".format(self.value) + def __eq__(self, other): + if not other.is_STRUCT(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class ENUM: + + def __init__(self, value:EnumType): + self.value = value + + + pass + + + + + + def __str__(self): + return "Ty.ENUM(value={})".format(self.value) + def __eq__(self, other): + if not other.is_ENUM(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class TUPLE: + + def __init__(self, values:typing.List[Ty]): + self.values = values + + + pass + + + + + + def __str__(self): + return "Ty.TUPLE(values={})".format(self.values) + def __eq__(self, other): + if not other.is_TUPLE(): + return False + if self.values != other.values: + return False + return True + + @dataclass + class ARRAY: + + def __init__(self, values:typing.List[Ty]): + self.values = values + + + pass + + + + + + def __str__(self): + return "Ty.ARRAY(values={})".format(self.values) + def __eq__(self, other): + if not other.is_ARRAY(): + return False + if self.values != other.values: + return False + return True + + @dataclass + class FIXED_SIZE_ARRAY: + + def __init__(self, value:FixedSizeArray): + self.value = value + + + pass + + + + + + def __str__(self): + return "Ty.FIXED_SIZE_ARRAY(value={})".format(self.value) + def __eq__(self, other): + if not other.is_FIXED_SIZE_ARRAY(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class BYTE_ARRAY: + + def __init__(self, value:str): + self.value = value + + + pass + + + + + + def __str__(self): + return "Ty.BYTE_ARRAY(value={})".format(self.value) + def __eq__(self, other): + if not other.is_BYTE_ARRAY(): + return False + if self.value != other.value: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_PRIMITIVE(self) -> bool: + return isinstance(self, Ty.PRIMITIVE) + def is_primitive(self) -> bool: + return isinstance(self, Ty.PRIMITIVE) + def is_STRUCT(self) -> bool: + return isinstance(self, Ty.STRUCT) + def is_struct(self) -> bool: + return isinstance(self, Ty.STRUCT) + def is_ENUM(self) -> bool: + return isinstance(self, Ty.ENUM) + def is_enum(self) -> bool: + return isinstance(self, Ty.ENUM) + def is_TUPLE(self) -> bool: + return isinstance(self, Ty.TUPLE) + def is_tuple(self) -> bool: + return isinstance(self, Ty.TUPLE) + def is_ARRAY(self) -> bool: + return isinstance(self, Ty.ARRAY) + def is_array(self) -> bool: + return isinstance(self, Ty.ARRAY) + def is_FIXED_SIZE_ARRAY(self) -> bool: + return isinstance(self, Ty.FIXED_SIZE_ARRAY) + def is_fixed_size_array(self) -> bool: + return isinstance(self, Ty.FIXED_SIZE_ARRAY) + def is_BYTE_ARRAY(self) -> bool: + return isinstance(self, Ty.BYTE_ARRAY) + def is_byte_array(self) -> bool: + return isinstance(self, Ty.BYTE_ARRAY) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +Ty.PRIMITIVE = type("Ty.PRIMITIVE", (Ty.PRIMITIVE, Ty,), {}) # type: ignore +Ty.STRUCT = type("Ty.STRUCT", (Ty.STRUCT, Ty,), {}) # type: ignore +Ty.ENUM = type("Ty.ENUM", (Ty.ENUM, Ty,), {}) # type: ignore +Ty.TUPLE = type("Ty.TUPLE", (Ty.TUPLE, Ty,), {}) # type: ignore +Ty.ARRAY = type("Ty.ARRAY", (Ty.ARRAY, Ty,), {}) # type: ignore +Ty.FIXED_SIZE_ARRAY = type("Ty.FIXED_SIZE_ARRAY", (Ty.FIXED_SIZE_ARRAY, Ty,), {}) # type: ignore +Ty.BYTE_ARRAY = type("Ty.BYTE_ARRAY", (Ty.BYTE_ARRAY, Ty,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypeTy(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Ty.PRIMITIVE( + _UniffiFfiConverterTypePrimitive.read(buf), + ) + if variant == 2: + return Ty.STRUCT( + _UniffiFfiConverterTypeStruct.read(buf), + ) + if variant == 3: + return Ty.ENUM( + _UniffiFfiConverterTypeEnumType.read(buf), + ) + if variant == 4: + return Ty.TUPLE( + _UniffiFfiConverterSequenceTypeTy.read(buf), + ) + if variant == 5: + return Ty.ARRAY( + _UniffiFfiConverterSequenceTypeTy.read(buf), + ) + if variant == 6: + return Ty.FIXED_SIZE_ARRAY( + _UniffiFfiConverterTypeFixedSizeArray.read(buf), + ) + if variant == 7: + return Ty.BYTE_ARRAY( + _UniffiFfiConverterString.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_PRIMITIVE(): + _UniffiFfiConverterTypePrimitive.check_lower(value.value) + return + if value.is_STRUCT(): + _UniffiFfiConverterTypeStruct.check_lower(value.value) + return + if value.is_ENUM(): + _UniffiFfiConverterTypeEnumType.check_lower(value.value) + return + if value.is_TUPLE(): + _UniffiFfiConverterSequenceTypeTy.check_lower(value.values) + return + if value.is_ARRAY(): + _UniffiFfiConverterSequenceTypeTy.check_lower(value.values) + return + if value.is_FIXED_SIZE_ARRAY(): + _UniffiFfiConverterTypeFixedSizeArray.check_lower(value.value) + return + if value.is_BYTE_ARRAY(): + _UniffiFfiConverterString.check_lower(value.value) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_PRIMITIVE(): + buf.write_i32(1) + _UniffiFfiConverterTypePrimitive.write(value.value, buf) + if value.is_STRUCT(): + buf.write_i32(2) + _UniffiFfiConverterTypeStruct.write(value.value, buf) + if value.is_ENUM(): + buf.write_i32(3) + _UniffiFfiConverterTypeEnumType.write(value.value, buf) + if value.is_TUPLE(): + buf.write_i32(4) + _UniffiFfiConverterSequenceTypeTy.write(value.values, buf) + if value.is_ARRAY(): + buf.write_i32(5) + _UniffiFfiConverterSequenceTypeTy.write(value.values, buf) + if value.is_FIXED_SIZE_ARRAY(): + buf.write_i32(6) + _UniffiFfiConverterTypeFixedSizeArray.write(value.value, buf) + if value.is_BYTE_ARRAY(): + buf.write_i32(7) + _UniffiFfiConverterString.write(value.value, buf) + + + +@dataclass +class Member: + def __init__(self, *, name:str, ty:Ty, key:bool): + self.name = name + self.ty = ty + self.key = key + + + + + def __str__(self): + return "Member(name={}, ty={}, key={})".format(self.name, self.ty, self.key) + def __eq__(self, other): + if self.name != other.name: + return False + if self.ty != other.ty: + return False + if self.key != other.key: + return False + return True + +class _UniffiFfiConverterTypeMember(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Member( + name=_UniffiFfiConverterString.read(buf), + ty=_UniffiFfiConverterTypeTy.read(buf), + key=_UniffiFfiConverterBoolean.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterTypeTy.check_lower(value.ty) + _UniffiFfiConverterBoolean.check_lower(value.key) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterTypeTy.write(value.ty, buf) + _UniffiFfiConverterBoolean.write(value.key, buf) + +class _UniffiFfiConverterSequenceTypeMember(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeMember.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeMember.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeMember.read(buf) for i in range(count) + ] + +@dataclass +class Struct: + def __init__(self, *, name:str, children:typing.List[Member]): + self.name = name + self.children = children + + + + + def __str__(self): + return "Struct(name={}, children={})".format(self.name, self.children) + def __eq__(self, other): + if self.name != other.name: + return False + if self.children != other.children: + return False + return True + +class _UniffiFfiConverterTypeStruct(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Struct( + name=_UniffiFfiConverterString.read(buf), + children=_UniffiFfiConverterSequenceTypeMember.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterSequenceTypeMember.check_lower(value.children) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterSequenceTypeMember.write(value.children, buf) + +class _UniffiFfiConverterSequenceTypeStruct(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeStruct.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeStruct.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeStruct.read(buf) for i in range(count) + ] + +@dataclass +class Entity: + def __init__(self, *, world_address:FieldElement, hashed_keys:FieldElement, models:typing.List[Struct], created_at:int, updated_at:int, executed_at:int): + self.world_address = world_address + self.hashed_keys = hashed_keys + self.models = models + self.created_at = created_at + self.updated_at = updated_at + self.executed_at = executed_at + + + + + def __str__(self): + return "Entity(world_address={}, hashed_keys={}, models={}, created_at={}, updated_at={}, executed_at={})".format(self.world_address, self.hashed_keys, self.models, self.created_at, self.updated_at, self.executed_at) + def __eq__(self, other): + if self.world_address != other.world_address: + return False + if self.hashed_keys != other.hashed_keys: + return False + if self.models != other.models: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + if self.executed_at != other.executed_at: + return False + return True + +class _UniffiFfiConverterTypeEntity(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Entity( + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + hashed_keys=_UniffiFfiConverterTypeFieldElement.read(buf), + models=_UniffiFfiConverterSequenceTypeStruct.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + executed_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterTypeFieldElement.check_lower(value.hashed_keys) + _UniffiFfiConverterSequenceTypeStruct.check_lower(value.models) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + _UniffiFfiConverterUInt64.check_lower(value.executed_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterTypeFieldElement.write(value.hashed_keys, buf) + _UniffiFfiConverterSequenceTypeStruct.write(value.models, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + _UniffiFfiConverterUInt64.write(value.executed_at, buf) + +@dataclass +class Event: + def __init__(self, *, keys:typing.List[FieldElement], data:typing.List[FieldElement], transaction_hash:FieldElement): + self.keys = keys + self.data = data + self.transaction_hash = transaction_hash + + + + + def __str__(self): + return "Event(keys={}, data={}, transaction_hash={})".format(self.keys, self.data, self.transaction_hash) + def __eq__(self, other): + if self.keys != other.keys: + return False + if self.data != other.data: + return False + if self.transaction_hash != other.transaction_hash: + return False + return True + +class _UniffiFfiConverterTypeEvent(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Event( + keys=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + data=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + transaction_hash=_UniffiFfiConverterTypeFieldElement.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.keys) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.data) + _UniffiFfiConverterTypeFieldElement.check_lower(value.transaction_hash) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.keys, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.data, buf) + _UniffiFfiConverterTypeFieldElement.write(value.transaction_hash, buf) + +class _UniffiFfiConverterOptionalTypeKeysClause(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterTypeKeysClause.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterTypeKeysClause.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterTypeKeysClause.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class EventQuery: + def __init__(self, *, keys:typing.Optional[KeysClause], pagination:Pagination): + self.keys = keys + self.pagination = pagination + + + + + def __str__(self): + return "EventQuery(keys={}, pagination={})".format(self.keys, self.pagination) + def __eq__(self, other): + if self.keys != other.keys: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeEventQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return EventQuery( + keys=_UniffiFfiConverterOptionalTypeKeysClause.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterOptionalTypeKeysClause.check_lower(value.keys) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterOptionalTypeKeysClause.write(value.keys, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class Message: + def __init__(self, *, message:str, signature:typing.List[FieldElement], world_address:FieldElement): + self.message = message + self.signature = signature + self.world_address = world_address + + + + + def __str__(self): + return "Message(message={}, signature={}, world_address={})".format(self.message, self.signature, self.world_address) + def __eq__(self, other): + if self.message != other.message: + return False + if self.signature != other.signature: + return False + if self.world_address != other.world_address: + return False + return True + +class _UniffiFfiConverterTypeMessage(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Message( + message=_UniffiFfiConverterString.read(buf), + signature=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.message) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.signature) + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.message, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.signature, buf) + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + +@dataclass +class Model: + def __init__(self, *, world_address:FieldElement, schema:Ty, namespace:str, name:str, selector:FieldElement, packed_size:int, unpacked_size:int, class_hash:FieldElement, contract_address:FieldElement, layout:str, use_legacy_store:bool): + self.world_address = world_address + self.schema = schema + self.namespace = namespace + self.name = name + self.selector = selector + self.packed_size = packed_size + self.unpacked_size = unpacked_size + self.class_hash = class_hash + self.contract_address = contract_address + self.layout = layout + self.use_legacy_store = use_legacy_store + + + + + def __str__(self): + return "Model(world_address={}, schema={}, namespace={}, name={}, selector={}, packed_size={}, unpacked_size={}, class_hash={}, contract_address={}, layout={}, use_legacy_store={})".format(self.world_address, self.schema, self.namespace, self.name, self.selector, self.packed_size, self.unpacked_size, self.class_hash, self.contract_address, self.layout, self.use_legacy_store) + def __eq__(self, other): + if self.world_address != other.world_address: + return False + if self.schema != other.schema: + return False + if self.namespace != other.namespace: + return False + if self.name != other.name: + return False + if self.selector != other.selector: + return False + if self.packed_size != other.packed_size: + return False + if self.unpacked_size != other.unpacked_size: + return False + if self.class_hash != other.class_hash: + return False + if self.contract_address != other.contract_address: + return False + if self.layout != other.layout: + return False + if self.use_legacy_store != other.use_legacy_store: + return False + return True + +class _UniffiFfiConverterTypeModel(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Model( + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + schema=_UniffiFfiConverterTypeTy.read(buf), + namespace=_UniffiFfiConverterString.read(buf), + name=_UniffiFfiConverterString.read(buf), + selector=_UniffiFfiConverterTypeFieldElement.read(buf), + packed_size=_UniffiFfiConverterUInt32.read(buf), + unpacked_size=_UniffiFfiConverterUInt32.read(buf), + class_hash=_UniffiFfiConverterTypeFieldElement.read(buf), + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + layout=_UniffiFfiConverterString.read(buf), + use_legacy_store=_UniffiFfiConverterBoolean.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterTypeTy.check_lower(value.schema) + _UniffiFfiConverterString.check_lower(value.namespace) + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterTypeFieldElement.check_lower(value.selector) + _UniffiFfiConverterUInt32.check_lower(value.packed_size) + _UniffiFfiConverterUInt32.check_lower(value.unpacked_size) + _UniffiFfiConverterTypeFieldElement.check_lower(value.class_hash) + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterString.check_lower(value.layout) + _UniffiFfiConverterBoolean.check_lower(value.use_legacy_store) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterTypeTy.write(value.schema, buf) + _UniffiFfiConverterString.write(value.namespace, buf) + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterTypeFieldElement.write(value.selector, buf) + _UniffiFfiConverterUInt32.write(value.packed_size, buf) + _UniffiFfiConverterUInt32.write(value.unpacked_size, buf) + _UniffiFfiConverterTypeFieldElement.write(value.class_hash, buf) + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterString.write(value.layout, buf) + _UniffiFfiConverterBoolean.write(value.use_legacy_store, buf) + +class _UniffiFfiConverterSequenceTypeAchievement(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeAchievement.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeAchievement.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeAchievement.read(buf) for i in range(count) + ] + +@dataclass +class PageAchievement: + def __init__(self, *, items:typing.List[Achievement], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageAchievement(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageAchievement(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageAchievement( + items=_UniffiFfiConverterSequenceTypeAchievement.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeAchievement.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeAchievement.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterSequenceTypeActivity(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeActivity.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeActivity.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeActivity.read(buf) for i in range(count) + ] + +@dataclass +class PageActivity: + def __init__(self, *, items:typing.List[Activity], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageActivity(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageActivity(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageActivity( + items=_UniffiFfiConverterSequenceTypeActivity.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeActivity.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeActivity.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterSequenceTypeAggregationEntry(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeAggregationEntry.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeAggregationEntry.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeAggregationEntry.read(buf) for i in range(count) + ] + +@dataclass +class PageAggregationEntry: + def __init__(self, *, items:typing.List[AggregationEntry], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageAggregationEntry(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageAggregationEntry(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageAggregationEntry( + items=_UniffiFfiConverterSequenceTypeAggregationEntry.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeAggregationEntry.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeAggregationEntry.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterSequenceTypeController(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeController.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeController.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeController.read(buf) for i in range(count) + ] + +@dataclass +class PageController: + def __init__(self, *, items:typing.List[Controller], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageController(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageController(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageController( + items=_UniffiFfiConverterSequenceTypeController.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeController.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeController.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterSequenceTypeEntity(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeEntity.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeEntity.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeEntity.read(buf) for i in range(count) + ] + +@dataclass +class PageEntity: + def __init__(self, *, items:typing.List[Entity], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageEntity(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageEntity(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageEntity( + items=_UniffiFfiConverterSequenceTypeEntity.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeEntity.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeEntity.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterSequenceTypeEvent(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeEvent.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeEvent.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeEvent.read(buf) for i in range(count) + ] + +@dataclass +class PageEvent: + def __init__(self, *, items:typing.List[Event], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageEvent(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageEvent(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageEvent( + items=_UniffiFfiConverterSequenceTypeEvent.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeEvent.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeEvent.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +@dataclass +class PlayerAchievementStats: + def __init__(self, *, total_points:int, completed_achievements:int, total_achievements:int, completion_percentage:float, last_achievement_at:typing.Optional[int], created_at:int, updated_at:int): + self.total_points = total_points + self.completed_achievements = completed_achievements + self.total_achievements = total_achievements + self.completion_percentage = completion_percentage + self.last_achievement_at = last_achievement_at + self.created_at = created_at + self.updated_at = updated_at + + + + + def __str__(self): + return "PlayerAchievementStats(total_points={}, completed_achievements={}, total_achievements={}, completion_percentage={}, last_achievement_at={}, created_at={}, updated_at={})".format(self.total_points, self.completed_achievements, self.total_achievements, self.completion_percentage, self.last_achievement_at, self.created_at, self.updated_at) + def __eq__(self, other): + if self.total_points != other.total_points: + return False + if self.completed_achievements != other.completed_achievements: + return False + if self.total_achievements != other.total_achievements: + return False + if self.completion_percentage != other.completion_percentage: + return False + if self.last_achievement_at != other.last_achievement_at: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + return True + +class _UniffiFfiConverterTypePlayerAchievementStats(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PlayerAchievementStats( + total_points=_UniffiFfiConverterUInt32.read(buf), + completed_achievements=_UniffiFfiConverterUInt32.read(buf), + total_achievements=_UniffiFfiConverterUInt32.read(buf), + completion_percentage=_UniffiFfiConverterFloat64.read(buf), + last_achievement_at=_UniffiFfiConverterOptionalUInt64.read(buf), + created_at=_UniffiFfiConverterUInt64.read(buf), + updated_at=_UniffiFfiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterUInt32.check_lower(value.total_points) + _UniffiFfiConverterUInt32.check_lower(value.completed_achievements) + _UniffiFfiConverterUInt32.check_lower(value.total_achievements) + _UniffiFfiConverterFloat64.check_lower(value.completion_percentage) + _UniffiFfiConverterOptionalUInt64.check_lower(value.last_achievement_at) + _UniffiFfiConverterUInt64.check_lower(value.created_at) + _UniffiFfiConverterUInt64.check_lower(value.updated_at) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterUInt32.write(value.total_points, buf) + _UniffiFfiConverterUInt32.write(value.completed_achievements, buf) + _UniffiFfiConverterUInt32.write(value.total_achievements, buf) + _UniffiFfiConverterFloat64.write(value.completion_percentage, buf) + _UniffiFfiConverterOptionalUInt64.write(value.last_achievement_at, buf) + _UniffiFfiConverterUInt64.write(value.created_at, buf) + _UniffiFfiConverterUInt64.write(value.updated_at, buf) + +@dataclass +class TaskProgress: + def __init__(self, *, task_id:str, count:int, completed:bool): + self.task_id = task_id + self.count = count + self.completed = completed + + + + + def __str__(self): + return "TaskProgress(task_id={}, count={}, completed={})".format(self.task_id, self.count, self.completed) + def __eq__(self, other): + if self.task_id != other.task_id: + return False + if self.count != other.count: + return False + if self.completed != other.completed: + return False + return True + +class _UniffiFfiConverterTypeTaskProgress(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TaskProgress( + task_id=_UniffiFfiConverterString.read(buf), + count=_UniffiFfiConverterUInt32.read(buf), + completed=_UniffiFfiConverterBoolean.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.task_id) + _UniffiFfiConverterUInt32.check_lower(value.count) + _UniffiFfiConverterBoolean.check_lower(value.completed) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.task_id, buf) + _UniffiFfiConverterUInt32.write(value.count, buf) + _UniffiFfiConverterBoolean.write(value.completed, buf) + +class _UniffiFfiConverterSequenceTypeTaskProgress(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTaskProgress.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTaskProgress.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTaskProgress.read(buf) for i in range(count) + ] + +@dataclass +class PlayerAchievementProgress: + def __init__(self, *, achievement:Achievement, task_progress:typing.List[TaskProgress], completed:bool, progress_percentage:float): + self.achievement = achievement + self.task_progress = task_progress + self.completed = completed + self.progress_percentage = progress_percentage + + + + + def __str__(self): + return "PlayerAchievementProgress(achievement={}, task_progress={}, completed={}, progress_percentage={})".format(self.achievement, self.task_progress, self.completed, self.progress_percentage) + def __eq__(self, other): + if self.achievement != other.achievement: + return False + if self.task_progress != other.task_progress: + return False + if self.completed != other.completed: + return False + if self.progress_percentage != other.progress_percentage: + return False + return True + +class _UniffiFfiConverterTypePlayerAchievementProgress(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PlayerAchievementProgress( + achievement=_UniffiFfiConverterTypeAchievement.read(buf), + task_progress=_UniffiFfiConverterSequenceTypeTaskProgress.read(buf), + completed=_UniffiFfiConverterBoolean.read(buf), + progress_percentage=_UniffiFfiConverterFloat64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeAchievement.check_lower(value.achievement) + _UniffiFfiConverterSequenceTypeTaskProgress.check_lower(value.task_progress) + _UniffiFfiConverterBoolean.check_lower(value.completed) + _UniffiFfiConverterFloat64.check_lower(value.progress_percentage) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeAchievement.write(value.achievement, buf) + _UniffiFfiConverterSequenceTypeTaskProgress.write(value.task_progress, buf) + _UniffiFfiConverterBoolean.write(value.completed, buf) + _UniffiFfiConverterFloat64.write(value.progress_percentage, buf) + +class _UniffiFfiConverterSequenceTypePlayerAchievementProgress(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypePlayerAchievementProgress.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypePlayerAchievementProgress.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypePlayerAchievementProgress.read(buf) for i in range(count) + ] + +@dataclass +class PlayerAchievementEntry: + def __init__(self, *, player_address:FieldElement, stats:PlayerAchievementStats, achievements:typing.List[PlayerAchievementProgress]): + self.player_address = player_address + self.stats = stats + self.achievements = achievements + + + + + def __str__(self): + return "PlayerAchievementEntry(player_address={}, stats={}, achievements={})".format(self.player_address, self.stats, self.achievements) + def __eq__(self, other): + if self.player_address != other.player_address: + return False + if self.stats != other.stats: + return False + if self.achievements != other.achievements: + return False + return True + +class _UniffiFfiConverterTypePlayerAchievementEntry(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PlayerAchievementEntry( + player_address=_UniffiFfiConverterTypeFieldElement.read(buf), + stats=_UniffiFfiConverterTypePlayerAchievementStats.read(buf), + achievements=_UniffiFfiConverterSequenceTypePlayerAchievementProgress.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.player_address) + _UniffiFfiConverterTypePlayerAchievementStats.check_lower(value.stats) + _UniffiFfiConverterSequenceTypePlayerAchievementProgress.check_lower(value.achievements) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.player_address, buf) + _UniffiFfiConverterTypePlayerAchievementStats.write(value.stats, buf) + _UniffiFfiConverterSequenceTypePlayerAchievementProgress.write(value.achievements, buf) + +class _UniffiFfiConverterSequenceTypePlayerAchievementEntry(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypePlayerAchievementEntry.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypePlayerAchievementEntry.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypePlayerAchievementEntry.read(buf) for i in range(count) + ] + +@dataclass +class PagePlayerAchievement: + def __init__(self, *, items:typing.List[PlayerAchievementEntry], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PagePlayerAchievement(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePagePlayerAchievement(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PagePlayerAchievement( + items=_UniffiFfiConverterSequenceTypePlayerAchievementEntry.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypePlayerAchievementEntry.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypePlayerAchievementEntry.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +class _UniffiFfiConverterOptionalTypeU256(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterTypeU256.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterTypeU256.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterTypeU256.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class Token: + def __init__(self, *, contract_address:FieldElement, token_id:typing.Optional[U256], name:str, symbol:str, decimals:int, metadata:str, total_supply:typing.Optional[U256]): + self.contract_address = contract_address + self.token_id = token_id + self.name = name + self.symbol = symbol + self.decimals = decimals + self.metadata = metadata + self.total_supply = total_supply + + + + + def __str__(self): + return "Token(contract_address={}, token_id={}, name={}, symbol={}, decimals={}, metadata={}, total_supply={})".format(self.contract_address, self.token_id, self.name, self.symbol, self.decimals, self.metadata, self.total_supply) + def __eq__(self, other): + if self.contract_address != other.contract_address: + return False + if self.token_id != other.token_id: + return False + if self.name != other.name: + return False + if self.symbol != other.symbol: + return False + if self.decimals != other.decimals: + return False + if self.metadata != other.metadata: + return False + if self.total_supply != other.total_supply: + return False + return True + +class _UniffiFfiConverterTypeToken(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Token( + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + token_id=_UniffiFfiConverterOptionalTypeU256.read(buf), + name=_UniffiFfiConverterString.read(buf), + symbol=_UniffiFfiConverterString.read(buf), + decimals=_UniffiFfiConverterUInt8.read(buf), + metadata=_UniffiFfiConverterString.read(buf), + total_supply=_UniffiFfiConverterOptionalTypeU256.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterOptionalTypeU256.check_lower(value.token_id) + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterString.check_lower(value.symbol) + _UniffiFfiConverterUInt8.check_lower(value.decimals) + _UniffiFfiConverterString.check_lower(value.metadata) + _UniffiFfiConverterOptionalTypeU256.check_lower(value.total_supply) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterOptionalTypeU256.write(value.token_id, buf) + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterString.write(value.symbol, buf) + _UniffiFfiConverterUInt8.write(value.decimals, buf) + _UniffiFfiConverterString.write(value.metadata, buf) + _UniffiFfiConverterOptionalTypeU256.write(value.total_supply, buf) + +class _UniffiFfiConverterSequenceTypeToken(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeToken.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeToken.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeToken.read(buf) for i in range(count) + ] + +@dataclass +class PageToken: + def __init__(self, *, items:typing.List[Token], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageToken(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageToken(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageToken( + items=_UniffiFfiConverterSequenceTypeToken.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeToken.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeToken.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +@dataclass +class TokenBalance: + def __init__(self, *, balance:U256, account_address:FieldElement, contract_address:FieldElement, token_id:typing.Optional[U256]): + self.balance = balance + self.account_address = account_address + self.contract_address = contract_address + self.token_id = token_id + + + + + def __str__(self): + return "TokenBalance(balance={}, account_address={}, contract_address={}, token_id={})".format(self.balance, self.account_address, self.contract_address, self.token_id) + def __eq__(self, other): + if self.balance != other.balance: + return False + if self.account_address != other.account_address: + return False + if self.contract_address != other.contract_address: + return False + if self.token_id != other.token_id: + return False + return True + +class _UniffiFfiConverterTypeTokenBalance(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenBalance( + balance=_UniffiFfiConverterTypeU256.read(buf), + account_address=_UniffiFfiConverterTypeFieldElement.read(buf), + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + token_id=_UniffiFfiConverterOptionalTypeU256.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeU256.check_lower(value.balance) + _UniffiFfiConverterTypeFieldElement.check_lower(value.account_address) + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterOptionalTypeU256.check_lower(value.token_id) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeU256.write(value.balance, buf) + _UniffiFfiConverterTypeFieldElement.write(value.account_address, buf) + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterOptionalTypeU256.write(value.token_id, buf) + +class _UniffiFfiConverterSequenceTypeTokenBalance(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTokenBalance.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTokenBalance.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTokenBalance.read(buf) for i in range(count) + ] + +@dataclass +class PageTokenBalance: + def __init__(self, *, items:typing.List[TokenBalance], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageTokenBalance(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageTokenBalance(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageTokenBalance( + items=_UniffiFfiConverterSequenceTypeTokenBalance.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeTokenBalance.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeTokenBalance.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +@dataclass +class TokenContract: + def __init__(self, *, contract_address:FieldElement, name:str, symbol:str, decimals:int, metadata:str, token_metadata:str, total_supply:typing.Optional[U256]): + self.contract_address = contract_address + self.name = name + self.symbol = symbol + self.decimals = decimals + self.metadata = metadata + self.token_metadata = token_metadata + self.total_supply = total_supply + + + + + def __str__(self): + return "TokenContract(contract_address={}, name={}, symbol={}, decimals={}, metadata={}, token_metadata={}, total_supply={})".format(self.contract_address, self.name, self.symbol, self.decimals, self.metadata, self.token_metadata, self.total_supply) + def __eq__(self, other): + if self.contract_address != other.contract_address: + return False + if self.name != other.name: + return False + if self.symbol != other.symbol: + return False + if self.decimals != other.decimals: + return False + if self.metadata != other.metadata: + return False + if self.token_metadata != other.token_metadata: + return False + if self.total_supply != other.total_supply: + return False + return True + +class _UniffiFfiConverterTypeTokenContract(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenContract( + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + name=_UniffiFfiConverterString.read(buf), + symbol=_UniffiFfiConverterString.read(buf), + decimals=_UniffiFfiConverterUInt8.read(buf), + metadata=_UniffiFfiConverterString.read(buf), + token_metadata=_UniffiFfiConverterString.read(buf), + total_supply=_UniffiFfiConverterOptionalTypeU256.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterString.check_lower(value.symbol) + _UniffiFfiConverterUInt8.check_lower(value.decimals) + _UniffiFfiConverterString.check_lower(value.metadata) + _UniffiFfiConverterString.check_lower(value.token_metadata) + _UniffiFfiConverterOptionalTypeU256.check_lower(value.total_supply) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterString.write(value.symbol, buf) + _UniffiFfiConverterUInt8.write(value.decimals, buf) + _UniffiFfiConverterString.write(value.metadata, buf) + _UniffiFfiConverterString.write(value.token_metadata, buf) + _UniffiFfiConverterOptionalTypeU256.write(value.total_supply, buf) + +class _UniffiFfiConverterSequenceTypeTokenContract(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTokenContract.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTokenContract.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTokenContract.read(buf) for i in range(count) + ] + +@dataclass +class PageTokenContract: + def __init__(self, *, items:typing.List[TokenContract], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageTokenContract(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageTokenContract(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageTokenContract( + items=_UniffiFfiConverterSequenceTypeTokenContract.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeTokenContract.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeTokenContract.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +@dataclass +class TokenTransfer: + def __init__(self, *, id:str, contract_address:FieldElement, from_address:FieldElement, to_address:FieldElement, amount:U256, token_id:typing.Optional[U256], executed_at:int, event_id:typing.Optional[str]): + self.id = id + self.contract_address = contract_address + self.from_address = from_address + self.to_address = to_address + self.amount = amount + self.token_id = token_id + self.executed_at = executed_at + self.event_id = event_id + + + + + def __str__(self): + return "TokenTransfer(id={}, contract_address={}, from_address={}, to_address={}, amount={}, token_id={}, executed_at={}, event_id={})".format(self.id, self.contract_address, self.from_address, self.to_address, self.amount, self.token_id, self.executed_at, self.event_id) + def __eq__(self, other): + if self.id != other.id: + return False + if self.contract_address != other.contract_address: + return False + if self.from_address != other.from_address: + return False + if self.to_address != other.to_address: + return False + if self.amount != other.amount: + return False + if self.token_id != other.token_id: + return False + if self.executed_at != other.executed_at: + return False + if self.event_id != other.event_id: + return False + return True + +class _UniffiFfiConverterTypeTokenTransfer(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenTransfer( + id=_UniffiFfiConverterString.read(buf), + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + from_address=_UniffiFfiConverterTypeFieldElement.read(buf), + to_address=_UniffiFfiConverterTypeFieldElement.read(buf), + amount=_UniffiFfiConverterTypeU256.read(buf), + token_id=_UniffiFfiConverterOptionalTypeU256.read(buf), + executed_at=_UniffiFfiConverterUInt64.read(buf), + event_id=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.id) + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterTypeFieldElement.check_lower(value.from_address) + _UniffiFfiConverterTypeFieldElement.check_lower(value.to_address) + _UniffiFfiConverterTypeU256.check_lower(value.amount) + _UniffiFfiConverterOptionalTypeU256.check_lower(value.token_id) + _UniffiFfiConverterUInt64.check_lower(value.executed_at) + _UniffiFfiConverterOptionalString.check_lower(value.event_id) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.id, buf) + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterTypeFieldElement.write(value.from_address, buf) + _UniffiFfiConverterTypeFieldElement.write(value.to_address, buf) + _UniffiFfiConverterTypeU256.write(value.amount, buf) + _UniffiFfiConverterOptionalTypeU256.write(value.token_id, buf) + _UniffiFfiConverterUInt64.write(value.executed_at, buf) + _UniffiFfiConverterOptionalString.write(value.event_id, buf) + +class _UniffiFfiConverterSequenceTypeTokenTransfer(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTokenTransfer.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTokenTransfer.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTokenTransfer.read(buf) for i in range(count) + ] + +@dataclass +class PageTokenTransfer: + def __init__(self, *, items:typing.List[TokenTransfer], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageTokenTransfer(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageTokenTransfer(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageTokenTransfer( + items=_UniffiFfiConverterSequenceTypeTokenTransfer.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeTokenTransfer.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeTokenTransfer.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + + + + + + +class CallType(enum.Enum): + + EXECUTE = 0 + + EXECUTE_FROM_OUTSIDE = 1 + + + +class _UniffiFfiConverterTypeCallType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return CallType.EXECUTE + if variant == 2: + return CallType.EXECUTE_FROM_OUTSIDE + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == CallType.EXECUTE: + return + if value == CallType.EXECUTE_FROM_OUTSIDE: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == CallType.EXECUTE: + buf.write_i32(1) + if value == CallType.EXECUTE_FROM_OUTSIDE: + buf.write_i32(2) + + + +@dataclass +class TransactionCall: + def __init__(self, *, contract_address:FieldElement, entrypoint:str, calldata:typing.List[FieldElement], call_type:CallType, caller_address:FieldElement): + self.contract_address = contract_address + self.entrypoint = entrypoint + self.calldata = calldata + self.call_type = call_type + self.caller_address = caller_address + + + + + def __str__(self): + return "TransactionCall(contract_address={}, entrypoint={}, calldata={}, call_type={}, caller_address={})".format(self.contract_address, self.entrypoint, self.calldata, self.call_type, self.caller_address) + def __eq__(self, other): + if self.contract_address != other.contract_address: + return False + if self.entrypoint != other.entrypoint: + return False + if self.calldata != other.calldata: + return False + if self.call_type != other.call_type: + return False + if self.caller_address != other.caller_address: + return False + return True + +class _UniffiFfiConverterTypeTransactionCall(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TransactionCall( + contract_address=_UniffiFfiConverterTypeFieldElement.read(buf), + entrypoint=_UniffiFfiConverterString.read(buf), + calldata=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + call_type=_UniffiFfiConverterTypeCallType.read(buf), + caller_address=_UniffiFfiConverterTypeFieldElement.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.contract_address) + _UniffiFfiConverterString.check_lower(value.entrypoint) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.calldata) + _UniffiFfiConverterTypeCallType.check_lower(value.call_type) + _UniffiFfiConverterTypeFieldElement.check_lower(value.caller_address) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.contract_address, buf) + _UniffiFfiConverterString.write(value.entrypoint, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.calldata, buf) + _UniffiFfiConverterTypeCallType.write(value.call_type, buf) + _UniffiFfiConverterTypeFieldElement.write(value.caller_address, buf) + +class _UniffiFfiConverterSequenceTypeTransactionCall(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTransactionCall.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTransactionCall.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTransactionCall.read(buf) for i in range(count) + ] + +@dataclass +class Transaction: + def __init__(self, *, transaction_hash:FieldElement, sender_address:FieldElement, calldata:typing.List[FieldElement], max_fee:FieldElement, signature:typing.List[FieldElement], nonce:FieldElement, block_number:int, transaction_type:str, block_timestamp:int, calls:typing.List[TransactionCall], unique_models:typing.List[FieldElement]): + self.transaction_hash = transaction_hash + self.sender_address = sender_address + self.calldata = calldata + self.max_fee = max_fee + self.signature = signature + self.nonce = nonce + self.block_number = block_number + self.transaction_type = transaction_type + self.block_timestamp = block_timestamp + self.calls = calls + self.unique_models = unique_models + + + + + def __str__(self): + return "Transaction(transaction_hash={}, sender_address={}, calldata={}, max_fee={}, signature={}, nonce={}, block_number={}, transaction_type={}, block_timestamp={}, calls={}, unique_models={})".format(self.transaction_hash, self.sender_address, self.calldata, self.max_fee, self.signature, self.nonce, self.block_number, self.transaction_type, self.block_timestamp, self.calls, self.unique_models) + def __eq__(self, other): + if self.transaction_hash != other.transaction_hash: + return False + if self.sender_address != other.sender_address: + return False + if self.calldata != other.calldata: + return False + if self.max_fee != other.max_fee: + return False + if self.signature != other.signature: + return False + if self.nonce != other.nonce: + return False + if self.block_number != other.block_number: + return False + if self.transaction_type != other.transaction_type: + return False + if self.block_timestamp != other.block_timestamp: + return False + if self.calls != other.calls: + return False + if self.unique_models != other.unique_models: + return False + return True + +class _UniffiFfiConverterTypeTransaction(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Transaction( + transaction_hash=_UniffiFfiConverterTypeFieldElement.read(buf), + sender_address=_UniffiFfiConverterTypeFieldElement.read(buf), + calldata=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + max_fee=_UniffiFfiConverterTypeFieldElement.read(buf), + signature=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + nonce=_UniffiFfiConverterTypeFieldElement.read(buf), + block_number=_UniffiFfiConverterUInt64.read(buf), + transaction_type=_UniffiFfiConverterString.read(buf), + block_timestamp=_UniffiFfiConverterUInt64.read(buf), + calls=_UniffiFfiConverterSequenceTypeTransactionCall.read(buf), + unique_models=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.transaction_hash) + _UniffiFfiConverterTypeFieldElement.check_lower(value.sender_address) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.calldata) + _UniffiFfiConverterTypeFieldElement.check_lower(value.max_fee) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.signature) + _UniffiFfiConverterTypeFieldElement.check_lower(value.nonce) + _UniffiFfiConverterUInt64.check_lower(value.block_number) + _UniffiFfiConverterString.check_lower(value.transaction_type) + _UniffiFfiConverterUInt64.check_lower(value.block_timestamp) + _UniffiFfiConverterSequenceTypeTransactionCall.check_lower(value.calls) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.unique_models) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.transaction_hash, buf) + _UniffiFfiConverterTypeFieldElement.write(value.sender_address, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.calldata, buf) + _UniffiFfiConverterTypeFieldElement.write(value.max_fee, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.signature, buf) + _UniffiFfiConverterTypeFieldElement.write(value.nonce, buf) + _UniffiFfiConverterUInt64.write(value.block_number, buf) + _UniffiFfiConverterString.write(value.transaction_type, buf) + _UniffiFfiConverterUInt64.write(value.block_timestamp, buf) + _UniffiFfiConverterSequenceTypeTransactionCall.write(value.calls, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.unique_models, buf) + +class _UniffiFfiConverterSequenceTypeTransaction(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeTransaction.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeTransaction.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeTransaction.read(buf) for i in range(count) + ] + +@dataclass +class PageTransaction: + def __init__(self, *, items:typing.List[Transaction], next_cursor:typing.Optional[str]): + self.items = items + self.next_cursor = next_cursor + + + + + def __str__(self): + return "PageTransaction(items={}, next_cursor={})".format(self.items, self.next_cursor) + def __eq__(self, other): + if self.items != other.items: + return False + if self.next_cursor != other.next_cursor: + return False + return True + +class _UniffiFfiConverterTypePageTransaction(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PageTransaction( + items=_UniffiFfiConverterSequenceTypeTransaction.read(buf), + next_cursor=_UniffiFfiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeTransaction.check_lower(value.items) + _UniffiFfiConverterOptionalString.check_lower(value.next_cursor) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeTransaction.write(value.items, buf) + _UniffiFfiConverterOptionalString.write(value.next_cursor, buf) + +@dataclass +class PlayerAchievementQuery: + def __init__(self, *, world_addresses:typing.List[FieldElement], namespaces:typing.List[str], player_addresses:typing.List[FieldElement], pagination:Pagination): + self.world_addresses = world_addresses + self.namespaces = namespaces + self.player_addresses = player_addresses + self.pagination = pagination + + + + + def __str__(self): + return "PlayerAchievementQuery(world_addresses={}, namespaces={}, player_addresses={}, pagination={})".format(self.world_addresses, self.namespaces, self.player_addresses, self.pagination) + def __eq__(self, other): + if self.world_addresses != other.world_addresses: + return False + if self.namespaces != other.namespaces: + return False + if self.player_addresses != other.player_addresses: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypePlayerAchievementQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PlayerAchievementQuery( + world_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + namespaces=_UniffiFfiConverterSequenceString.read(buf), + player_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.world_addresses) + _UniffiFfiConverterSequenceString.check_lower(value.namespaces) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.player_addresses) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.world_addresses, buf) + _UniffiFfiConverterSequenceString.write(value.namespaces, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.player_addresses, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +class _UniffiFfiConverterOptionalTypeClause(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterTypeClause.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterTypeClause.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterTypeClause.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class Query: + def __init__(self, *, world_addresses:typing.List[FieldElement], pagination:Pagination, clause:typing.Optional[Clause], no_hashed_keys:bool, models:typing.List[str], historical:bool): + self.world_addresses = world_addresses + self.pagination = pagination + self.clause = clause + self.no_hashed_keys = no_hashed_keys + self.models = models + self.historical = historical + + + + + def __str__(self): + return "Query(world_addresses={}, pagination={}, clause={}, no_hashed_keys={}, models={}, historical={})".format(self.world_addresses, self.pagination, self.clause, self.no_hashed_keys, self.models, self.historical) + def __eq__(self, other): + if self.world_addresses != other.world_addresses: + return False + if self.pagination != other.pagination: + return False + if self.clause != other.clause: + return False + if self.no_hashed_keys != other.no_hashed_keys: + return False + if self.models != other.models: + return False + if self.historical != other.historical: + return False + return True + +class _UniffiFfiConverterTypeQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Query( + world_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + clause=_UniffiFfiConverterOptionalTypeClause.read(buf), + no_hashed_keys=_UniffiFfiConverterBoolean.read(buf), + models=_UniffiFfiConverterSequenceString.read(buf), + historical=_UniffiFfiConverterBoolean.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.world_addresses) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + _UniffiFfiConverterOptionalTypeClause.check_lower(value.clause) + _UniffiFfiConverterBoolean.check_lower(value.no_hashed_keys) + _UniffiFfiConverterSequenceString.check_lower(value.models) + _UniffiFfiConverterBoolean.check_lower(value.historical) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.world_addresses, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + _UniffiFfiConverterOptionalTypeClause.write(value.clause, buf) + _UniffiFfiConverterBoolean.write(value.no_hashed_keys, buf) + _UniffiFfiConverterSequenceString.write(value.models, buf) + _UniffiFfiConverterBoolean.write(value.historical, buf) + +@dataclass +class Signature: + def __init__(self, *, r:FieldElement, s:FieldElement): + self.r = r + self.s = s + + + + + def __str__(self): + return "Signature(r={}, s={})".format(self.r, self.s) + def __eq__(self, other): + if self.r != other.r: + return False + if self.s != other.s: + return False + return True + +class _UniffiFfiConverterTypeSignature(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Signature( + r=_UniffiFfiConverterTypeFieldElement.read(buf), + s=_UniffiFfiConverterTypeFieldElement.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.r) + _UniffiFfiConverterTypeFieldElement.check_lower(value.s) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.r, buf) + _UniffiFfiConverterTypeFieldElement.write(value.s, buf) + + + + + + +class SqlValue: + def __init__(self): + raise RuntimeError("SqlValue cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class TEXT: + + def __init__(self, value:str): + self.value = value + + + pass + + + + + + def __str__(self): + return "SqlValue.TEXT(value={})".format(self.value) + def __eq__(self, other): + if not other.is_TEXT(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class INTEGER: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "SqlValue.INTEGER(value={})".format(self.value) + def __eq__(self, other): + if not other.is_INTEGER(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class REAL: + + def __init__(self, value:float): + self.value = value + + + pass + + + + + + def __str__(self): + return "SqlValue.REAL(value={})".format(self.value) + def __eq__(self, other): + if not other.is_REAL(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class BLOB: + + def __init__(self, value:typing.List[int]): + self.value = value + + + pass + + + + + + def __str__(self): + return "SqlValue.BLOB(value={})".format(self.value) + def __eq__(self, other): + if not other.is_BLOB(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class NULL: + + def __init__(self, ): + pass + + + + + + def __str__(self): + return "SqlValue.NULL()".format() + def __eq__(self, other): + if not other.is_NULL(): + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_TEXT(self) -> bool: + return isinstance(self, SqlValue.TEXT) + def is_text(self) -> bool: + return isinstance(self, SqlValue.TEXT) + def is_INTEGER(self) -> bool: + return isinstance(self, SqlValue.INTEGER) + def is_integer(self) -> bool: + return isinstance(self, SqlValue.INTEGER) + def is_REAL(self) -> bool: + return isinstance(self, SqlValue.REAL) + def is_real(self) -> bool: + return isinstance(self, SqlValue.REAL) + def is_BLOB(self) -> bool: + return isinstance(self, SqlValue.BLOB) + def is_blob(self) -> bool: + return isinstance(self, SqlValue.BLOB) + def is_NULL(self) -> bool: + return isinstance(self, SqlValue.NULL) + def is_null(self) -> bool: + return isinstance(self, SqlValue.NULL) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +SqlValue.TEXT = type("SqlValue.TEXT", (SqlValue.TEXT, SqlValue,), {}) # type: ignore +SqlValue.INTEGER = type("SqlValue.INTEGER", (SqlValue.INTEGER, SqlValue,), {}) # type: ignore +SqlValue.REAL = type("SqlValue.REAL", (SqlValue.REAL, SqlValue,), {}) # type: ignore +SqlValue.BLOB = type("SqlValue.BLOB", (SqlValue.BLOB, SqlValue,), {}) # type: ignore +SqlValue.NULL = type("SqlValue.NULL", (SqlValue.NULL, SqlValue,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypeSqlValue(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return SqlValue.TEXT( + _UniffiFfiConverterString.read(buf), + ) + if variant == 2: + return SqlValue.INTEGER( + _UniffiFfiConverterInt64.read(buf), + ) + if variant == 3: + return SqlValue.REAL( + _UniffiFfiConverterFloat64.read(buf), + ) + if variant == 4: + return SqlValue.BLOB( + _UniffiFfiConverterSequenceUInt8.read(buf), + ) + if variant == 5: + return SqlValue.NULL( + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_TEXT(): + _UniffiFfiConverterString.check_lower(value.value) + return + if value.is_INTEGER(): + _UniffiFfiConverterInt64.check_lower(value.value) + return + if value.is_REAL(): + _UniffiFfiConverterFloat64.check_lower(value.value) + return + if value.is_BLOB(): + _UniffiFfiConverterSequenceUInt8.check_lower(value.value) + return + if value.is_NULL(): + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_TEXT(): + buf.write_i32(1) + _UniffiFfiConverterString.write(value.value, buf) + if value.is_INTEGER(): + buf.write_i32(2) + _UniffiFfiConverterInt64.write(value.value, buf) + if value.is_REAL(): + buf.write_i32(3) + _UniffiFfiConverterFloat64.write(value.value, buf) + if value.is_BLOB(): + buf.write_i32(4) + _UniffiFfiConverterSequenceUInt8.write(value.value, buf) + if value.is_NULL(): + buf.write_i32(5) + + + +@dataclass +class SqlField: + def __init__(self, *, name:str, value:SqlValue): + self.name = name + self.value = value + + + + + def __str__(self): + return "SqlField(name={}, value={})".format(self.name, self.value) + def __eq__(self, other): + if self.name != other.name: + return False + if self.value != other.value: + return False + return True + +class _UniffiFfiConverterTypeSqlField(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return SqlField( + name=_UniffiFfiConverterString.read(buf), + value=_UniffiFfiConverterTypeSqlValue.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterString.check_lower(value.name) + _UniffiFfiConverterTypeSqlValue.check_lower(value.value) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterString.write(value.name, buf) + _UniffiFfiConverterTypeSqlValue.write(value.value, buf) + +class _UniffiFfiConverterSequenceTypeSqlField(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeSqlField.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeSqlField.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeSqlField.read(buf) for i in range(count) + ] + +@dataclass +class SqlRow: + def __init__(self, *, fields:typing.List[SqlField]): + self.fields = fields + + + + + def __str__(self): + return "SqlRow(fields={})".format(self.fields) + def __eq__(self, other): + if self.fields != other.fields: + return False + return True + +class _UniffiFfiConverterTypeSqlRow(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return SqlRow( + fields=_UniffiFfiConverterSequenceTypeSqlField.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeSqlField.check_lower(value.fields) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeSqlField.write(value.fields, buf) + +class _UniffiFfiConverterSequenceTypeU256(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeU256.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeU256.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeU256.read(buf) for i in range(count) + ] + +@dataclass +class TokenBalanceQuery: + def __init__(self, *, contract_addresses:typing.List[FieldElement], account_addresses:typing.List[FieldElement], token_ids:typing.List[U256], pagination:Pagination): + self.contract_addresses = contract_addresses + self.account_addresses = account_addresses + self.token_ids = token_ids + self.pagination = pagination + + + + + def __str__(self): + return "TokenBalanceQuery(contract_addresses={}, account_addresses={}, token_ids={}, pagination={})".format(self.contract_addresses, self.account_addresses, self.token_ids, self.pagination) + def __eq__(self, other): + if self.contract_addresses != other.contract_addresses: + return False + if self.account_addresses != other.account_addresses: + return False + if self.token_ids != other.token_ids: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeTokenBalanceQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenBalanceQuery( + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + account_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + token_ids=_UniffiFfiConverterSequenceTypeU256.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.account_addresses) + _UniffiFfiConverterSequenceTypeU256.check_lower(value.token_ids) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.account_addresses, buf) + _UniffiFfiConverterSequenceTypeU256.write(value.token_ids, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class TokenContractQuery: + def __init__(self, *, contract_addresses:typing.List[FieldElement], contract_types:typing.List[ContractType], pagination:Pagination): + self.contract_addresses = contract_addresses + self.contract_types = contract_types + self.pagination = pagination + + + + + def __str__(self): + return "TokenContractQuery(contract_addresses={}, contract_types={}, pagination={})".format(self.contract_addresses, self.contract_types, self.pagination) + def __eq__(self, other): + if self.contract_addresses != other.contract_addresses: + return False + if self.contract_types != other.contract_types: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeTokenContractQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenContractQuery( + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + contract_types=_UniffiFfiConverterSequenceTypeContractType.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceTypeContractType.check_lower(value.contract_types) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceTypeContractType.write(value.contract_types, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +class _UniffiFfiConverterSequenceTypeAttributeFilter(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeAttributeFilter.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeAttributeFilter.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeAttributeFilter.read(buf) for i in range(count) + ] + +@dataclass +class TokenQuery: + def __init__(self, *, contract_addresses:typing.List[FieldElement], token_ids:typing.List[U256], attribute_filters:typing.List[AttributeFilter], pagination:Pagination): + self.contract_addresses = contract_addresses + self.token_ids = token_ids + self.attribute_filters = attribute_filters + self.pagination = pagination + + + + + def __str__(self): + return "TokenQuery(contract_addresses={}, token_ids={}, attribute_filters={}, pagination={})".format(self.contract_addresses, self.token_ids, self.attribute_filters, self.pagination) + def __eq__(self, other): + if self.contract_addresses != other.contract_addresses: + return False + if self.token_ids != other.token_ids: + return False + if self.attribute_filters != other.attribute_filters: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeTokenQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenQuery( + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + token_ids=_UniffiFfiConverterSequenceTypeU256.read(buf), + attribute_filters=_UniffiFfiConverterSequenceTypeAttributeFilter.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceTypeU256.check_lower(value.token_ids) + _UniffiFfiConverterSequenceTypeAttributeFilter.check_lower(value.attribute_filters) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceTypeU256.write(value.token_ids, buf) + _UniffiFfiConverterSequenceTypeAttributeFilter.write(value.attribute_filters, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class TokenTransferQuery: + def __init__(self, *, contract_addresses:typing.List[FieldElement], account_addresses:typing.List[FieldElement], token_ids:typing.List[U256], pagination:Pagination): + self.contract_addresses = contract_addresses + self.account_addresses = account_addresses + self.token_ids = token_ids + self.pagination = pagination + + + + + def __str__(self): + return "TokenTransferQuery(contract_addresses={}, account_addresses={}, token_ids={}, pagination={})".format(self.contract_addresses, self.account_addresses, self.token_ids, self.pagination) + def __eq__(self, other): + if self.contract_addresses != other.contract_addresses: + return False + if self.account_addresses != other.account_addresses: + return False + if self.token_ids != other.token_ids: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeTokenTransferQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TokenTransferQuery( + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + account_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + token_ids=_UniffiFfiConverterSequenceTypeU256.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.account_addresses) + _UniffiFfiConverterSequenceTypeU256.check_lower(value.token_ids) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.account_addresses, buf) + _UniffiFfiConverterSequenceTypeU256.write(value.token_ids, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +@dataclass +class TransactionFilter: + def __init__(self, *, transaction_hashes:typing.List[FieldElement], caller_addresses:typing.List[FieldElement], contract_addresses:typing.List[FieldElement], entrypoints:typing.List[str], model_selectors:typing.List[FieldElement], from_block:typing.Optional[int], to_block:typing.Optional[int]): + self.transaction_hashes = transaction_hashes + self.caller_addresses = caller_addresses + self.contract_addresses = contract_addresses + self.entrypoints = entrypoints + self.model_selectors = model_selectors + self.from_block = from_block + self.to_block = to_block + + + + + def __str__(self): + return "TransactionFilter(transaction_hashes={}, caller_addresses={}, contract_addresses={}, entrypoints={}, model_selectors={}, from_block={}, to_block={})".format(self.transaction_hashes, self.caller_addresses, self.contract_addresses, self.entrypoints, self.model_selectors, self.from_block, self.to_block) + def __eq__(self, other): + if self.transaction_hashes != other.transaction_hashes: + return False + if self.caller_addresses != other.caller_addresses: + return False + if self.contract_addresses != other.contract_addresses: + return False + if self.entrypoints != other.entrypoints: + return False + if self.model_selectors != other.model_selectors: + return False + if self.from_block != other.from_block: + return False + if self.to_block != other.to_block: + return False + return True + +class _UniffiFfiConverterTypeTransactionFilter(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TransactionFilter( + transaction_hashes=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + caller_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + contract_addresses=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + entrypoints=_UniffiFfiConverterSequenceString.read(buf), + model_selectors=_UniffiFfiConverterSequenceTypeFieldElement.read(buf), + from_block=_UniffiFfiConverterOptionalUInt64.read(buf), + to_block=_UniffiFfiConverterOptionalUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.transaction_hashes) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.caller_addresses) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.contract_addresses) + _UniffiFfiConverterSequenceString.check_lower(value.entrypoints) + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(value.model_selectors) + _UniffiFfiConverterOptionalUInt64.check_lower(value.from_block) + _UniffiFfiConverterOptionalUInt64.check_lower(value.to_block) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterSequenceTypeFieldElement.write(value.transaction_hashes, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.caller_addresses, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.contract_addresses, buf) + _UniffiFfiConverterSequenceString.write(value.entrypoints, buf) + _UniffiFfiConverterSequenceTypeFieldElement.write(value.model_selectors, buf) + _UniffiFfiConverterOptionalUInt64.write(value.from_block, buf) + _UniffiFfiConverterOptionalUInt64.write(value.to_block, buf) + +class _UniffiFfiConverterOptionalTypeTransactionFilter(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiFfiConverterTypeTransactionFilter.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiFfiConverterTypeTransactionFilter.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiFfiConverterTypeTransactionFilter.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + +@dataclass +class TransactionQuery: + def __init__(self, *, filter:typing.Optional[TransactionFilter], pagination:Pagination): + self.filter = filter + self.pagination = pagination + + + + + def __str__(self): + return "TransactionQuery(filter={}, pagination={})".format(self.filter, self.pagination) + def __eq__(self, other): + if self.filter != other.filter: + return False + if self.pagination != other.pagination: + return False + return True + +class _UniffiFfiConverterTypeTransactionQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TransactionQuery( + filter=_UniffiFfiConverterOptionalTypeTransactionFilter.read(buf), + pagination=_UniffiFfiConverterTypePagination.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterOptionalTypeTransactionFilter.check_lower(value.filter) + _UniffiFfiConverterTypePagination.check_lower(value.pagination) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterOptionalTypeTransactionFilter.write(value.filter, buf) + _UniffiFfiConverterTypePagination.write(value.pagination, buf) + +class _UniffiFfiConverterSequenceTypeModel(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeModel.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeModel.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeModel.read(buf) for i in range(count) + ] + +@dataclass +class World: + def __init__(self, *, world_address:FieldElement, models:typing.List[Model]): + self.world_address = world_address + self.models = models + + + + + def __str__(self): + return "World(world_address={}, models={})".format(self.world_address, self.models) + def __eq__(self, other): + if self.world_address != other.world_address: + return False + if self.models != other.models: + return False + return True + +class _UniffiFfiConverterTypeWorld(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return World( + world_address=_UniffiFfiConverterTypeFieldElement.read(buf), + models=_UniffiFfiConverterSequenceTypeModel.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiFfiConverterTypeFieldElement.check_lower(value.world_address) + _UniffiFfiConverterSequenceTypeModel.check_lower(value.models) + + @staticmethod + def write(value, buf): + _UniffiFfiConverterTypeFieldElement.write(value.world_address, buf) + _UniffiFfiConverterSequenceTypeModel.write(value.models, buf) + + + +# DojoError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class DojoError(Exception): + pass + +_UniffiTempDojoError = DojoError + +class DojoError: # type: ignore + + class ClientError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.ClientError({})".format(repr(str(self))) + _UniffiTempDojoError.ClientError = ClientError # type: ignore + class SerializationError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.SerializationError({})".format(repr(str(self))) + _UniffiTempDojoError.SerializationError = SerializationError # type: ignore + class NetworkError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.NetworkError({})".format(repr(str(self))) + _UniffiTempDojoError.NetworkError = NetworkError # type: ignore + class InvalidInput(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.InvalidInput({})".format(repr(str(self))) + _UniffiTempDojoError.InvalidInput = InvalidInput # type: ignore + class ConnectionError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.ConnectionError({})".format(repr(str(self))) + _UniffiTempDojoError.ConnectionError = ConnectionError # type: ignore + class PublishError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.PublishError({})".format(repr(str(self))) + _UniffiTempDojoError.PublishError = PublishError # type: ignore + class QueryError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.QueryError({})".format(repr(str(self))) + _UniffiTempDojoError.QueryError = QueryError # type: ignore + class SubscriptionError(_UniffiTempDojoError): + def __repr__(self): + return "DojoError.SubscriptionError({})".format(repr(str(self))) + _UniffiTempDojoError.SubscriptionError = SubscriptionError # type: ignore + +DojoError = _UniffiTempDojoError # type: ignore +del _UniffiTempDojoError + + +class _UniffiFfiConverterTypeDojoError(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return DojoError.ClientError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 2: + return DojoError.SerializationError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 3: + return DojoError.NetworkError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 4: + return DojoError.InvalidInput( + _UniffiFfiConverterString.read(buf), + ) + if variant == 5: + return DojoError.ConnectionError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 6: + return DojoError.PublishError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 7: + return DojoError.QueryError( + _UniffiFfiConverterString.read(buf), + ) + if variant == 8: + return DojoError.SubscriptionError( + _UniffiFfiConverterString.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if isinstance(value, DojoError.ClientError): + return + if isinstance(value, DojoError.SerializationError): + return + if isinstance(value, DojoError.NetworkError): + return + if isinstance(value, DojoError.InvalidInput): + return + if isinstance(value, DojoError.ConnectionError): + return + if isinstance(value, DojoError.PublishError): + return + if isinstance(value, DojoError.QueryError): + return + if isinstance(value, DojoError.SubscriptionError): + return + + @staticmethod + def write(value, buf): + if isinstance(value, DojoError.ClientError): + buf.write_i32(1) + if isinstance(value, DojoError.SerializationError): + buf.write_i32(2) + if isinstance(value, DojoError.NetworkError): + buf.write_i32(3) + if isinstance(value, DojoError.InvalidInput): + buf.write_i32(4) + if isinstance(value, DojoError.ConnectionError): + buf.write_i32(5) + if isinstance(value, DojoError.PublishError): + buf.write_i32(6) + if isinstance(value, DojoError.QueryError): + buf.write_i32(7) + if isinstance(value, DojoError.SubscriptionError): + buf.write_i32(8) + + + + + + +class ValueType: + def __init__(self): + raise RuntimeError("ValueType cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + @dataclass + class STRING: + + def __init__(self, value:str): + self.value = value + + + pass + + + + + + def __str__(self): + return "ValueType.STRING(value={})".format(self.value) + def __eq__(self, other): + if not other.is_STRING(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class INT: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "ValueType.INT(value={})".format(self.value) + def __eq__(self, other): + if not other.is_INT(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class U_INT: + + def __init__(self, value:int): + self.value = value + + + pass + + + + + + def __str__(self): + return "ValueType.U_INT(value={})".format(self.value) + def __eq__(self, other): + if not other.is_U_INT(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class BOOL: + + def __init__(self, value:bool): + self.value = value + + + pass + + + + + + def __str__(self): + return "ValueType.BOOL(value={})".format(self.value) + def __eq__(self, other): + if not other.is_BOOL(): + return False + if self.value != other.value: + return False + return True + + @dataclass + class BYTES: + + def __init__(self, value:typing.List[int]): + self.value = value + + + pass + + + + + + def __str__(self): + return "ValueType.BYTES(value={})".format(self.value) + def __eq__(self, other): + if not other.is_BYTES(): + return False + if self.value != other.value: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_STRING(self) -> bool: + return isinstance(self, ValueType.STRING) + def is_string(self) -> bool: + return isinstance(self, ValueType.STRING) + def is_INT(self) -> bool: + return isinstance(self, ValueType.INT) + def is_int(self) -> bool: + return isinstance(self, ValueType.INT) + def is_U_INT(self) -> bool: + return isinstance(self, ValueType.U_INT) + def is_u_int(self) -> bool: + return isinstance(self, ValueType.U_INT) + def is_BOOL(self) -> bool: + return isinstance(self, ValueType.BOOL) + def is_bool(self) -> bool: + return isinstance(self, ValueType.BOOL) + def is_BYTES(self) -> bool: + return isinstance(self, ValueType.BYTES) + def is_bytes(self) -> bool: + return isinstance(self, ValueType.BYTES) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +ValueType.STRING = type("ValueType.STRING", (ValueType.STRING, ValueType,), {}) # type: ignore +ValueType.INT = type("ValueType.INT", (ValueType.INT, ValueType,), {}) # type: ignore +ValueType.U_INT = type("ValueType.U_INT", (ValueType.U_INT, ValueType,), {}) # type: ignore +ValueType.BOOL = type("ValueType.BOOL", (ValueType.BOOL, ValueType,), {}) # type: ignore +ValueType.BYTES = type("ValueType.BYTES", (ValueType.BYTES, ValueType,), {}) # type: ignore + + + + +class _UniffiFfiConverterTypeValueType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return ValueType.STRING( + _UniffiFfiConverterString.read(buf), + ) + if variant == 2: + return ValueType.INT( + _UniffiFfiConverterInt64.read(buf), + ) + if variant == 3: + return ValueType.U_INT( + _UniffiFfiConverterUInt64.read(buf), + ) + if variant == 4: + return ValueType.BOOL( + _UniffiFfiConverterBoolean.read(buf), + ) + if variant == 5: + return ValueType.BYTES( + _UniffiFfiConverterSequenceUInt8.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_STRING(): + _UniffiFfiConverterString.check_lower(value.value) + return + if value.is_INT(): + _UniffiFfiConverterInt64.check_lower(value.value) + return + if value.is_U_INT(): + _UniffiFfiConverterUInt64.check_lower(value.value) + return + if value.is_BOOL(): + _UniffiFfiConverterBoolean.check_lower(value.value) + return + if value.is_BYTES(): + _UniffiFfiConverterSequenceUInt8.check_lower(value.value) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_STRING(): + buf.write_i32(1) + _UniffiFfiConverterString.write(value.value, buf) + if value.is_INT(): + buf.write_i32(2) + _UniffiFfiConverterInt64.write(value.value, buf) + if value.is_U_INT(): + buf.write_i32(3) + _UniffiFfiConverterUInt64.write(value.value, buf) + if value.is_BOOL(): + buf.write_i32(4) + _UniffiFfiConverterBoolean.write(value.value, buf) + if value.is_BYTES(): + buf.write_i32(5) + _UniffiFfiConverterSequenceUInt8.write(value.value, buf) + + + +class _UniffiFfiConverterSequenceTypeContract(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeContract.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeContract.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeContract.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterSequenceTypeMessage(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeMessage.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeMessage.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeMessage.read(buf) for i in range(count) + ] + +class _UniffiFfiConverterSequenceTypeSqlRow(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeSqlRow.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeSqlRow.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeSqlRow.read(buf) for i in range(count) + ] + + + + +class EntityUpdateCallback(typing.Protocol): + + def on_update(self, entity: Entity) -> None: + raise NotImplementedError + def on_error(self, error: str) -> None: + raise NotImplementedError +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplEntityUpdateCallbackImpl: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD0 + def on_update( + uniffi_handle, + entity, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeEntityUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterTypeEntity.lift(entity), ) + uniffi_method = uniffi_obj.on_update + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_ENTITY_UPDATE_CALLBACK_METHOD1 + def on_error( + uniffi_handle, + error, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeEntityUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterString.lift(error), ) + uniffi_method = uniffi_obj.on_error + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_ENTITY_UPDATE_CALLBACK + def _uniffi_free(uniffi_handle): + _UniffiFfiConverterTypeEntityUpdateCallback._handle_map.remove(uniffi_handle) + + @_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_ENTITY_UPDATE_CALLBACK + def _uniffi_clone(uniffi_handle): + return _UniffiFfiConverterTypeEntityUpdateCallback._handle_map.clone(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceDojoEntityUpdateCallback( + _uniffi_free, + _uniffi_clone, + on_update, + on_error, + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiFfiConverterTypeEntityUpdateCallback = _UniffiCallbackInterfaceFfiConverter() + +class _UniffiFfiConverterSequenceTypeKeysClause(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeKeysClause.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeKeysClause.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeKeysClause.read(buf) for i in range(count) + ] + + + + +class EventUpdateCallback(typing.Protocol): + + def on_update(self, event: Event) -> None: + raise NotImplementedError + def on_error(self, error: str) -> None: + raise NotImplementedError +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplEventUpdateCallbackImpl: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD0 + def on_update( + uniffi_handle, + event, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeEventUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterTypeEvent.lift(event), ) + uniffi_method = uniffi_obj.on_update + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_EVENT_UPDATE_CALLBACK_METHOD1 + def on_error( + uniffi_handle, + error, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeEventUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterString.lift(error), ) + uniffi_method = uniffi_obj.on_error + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_EVENT_UPDATE_CALLBACK + def _uniffi_free(uniffi_handle): + _UniffiFfiConverterTypeEventUpdateCallback._handle_map.remove(uniffi_handle) + + @_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_EVENT_UPDATE_CALLBACK + def _uniffi_clone(uniffi_handle): + return _UniffiFfiConverterTypeEventUpdateCallback._handle_map.clone(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceDojoEventUpdateCallback( + _uniffi_free, + _uniffi_clone, + on_update, + on_error, + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiFfiConverterTypeEventUpdateCallback = _UniffiCallbackInterfaceFfiConverter() + + + + +class TokenBalanceUpdateCallback(typing.Protocol): + + def on_update(self, balance: TokenBalance) -> None: + raise NotImplementedError + def on_error(self, error: str) -> None: + raise NotImplementedError +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplTokenBalanceUpdateCallbackImpl: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD0 + def on_update( + uniffi_handle, + balance, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTokenBalanceUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterTypeTokenBalance.lift(balance), ) + uniffi_method = uniffi_obj.on_update + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD1 + def on_error( + uniffi_handle, + error, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTokenBalanceUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterString.lift(error), ) + uniffi_method = uniffi_obj.on_error + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK + def _uniffi_free(uniffi_handle): + _UniffiFfiConverterTypeTokenBalanceUpdateCallback._handle_map.remove(uniffi_handle) + + @_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_BALANCE_UPDATE_CALLBACK + def _uniffi_clone(uniffi_handle): + return _UniffiFfiConverterTypeTokenBalanceUpdateCallback._handle_map.clone(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceDojoTokenBalanceUpdateCallback( + _uniffi_free, + _uniffi_clone, + on_update, + on_error, + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiFfiConverterTypeTokenBalanceUpdateCallback = _UniffiCallbackInterfaceFfiConverter() + + + + +class TokenUpdateCallback(typing.Protocol): + + def on_update(self, token: Token) -> None: + raise NotImplementedError + def on_error(self, error: str) -> None: + raise NotImplementedError +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplTokenUpdateCallbackImpl: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD0 + def on_update( + uniffi_handle, + token, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTokenUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterTypeToken.lift(token), ) + uniffi_method = uniffi_obj.on_update + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TOKEN_UPDATE_CALLBACK_METHOD1 + def on_error( + uniffi_handle, + error, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTokenUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterString.lift(error), ) + uniffi_method = uniffi_obj.on_error + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TOKEN_UPDATE_CALLBACK + def _uniffi_free(uniffi_handle): + _UniffiFfiConverterTypeTokenUpdateCallback._handle_map.remove(uniffi_handle) + + @_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TOKEN_UPDATE_CALLBACK + def _uniffi_clone(uniffi_handle): + return _UniffiFfiConverterTypeTokenUpdateCallback._handle_map.clone(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceDojoTokenUpdateCallback( + _uniffi_free, + _uniffi_clone, + on_update, + on_error, + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiFfiConverterTypeTokenUpdateCallback = _UniffiCallbackInterfaceFfiConverter() + + + + +class TransactionUpdateCallback(typing.Protocol): + + def on_update(self, transaction: Transaction) -> None: + raise NotImplementedError + def on_error(self, error: str) -> None: + raise NotImplementedError +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplTransactionUpdateCallbackImpl: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD0 + def on_update( + uniffi_handle, + transaction, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTransactionUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterTypeTransaction.lift(transaction), ) + uniffi_method = uniffi_obj.on_update + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_DOJO_TRANSACTION_UPDATE_CALLBACK_METHOD1 + def on_error( + uniffi_handle, + error, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiFfiConverterTypeTransactionUpdateCallback._handle_map.get(uniffi_handle) + def make_call(): + uniffi_args = (_UniffiFfiConverterString.lift(error), ) + uniffi_method = uniffi_obj.on_error + return uniffi_method(*uniffi_args) + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE_DOJO_TRANSACTION_UPDATE_CALLBACK + def _uniffi_free(uniffi_handle): + _UniffiFfiConverterTypeTransactionUpdateCallback._handle_map.remove(uniffi_handle) + + @_UNIFFI_CALLBACK_INTERFACE_CLONE_DOJO_TRANSACTION_UPDATE_CALLBACK + def _uniffi_clone(uniffi_handle): + return _UniffiFfiConverterTypeTransactionUpdateCallback._handle_map.clone(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceDojoTransactionUpdateCallback( + _uniffi_free, + _uniffi_clone, + on_update, + on_error, + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiFfiConverterTypeTransactionUpdateCallback = _UniffiCallbackInterfaceFfiConverter() + +class _UniffiFfiConverterSequenceTypeWorld(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiFfiConverterTypeWorld.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiFfiConverterTypeWorld.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiFfiConverterTypeWorld.read(buf) for i in range(count) + ] + + +class ToriiClientProtocol(typing.Protocol): + + def achievements(self, query: AchievementQuery) -> PageAchievement: + raise NotImplementedError + def activities(self, query: ActivityQuery) -> PageActivity: + raise NotImplementedError + def aggregations(self, query: AggregationQuery) -> PageAggregationEntry: + raise NotImplementedError + def cancel_subscription(self, subscription_id: int) -> None: + raise NotImplementedError + def contracts(self, query: ContractQuery) -> typing.List[Contract]: + raise NotImplementedError + def controllers(self, query: ControllerQuery) -> PageController: + raise NotImplementedError + def entities(self, query: Query) -> PageEntity: + raise NotImplementedError + def event_messages(self, query: Query) -> PageEntity: + raise NotImplementedError + def player_achievements(self, query: PlayerAchievementQuery) -> PagePlayerAchievement: + raise NotImplementedError + def publish_message(self, message: Message) -> str: + raise NotImplementedError + def publish_message_batch(self, messages: typing.List[Message]) -> typing.List[str]: + raise NotImplementedError + def sql(self, query: str) -> typing.List[SqlRow]: + raise NotImplementedError + def starknet_events(self, query: EventQuery) -> PageEvent: + raise NotImplementedError + def subscribe_entity_updates(self, clause: typing.Optional[Clause],world_addresses: typing.List[FieldElement],callback: EntityUpdateCallback) -> int: + raise NotImplementedError + def subscribe_event_updates(self, keys: typing.List[KeysClause],callback: EventUpdateCallback) -> int: + raise NotImplementedError + def subscribe_token_balance_updates(self, contract_addresses: typing.List[FieldElement],account_addresses: typing.List[FieldElement],token_ids: typing.List[U256],callback: TokenBalanceUpdateCallback) -> int: + raise NotImplementedError + def subscribe_token_updates(self, contract_addresses: typing.List[FieldElement],token_ids: typing.List[U256],callback: TokenUpdateCallback) -> int: + raise NotImplementedError + def subscribe_transaction_updates(self, filter: typing.Optional[TransactionFilter],callback: TransactionUpdateCallback) -> int: + raise NotImplementedError + def token_balances(self, query: TokenBalanceQuery) -> PageTokenBalance: + raise NotImplementedError + def token_contracts(self, query: TokenContractQuery) -> PageTokenContract: + raise NotImplementedError + def token_transfers(self, query: TokenTransferQuery) -> PageTokenTransfer: + raise NotImplementedError + def tokens(self, query: TokenQuery) -> PageToken: + raise NotImplementedError + def transactions(self, query: TransactionQuery) -> PageTransaction: + raise NotImplementedError + def worlds(self, world_addresses: typing.List[FieldElement]) -> typing.List[World]: + raise NotImplementedError + +class ToriiClient(ToriiClientProtocol): + + _handle: ctypes.c_uint64 + def __init__(self, torii_url: str): + + _UniffiFfiConverterString.check_lower(torii_url) + _uniffi_lowered_args = ( + _UniffiFfiConverterString.lower(torii_url), + ) + _uniffi_lift_return = _UniffiFfiConverterTypeToriiClient.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new, + *_uniffi_lowered_args, + ) + self._handle = _uniffi_ffi_result + @classmethod + def new_with_config(cls, torii_url: str,max_message_size: int) -> ToriiClient: + + _UniffiFfiConverterString.check_lower(torii_url) + + _UniffiFfiConverterUInt64.check_lower(max_message_size) + _uniffi_lowered_args = ( + _UniffiFfiConverterString.lower(torii_url), + _UniffiFfiConverterUInt64.lower(max_message_size), + ) + _uniffi_lift_return = _UniffiFfiConverterTypeToriiClient.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config, + *_uniffi_lowered_args, + ) + return cls._uniffi_make_instance(_uniffi_ffi_result) + + def __del__(self): + # In case of partial initialization of instances. + handle = getattr(self, "_handle", None) + if handle is not None: + _uniffi_rust_call(_UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient, handle) + + def _uniffi_clone_handle(self): + return _uniffi_rust_call(_UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient, self._handle) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _uniffi_make_instance(cls, handle): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required handle. + inst = cls.__new__(cls) + inst._handle = handle + return inst + def achievements(self, query: AchievementQuery) -> PageAchievement: + + _UniffiFfiConverterTypeAchievementQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeAchievementQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageAchievement.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def activities(self, query: ActivityQuery) -> PageActivity: + + _UniffiFfiConverterTypeActivityQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeActivityQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageActivity.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def aggregations(self, query: AggregationQuery) -> PageAggregationEntry: + + _UniffiFfiConverterTypeAggregationQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeAggregationQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageAggregationEntry.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def cancel_subscription(self, subscription_id: int) -> None: + + _UniffiFfiConverterUInt64.check_lower(subscription_id) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterUInt64.lower(subscription_id), + ) + _uniffi_lift_return = lambda val: None + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def contracts(self, query: ContractQuery) -> typing.List[Contract]: + + _UniffiFfiConverterTypeContractQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeContractQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterSequenceTypeContract.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def controllers(self, query: ControllerQuery) -> PageController: + + _UniffiFfiConverterTypeControllerQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeControllerQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageController.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def entities(self, query: Query) -> PageEntity: + + _UniffiFfiConverterTypeQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageEntity.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def event_messages(self, query: Query) -> PageEntity: + + _UniffiFfiConverterTypeQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageEntity.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def player_achievements(self, query: PlayerAchievementQuery) -> PagePlayerAchievement: + + _UniffiFfiConverterTypePlayerAchievementQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypePlayerAchievementQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePagePlayerAchievement.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def publish_message(self, message: Message) -> str: + + _UniffiFfiConverterTypeMessage.check_lower(message) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeMessage.lower(message), + ) + _uniffi_lift_return = _UniffiFfiConverterString.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def publish_message_batch(self, messages: typing.List[Message]) -> typing.List[str]: + + _UniffiFfiConverterSequenceTypeMessage.check_lower(messages) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterSequenceTypeMessage.lower(messages), + ) + _uniffi_lift_return = _UniffiFfiConverterSequenceString.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def sql(self, query: str) -> typing.List[SqlRow]: + + _UniffiFfiConverterString.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterString.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterSequenceTypeSqlRow.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def starknet_events(self, query: EventQuery) -> PageEvent: + + _UniffiFfiConverterTypeEventQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeEventQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageEvent.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def subscribe_entity_updates(self, clause: typing.Optional[Clause],world_addresses: typing.List[FieldElement],callback: EntityUpdateCallback) -> int: + + _UniffiFfiConverterOptionalTypeClause.check_lower(clause) + + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(world_addresses) + + _UniffiFfiConverterTypeEntityUpdateCallback.check_lower(callback) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterOptionalTypeClause.lower(clause), + _UniffiFfiConverterSequenceTypeFieldElement.lower(world_addresses), + _UniffiFfiConverterTypeEntityUpdateCallback.lower(callback), + ) + _uniffi_lift_return = _UniffiFfiConverterUInt64.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def subscribe_event_updates(self, keys: typing.List[KeysClause],callback: EventUpdateCallback) -> int: + + _UniffiFfiConverterSequenceTypeKeysClause.check_lower(keys) + + _UniffiFfiConverterTypeEventUpdateCallback.check_lower(callback) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterSequenceTypeKeysClause.lower(keys), + _UniffiFfiConverterTypeEventUpdateCallback.lower(callback), + ) + _uniffi_lift_return = _UniffiFfiConverterUInt64.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def subscribe_token_balance_updates(self, contract_addresses: typing.List[FieldElement],account_addresses: typing.List[FieldElement],token_ids: typing.List[U256],callback: TokenBalanceUpdateCallback) -> int: + + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(contract_addresses) + + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(account_addresses) + + _UniffiFfiConverterSequenceTypeU256.check_lower(token_ids) + + _UniffiFfiConverterTypeTokenBalanceUpdateCallback.check_lower(callback) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterSequenceTypeFieldElement.lower(contract_addresses), + _UniffiFfiConverterSequenceTypeFieldElement.lower(account_addresses), + _UniffiFfiConverterSequenceTypeU256.lower(token_ids), + _UniffiFfiConverterTypeTokenBalanceUpdateCallback.lower(callback), + ) + _uniffi_lift_return = _UniffiFfiConverterUInt64.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def subscribe_token_updates(self, contract_addresses: typing.List[FieldElement],token_ids: typing.List[U256],callback: TokenUpdateCallback) -> int: + + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(contract_addresses) + + _UniffiFfiConverterSequenceTypeU256.check_lower(token_ids) + + _UniffiFfiConverterTypeTokenUpdateCallback.check_lower(callback) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterSequenceTypeFieldElement.lower(contract_addresses), + _UniffiFfiConverterSequenceTypeU256.lower(token_ids), + _UniffiFfiConverterTypeTokenUpdateCallback.lower(callback), + ) + _uniffi_lift_return = _UniffiFfiConverterUInt64.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def subscribe_transaction_updates(self, filter: typing.Optional[TransactionFilter],callback: TransactionUpdateCallback) -> int: + + _UniffiFfiConverterOptionalTypeTransactionFilter.check_lower(filter) + + _UniffiFfiConverterTypeTransactionUpdateCallback.check_lower(callback) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterOptionalTypeTransactionFilter.lower(filter), + _UniffiFfiConverterTypeTransactionUpdateCallback.lower(callback), + ) + _uniffi_lift_return = _UniffiFfiConverterUInt64.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def token_balances(self, query: TokenBalanceQuery) -> PageTokenBalance: + + _UniffiFfiConverterTypeTokenBalanceQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeTokenBalanceQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageTokenBalance.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def token_contracts(self, query: TokenContractQuery) -> PageTokenContract: + + _UniffiFfiConverterTypeTokenContractQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeTokenContractQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageTokenContract.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def token_transfers(self, query: TokenTransferQuery) -> PageTokenTransfer: + + _UniffiFfiConverterTypeTokenTransferQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeTokenTransferQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageTokenTransfer.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def tokens(self, query: TokenQuery) -> PageToken: + + _UniffiFfiConverterTypeTokenQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeTokenQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageToken.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def transactions(self, query: TransactionQuery) -> PageTransaction: + + _UniffiFfiConverterTypeTransactionQuery.check_lower(query) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterTypeTransactionQuery.lower(query), + ) + _uniffi_lift_return = _UniffiFfiConverterTypePageTransaction.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + def worlds(self, world_addresses: typing.List[FieldElement]) -> typing.List[World]: + + _UniffiFfiConverterSequenceTypeFieldElement.check_lower(world_addresses) + _uniffi_lowered_args = ( + self._uniffi_clone_handle(), + _UniffiFfiConverterSequenceTypeFieldElement.lower(world_addresses), + ) + _uniffi_lift_return = _UniffiFfiConverterSequenceTypeWorld.lift + _uniffi_error_converter = _UniffiFfiConverterTypeDojoError + _uniffi_ffi_result = _uniffi_rust_call_with_error( + _uniffi_error_converter, + _UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds, + *_uniffi_lowered_args, + ) + return _uniffi_lift_return(_uniffi_ffi_result) + + + + + +class _UniffiFfiConverterTypeToriiClient: + @staticmethod + def lift(value: int) -> ToriiClient: + return ToriiClient._uniffi_make_instance(value) + + @staticmethod + def check_lower(value: ToriiClient): + if not isinstance(value, ToriiClient): + raise TypeError("Expected ToriiClient instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: ToriiClient) -> ctypes.c_uint64: + return value._uniffi_clone_handle() + + @classmethod + def read(cls, buf: _UniffiRustBuffer) -> ToriiClient: + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw handle value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: ToriiClient, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) + +__all__ = [ + "InternalError", + "PaginationDirection", + "OrderDirection", + "LogicalOperator", + "PatternMatching", + "ComparisonOperator", + "Primitive", + "MemberValue", + "Clause", + "ContractType", + "Ty", + "CallType", + "SqlValue", + "DojoError", + "ValueType", + "AchievementTask", + "Achievement", + "AchievementProgression", + "OrderBy", + "Pagination", + "AchievementQuery", + "ActionCount", + "Activity", + "ActivityQuery", + "AggregationEntry", + "AggregationQuery", + "AttributeFilter", + "KeysClause", + "MemberClause", + "CompositeClause", + "Contract", + "ContractQuery", + "Controller", + "ControllerQuery", + "EnumOption", + "EnumType", + "FixedSizeArray", + "Member", + "Struct", + "Entity", + "Event", + "EventQuery", + "Message", + "Model", + "PageAchievement", + "PageActivity", + "PageAggregationEntry", + "PageController", + "PageEntity", + "PageEvent", + "PlayerAchievementStats", + "TaskProgress", + "PlayerAchievementProgress", + "PlayerAchievementEntry", + "PagePlayerAchievement", + "Token", + "PageToken", + "TokenBalance", + "PageTokenBalance", + "TokenContract", + "PageTokenContract", + "TokenTransfer", + "PageTokenTransfer", + "TransactionCall", + "Transaction", + "PageTransaction", + "PlayerAchievementQuery", + "Query", + "Signature", + "SqlField", + "SqlRow", + "TokenBalanceQuery", + "TokenContractQuery", + "TokenQuery", + "TokenTransferQuery", + "TransactionFilter", + "TransactionQuery", + "World", + "ToriiClient", + "ToriiClientProtocol", + "EntityUpdateCallback", + "EventUpdateCallback", + "TokenBalanceUpdateCallback", + "TokenUpdateCallback", + "TransactionUpdateCallback", +] \ No newline at end of file diff --git a/bindings/python/libdojo_c.dylib b/bindings/python/libdojo_c.dylib new file mode 100755 index 0000000..e3c147c Binary files /dev/null and b/bindings/python/libdojo_c.dylib differ diff --git a/bindings/python/libdojo_uniffi.dylib b/bindings/python/libdojo_uniffi.dylib new file mode 100755 index 0000000..9f42b15 Binary files /dev/null and b/bindings/python/libdojo_uniffi.dylib differ diff --git a/bindings/swift/DojoEngine.swift b/bindings/swift/DojoEngine.swift new file mode 100644 index 0000000..56a1a5e --- /dev/null +++ b/bindings/swift/DojoEngine.swift @@ -0,0 +1,8395 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +// swiftlint:disable all +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(DojoEngineFFI) +import DojoEngineFFI +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func empty() -> RustBuffer { + RustBuffer(capacity: 0, len:0, data: nil) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_dojo_uniffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_dojo_uniffi_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + self.init( + bytesNoCopy: rustBuffer.data!, + count: Int(rustBuffer.len), + deallocator: .none + ) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous to the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate extension NSLock { + func withLock(f: () throws -> T) rethrows -> T { + self.lock() + defer { self.unlock() } + return try f() + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + let neverThrow: ((RustBuffer) throws -> Never)? = nil + return try makeRustCall(callback, errorHandler: neverThrow) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> E, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> E)? +) throws -> T { + uniffiEnsureDojoUniffiInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> E)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_UNEXPECTED_ERROR: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +private func uniffiTraitInterfaceCall( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> () +) { + do { + try writeReturn(makeCall()) + } catch let error { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} + +private func uniffiTraitInterfaceCallWithError( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> (), + lowerError: (E) -> RustBuffer +) { + do { + try writeReturn(makeCall()) + } catch let error as E { + callStatus.pointee.code = CALL_ERROR + callStatus.pointee.errorBuf = lowerError(error) + } catch { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} +// Initial value and increment amount for handles. +// These ensure that SWIFT handles always have the lowest bit set +fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1 +fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2 + +fileprivate final class UniffiHandleMap: @unchecked Sendable { + // All mutation happens with this lock held, which is why we implement @unchecked Sendable. + private let lock = NSLock() + private var map: [UInt64: T] = [:] + private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL + + func insert(obj: T) -> UInt64 { + lock.withLock { + return doInsert(obj) + } + } + + // Low-level insert function, this assumes `lock` is held. + private func doInsert(_ obj: T) -> UInt64 { + let handle = currentHandle + currentHandle += UNIFFI_HANDLEMAP_DELTA + map[handle] = obj + return handle + } + + func get(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + func clone(handle: UInt64) throws -> UInt64 { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return doInsert(obj) + } + } + + @discardableResult + func remove(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map.removeValue(forKey: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + var count: Int { + get { + map.count + } + } +} + + +// Public interface members begin here. +// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +private let IDX_CALLBACK_FREE: Int32 = 0 +// Callback return codes +private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 +private let UNIFFI_CALLBACK_ERROR: Int32 = 1 +private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterUInt8: FfiConverterPrimitive { + typealias FfiType = UInt8 + typealias SwiftType = UInt8 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: UInt8, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterInt8: FfiConverterPrimitive { + typealias FfiType = Int8 + typealias SwiftType = Int8 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int8 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int8, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterUInt16: FfiConverterPrimitive { + typealias FfiType = UInt16 + typealias SwiftType = UInt16 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterInt16: FfiConverterPrimitive { + typealias FfiType = Int16 + typealias SwiftType = Int16 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int16 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int16, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { + typealias FfiType = UInt32 + typealias SwiftType = UInt32 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterInt32: FfiConverterPrimitive { + typealias FfiType = Int32 + typealias SwiftType = Int32 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int32 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int32, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { + typealias FfiType = UInt64 + typealias SwiftType = UInt64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterInt64: FfiConverterPrimitive { + typealias FfiType = Int64 + typealias SwiftType = Int64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int64, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterDouble: FfiConverterPrimitive { + typealias FfiType = Double + typealias SwiftType = Double + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Double { + return try lift(readDouble(&buf)) + } + + public static func write(_ value: Double, into buf: inout [UInt8]) { + writeDouble(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterBool : FfiConverter { + typealias FfiType = Int8 + typealias SwiftType = Bool + + public static func lift(_ value: Int8) throws -> Bool { + return value != 0 + } + + public static func lower(_ value: Bool) -> Int8 { + return value ? 1 : 0 + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Bool, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + + + +public protocol ToriiClientProtocol: AnyObject, Sendable { + + func achievements(query: AchievementQuery) throws -> PageAchievement + + func activities(query: ActivityQuery) throws -> PageActivity + + func aggregations(query: AggregationQuery) throws -> PageAggregationEntry + + func cancelSubscription(subscriptionId: UInt64) throws + + func contracts(query: ContractQuery) throws -> [Contract] + + func controllers(query: ControllerQuery) throws -> PageController + + func entities(query: Query) throws -> PageEntity + + func eventMessages(query: Query) throws -> PageEntity + + func playerAchievements(query: PlayerAchievementQuery) throws -> PagePlayerAchievement + + func publishMessage(message: Message) throws -> String + + func publishMessageBatch(messages: [Message]) throws -> [String] + + func sql(query: String) throws -> [SqlRow] + + func starknetEvents(query: EventQuery) throws -> PageEvent + + func subscribeEntityUpdates(clause: Clause?, worldAddresses: [FieldElement], callback: EntityUpdateCallback) throws -> UInt64 + + func subscribeEventUpdates(keys: [KeysClause], callback: EventUpdateCallback) throws -> UInt64 + + func subscribeTokenBalanceUpdates(contractAddresses: [FieldElement], accountAddresses: [FieldElement], tokenIds: [U256], callback: TokenBalanceUpdateCallback) throws -> UInt64 + + func subscribeTokenUpdates(contractAddresses: [FieldElement], tokenIds: [U256], callback: TokenUpdateCallback) throws -> UInt64 + + func subscribeTransactionUpdates(filter: TransactionFilter?, callback: TransactionUpdateCallback) throws -> UInt64 + + func tokenBalances(query: TokenBalanceQuery) throws -> PageTokenBalance + + func tokenContracts(query: TokenContractQuery) throws -> PageTokenContract + + func tokenTransfers(query: TokenTransferQuery) throws -> PageTokenTransfer + + func tokens(query: TokenQuery) throws -> PageToken + + func transactions(query: TransactionQuery) throws -> PageTransaction + + func worlds(worldAddresses: [FieldElement]) throws -> [World] + +} +open class ToriiClient: ToriiClientProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_dojo_uniffi_fn_clone_toriiclient(self.handle, $0) } + } +public convenience init(toriiUrl: String)throws { + let handle = + try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_constructor_toriiclient_new( + FfiConverterString.lower(toriiUrl),$0 + ) +} + self.init(unsafeFromHandle: handle) +} + + deinit { + try! rustCall { uniffi_dojo_uniffi_fn_free_toriiclient(handle, $0) } + } + + +public static func newWithConfig(toriiUrl: String, maxMessageSize: UInt64)throws -> ToriiClient { + return try FfiConverterTypeToriiClient_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config( + FfiConverterString.lower(toriiUrl), + FfiConverterUInt64.lower(maxMessageSize),$0 + ) +}) +} + + + +open func achievements(query: AchievementQuery)throws -> PageAchievement { + return try FfiConverterTypePageAchievement_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_achievements( + self.uniffiCloneHandle(), + FfiConverterTypeAchievementQuery_lower(query),$0 + ) +}) +} + +open func activities(query: ActivityQuery)throws -> PageActivity { + return try FfiConverterTypePageActivity_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_activities( + self.uniffiCloneHandle(), + FfiConverterTypeActivityQuery_lower(query),$0 + ) +}) +} + +open func aggregations(query: AggregationQuery)throws -> PageAggregationEntry { + return try FfiConverterTypePageAggregationEntry_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_aggregations( + self.uniffiCloneHandle(), + FfiConverterTypeAggregationQuery_lower(query),$0 + ) +}) +} + +open func cancelSubscription(subscriptionId: UInt64)throws {try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription( + self.uniffiCloneHandle(), + FfiConverterUInt64.lower(subscriptionId),$0 + ) +} +} + +open func contracts(query: ContractQuery)throws -> [Contract] { + return try FfiConverterSequenceTypeContract.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_contracts( + self.uniffiCloneHandle(), + FfiConverterTypeContractQuery_lower(query),$0 + ) +}) +} + +open func controllers(query: ControllerQuery)throws -> PageController { + return try FfiConverterTypePageController_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_controllers( + self.uniffiCloneHandle(), + FfiConverterTypeControllerQuery_lower(query),$0 + ) +}) +} + +open func entities(query: Query)throws -> PageEntity { + return try FfiConverterTypePageEntity_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_entities( + self.uniffiCloneHandle(), + FfiConverterTypeQuery_lower(query),$0 + ) +}) +} + +open func eventMessages(query: Query)throws -> PageEntity { + return try FfiConverterTypePageEntity_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_event_messages( + self.uniffiCloneHandle(), + FfiConverterTypeQuery_lower(query),$0 + ) +}) +} + +open func playerAchievements(query: PlayerAchievementQuery)throws -> PagePlayerAchievement { + return try FfiConverterTypePagePlayerAchievement_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements( + self.uniffiCloneHandle(), + FfiConverterTypePlayerAchievementQuery_lower(query),$0 + ) +}) +} + +open func publishMessage(message: Message)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_publish_message( + self.uniffiCloneHandle(), + FfiConverterTypeMessage_lower(message),$0 + ) +}) +} + +open func publishMessageBatch(messages: [Message])throws -> [String] { + return try FfiConverterSequenceString.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch( + self.uniffiCloneHandle(), + FfiConverterSequenceTypeMessage.lower(messages),$0 + ) +}) +} + +open func sql(query: String)throws -> [SqlRow] { + return try FfiConverterSequenceTypeSqlRow.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_sql( + self.uniffiCloneHandle(), + FfiConverterString.lower(query),$0 + ) +}) +} + +open func starknetEvents(query: EventQuery)throws -> PageEvent { + return try FfiConverterTypePageEvent_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events( + self.uniffiCloneHandle(), + FfiConverterTypeEventQuery_lower(query),$0 + ) +}) +} + +open func subscribeEntityUpdates(clause: Clause?, worldAddresses: [FieldElement], callback: EntityUpdateCallback)throws -> UInt64 { + return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates( + self.uniffiCloneHandle(), + FfiConverterOptionTypeClause.lower(clause), + FfiConverterSequenceTypeFieldElement.lower(worldAddresses), + FfiConverterCallbackInterfaceEntityUpdateCallback_lower(callback),$0 + ) +}) +} + +open func subscribeEventUpdates(keys: [KeysClause], callback: EventUpdateCallback)throws -> UInt64 { + return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates( + self.uniffiCloneHandle(), + FfiConverterSequenceTypeKeysClause.lower(keys), + FfiConverterCallbackInterfaceEventUpdateCallback_lower(callback),$0 + ) +}) +} + +open func subscribeTokenBalanceUpdates(contractAddresses: [FieldElement], accountAddresses: [FieldElement], tokenIds: [U256], callback: TokenBalanceUpdateCallback)throws -> UInt64 { + return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates( + self.uniffiCloneHandle(), + FfiConverterSequenceTypeFieldElement.lower(contractAddresses), + FfiConverterSequenceTypeFieldElement.lower(accountAddresses), + FfiConverterSequenceTypeU256.lower(tokenIds), + FfiConverterCallbackInterfaceTokenBalanceUpdateCallback_lower(callback),$0 + ) +}) +} + +open func subscribeTokenUpdates(contractAddresses: [FieldElement], tokenIds: [U256], callback: TokenUpdateCallback)throws -> UInt64 { + return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates( + self.uniffiCloneHandle(), + FfiConverterSequenceTypeFieldElement.lower(contractAddresses), + FfiConverterSequenceTypeU256.lower(tokenIds), + FfiConverterCallbackInterfaceTokenUpdateCallback_lower(callback),$0 + ) +}) +} + +open func subscribeTransactionUpdates(filter: TransactionFilter?, callback: TransactionUpdateCallback)throws -> UInt64 { + return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates( + self.uniffiCloneHandle(), + FfiConverterOptionTypeTransactionFilter.lower(filter), + FfiConverterCallbackInterfaceTransactionUpdateCallback_lower(callback),$0 + ) +}) +} + +open func tokenBalances(query: TokenBalanceQuery)throws -> PageTokenBalance { + return try FfiConverterTypePageTokenBalance_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_token_balances( + self.uniffiCloneHandle(), + FfiConverterTypeTokenBalanceQuery_lower(query),$0 + ) +}) +} + +open func tokenContracts(query: TokenContractQuery)throws -> PageTokenContract { + return try FfiConverterTypePageTokenContract_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts( + self.uniffiCloneHandle(), + FfiConverterTypeTokenContractQuery_lower(query),$0 + ) +}) +} + +open func tokenTransfers(query: TokenTransferQuery)throws -> PageTokenTransfer { + return try FfiConverterTypePageTokenTransfer_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers( + self.uniffiCloneHandle(), + FfiConverterTypeTokenTransferQuery_lower(query),$0 + ) +}) +} + +open func tokens(query: TokenQuery)throws -> PageToken { + return try FfiConverterTypePageToken_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_tokens( + self.uniffiCloneHandle(), + FfiConverterTypeTokenQuery_lower(query),$0 + ) +}) +} + +open func transactions(query: TransactionQuery)throws -> PageTransaction { + return try FfiConverterTypePageTransaction_lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_transactions( + self.uniffiCloneHandle(), + FfiConverterTypeTransactionQuery_lower(query),$0 + ) +}) +} + +open func worlds(worldAddresses: [FieldElement])throws -> [World] { + return try FfiConverterSequenceTypeWorld.lift(try rustCallWithError(FfiConverterTypeDojoError_lift) { + uniffi_dojo_uniffi_fn_method_toriiclient_worlds( + self.uniffiCloneHandle(), + FfiConverterSequenceTypeFieldElement.lower(worldAddresses),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeToriiClient: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = ToriiClient + + public static func lift(_ handle: UInt64) throws -> ToriiClient { + return ToriiClient(unsafeFromHandle: handle) + } + + public static func lower(_ value: ToriiClient) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ToriiClient { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: ToriiClient, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeToriiClient_lift(_ handle: UInt64) throws -> ToriiClient { + return try FfiConverterTypeToriiClient.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeToriiClient_lower(_ value: ToriiClient) -> UInt64 { + return FfiConverterTypeToriiClient.lower(value) +} + + + + +public struct Achievement: Equatable, Hashable { + public let id: String + public let worldAddress: FieldElement + public let namespace: String + public let entityId: String + public let hidden: Bool + public let index: UInt32 + public let points: UInt32 + public let start: String + public let end: String + public let group: String + public let icon: String + public let title: String + public let description: String + public let tasks: [AchievementTask] + public let data: String? + public let totalCompletions: UInt32 + public let completionRate: Double + public let createdAt: UInt64 + public let updatedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, worldAddress: FieldElement, namespace: String, entityId: String, hidden: Bool, index: UInt32, points: UInt32, start: String, end: String, group: String, icon: String, title: String, description: String, tasks: [AchievementTask], data: String?, totalCompletions: UInt32, completionRate: Double, createdAt: UInt64, updatedAt: UInt64) { + self.id = id + self.worldAddress = worldAddress + self.namespace = namespace + self.entityId = entityId + self.hidden = hidden + self.index = index + self.points = points + self.start = start + self.end = end + self.group = group + self.icon = icon + self.title = title + self.description = description + self.tasks = tasks + self.data = data + self.totalCompletions = totalCompletions + self.completionRate = completionRate + self.createdAt = createdAt + self.updatedAt = updatedAt + } + + +} + +#if compiler(>=6) +extension Achievement: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAchievement: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Achievement { + return + try Achievement( + id: FfiConverterString.read(from: &buf), + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + namespace: FfiConverterString.read(from: &buf), + entityId: FfiConverterString.read(from: &buf), + hidden: FfiConverterBool.read(from: &buf), + index: FfiConverterUInt32.read(from: &buf), + points: FfiConverterUInt32.read(from: &buf), + start: FfiConverterString.read(from: &buf), + end: FfiConverterString.read(from: &buf), + group: FfiConverterString.read(from: &buf), + icon: FfiConverterString.read(from: &buf), + title: FfiConverterString.read(from: &buf), + description: FfiConverterString.read(from: &buf), + tasks: FfiConverterSequenceTypeAchievementTask.read(from: &buf), + data: FfiConverterOptionString.read(from: &buf), + totalCompletions: FfiConverterUInt32.read(from: &buf), + completionRate: FfiConverterDouble.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: Achievement, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterString.write(value.namespace, into: &buf) + FfiConverterString.write(value.entityId, into: &buf) + FfiConverterBool.write(value.hidden, into: &buf) + FfiConverterUInt32.write(value.index, into: &buf) + FfiConverterUInt32.write(value.points, into: &buf) + FfiConverterString.write(value.start, into: &buf) + FfiConverterString.write(value.end, into: &buf) + FfiConverterString.write(value.group, into: &buf) + FfiConverterString.write(value.icon, into: &buf) + FfiConverterString.write(value.title, into: &buf) + FfiConverterString.write(value.description, into: &buf) + FfiConverterSequenceTypeAchievementTask.write(value.tasks, into: &buf) + FfiConverterOptionString.write(value.data, into: &buf) + FfiConverterUInt32.write(value.totalCompletions, into: &buf) + FfiConverterDouble.write(value.completionRate, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievement_lift(_ buf: RustBuffer) throws -> Achievement { + return try FfiConverterTypeAchievement.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievement_lower(_ value: Achievement) -> RustBuffer { + return FfiConverterTypeAchievement.lower(value) +} + + +public struct AchievementProgression: Equatable, Hashable { + public let id: String + public let achievementId: String + public let taskId: String + public let worldAddress: FieldElement + public let namespace: String + public let playerId: FieldElement + public let count: UInt32 + public let completed: Bool + public let completedAt: UInt64? + public let createdAt: UInt64 + public let updatedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, achievementId: String, taskId: String, worldAddress: FieldElement, namespace: String, playerId: FieldElement, count: UInt32, completed: Bool, completedAt: UInt64?, createdAt: UInt64, updatedAt: UInt64) { + self.id = id + self.achievementId = achievementId + self.taskId = taskId + self.worldAddress = worldAddress + self.namespace = namespace + self.playerId = playerId + self.count = count + self.completed = completed + self.completedAt = completedAt + self.createdAt = createdAt + self.updatedAt = updatedAt + } + + +} + +#if compiler(>=6) +extension AchievementProgression: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAchievementProgression: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AchievementProgression { + return + try AchievementProgression( + id: FfiConverterString.read(from: &buf), + achievementId: FfiConverterString.read(from: &buf), + taskId: FfiConverterString.read(from: &buf), + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + namespace: FfiConverterString.read(from: &buf), + playerId: FfiConverterTypeFieldElement.read(from: &buf), + count: FfiConverterUInt32.read(from: &buf), + completed: FfiConverterBool.read(from: &buf), + completedAt: FfiConverterOptionUInt64.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: AchievementProgression, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.achievementId, into: &buf) + FfiConverterString.write(value.taskId, into: &buf) + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterString.write(value.namespace, into: &buf) + FfiConverterTypeFieldElement.write(value.playerId, into: &buf) + FfiConverterUInt32.write(value.count, into: &buf) + FfiConverterBool.write(value.completed, into: &buf) + FfiConverterOptionUInt64.write(value.completedAt, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementProgression_lift(_ buf: RustBuffer) throws -> AchievementProgression { + return try FfiConverterTypeAchievementProgression.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementProgression_lower(_ value: AchievementProgression) -> RustBuffer { + return FfiConverterTypeAchievementProgression.lower(value) +} + + +public struct AchievementQuery: Equatable, Hashable { + public let worldAddresses: [FieldElement] + public let namespaces: [String] + public let hidden: Bool? + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddresses: [FieldElement], namespaces: [String], hidden: Bool?, pagination: Pagination) { + self.worldAddresses = worldAddresses + self.namespaces = namespaces + self.hidden = hidden + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension AchievementQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAchievementQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AchievementQuery { + return + try AchievementQuery( + worldAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + namespaces: FfiConverterSequenceString.read(from: &buf), + hidden: FfiConverterOptionBool.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: AchievementQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.worldAddresses, into: &buf) + FfiConverterSequenceString.write(value.namespaces, into: &buf) + FfiConverterOptionBool.write(value.hidden, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementQuery_lift(_ buf: RustBuffer) throws -> AchievementQuery { + return try FfiConverterTypeAchievementQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementQuery_lower(_ value: AchievementQuery) -> RustBuffer { + return FfiConverterTypeAchievementQuery.lower(value) +} + + +public struct AchievementTask: Equatable, Hashable { + public let taskId: String + public let description: String + public let total: UInt32 + public let totalCompletions: UInt32 + public let completionRate: Double + public let createdAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(taskId: String, description: String, total: UInt32, totalCompletions: UInt32, completionRate: Double, createdAt: UInt64) { + self.taskId = taskId + self.description = description + self.total = total + self.totalCompletions = totalCompletions + self.completionRate = completionRate + self.createdAt = createdAt + } + + +} + +#if compiler(>=6) +extension AchievementTask: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAchievementTask: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AchievementTask { + return + try AchievementTask( + taskId: FfiConverterString.read(from: &buf), + description: FfiConverterString.read(from: &buf), + total: FfiConverterUInt32.read(from: &buf), + totalCompletions: FfiConverterUInt32.read(from: &buf), + completionRate: FfiConverterDouble.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: AchievementTask, into buf: inout [UInt8]) { + FfiConverterString.write(value.taskId, into: &buf) + FfiConverterString.write(value.description, into: &buf) + FfiConverterUInt32.write(value.total, into: &buf) + FfiConverterUInt32.write(value.totalCompletions, into: &buf) + FfiConverterDouble.write(value.completionRate, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementTask_lift(_ buf: RustBuffer) throws -> AchievementTask { + return try FfiConverterTypeAchievementTask.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAchievementTask_lower(_ value: AchievementTask) -> RustBuffer { + return FfiConverterTypeAchievementTask.lower(value) +} + + +public struct ActionCount: Equatable, Hashable { + public let actionName: String + public let count: UInt32 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(actionName: String, count: UInt32) { + self.actionName = actionName + self.count = count + } + + +} + +#if compiler(>=6) +extension ActionCount: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActionCount: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionCount { + return + try ActionCount( + actionName: FfiConverterString.read(from: &buf), + count: FfiConverterUInt32.read(from: &buf) + ) + } + + public static func write(_ value: ActionCount, into buf: inout [UInt8]) { + FfiConverterString.write(value.actionName, into: &buf) + FfiConverterUInt32.write(value.count, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActionCount_lift(_ buf: RustBuffer) throws -> ActionCount { + return try FfiConverterTypeActionCount.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActionCount_lower(_ value: ActionCount) -> RustBuffer { + return FfiConverterTypeActionCount.lower(value) +} + + +public struct Activity: Equatable, Hashable { + public let id: String + public let worldAddress: FieldElement + public let namespace: String + public let callerAddress: FieldElement + public let sessionStart: UInt64 + public let sessionEnd: UInt64 + public let actionCount: UInt32 + public let actions: [ActionCount] + public let updatedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, worldAddress: FieldElement, namespace: String, callerAddress: FieldElement, sessionStart: UInt64, sessionEnd: UInt64, actionCount: UInt32, actions: [ActionCount], updatedAt: UInt64) { + self.id = id + self.worldAddress = worldAddress + self.namespace = namespace + self.callerAddress = callerAddress + self.sessionStart = sessionStart + self.sessionEnd = sessionEnd + self.actionCount = actionCount + self.actions = actions + self.updatedAt = updatedAt + } + + +} + +#if compiler(>=6) +extension Activity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Activity { + return + try Activity( + id: FfiConverterString.read(from: &buf), + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + namespace: FfiConverterString.read(from: &buf), + callerAddress: FfiConverterTypeFieldElement.read(from: &buf), + sessionStart: FfiConverterUInt64.read(from: &buf), + sessionEnd: FfiConverterUInt64.read(from: &buf), + actionCount: FfiConverterUInt32.read(from: &buf), + actions: FfiConverterSequenceTypeActionCount.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: Activity, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterString.write(value.namespace, into: &buf) + FfiConverterTypeFieldElement.write(value.callerAddress, into: &buf) + FfiConverterUInt64.write(value.sessionStart, into: &buf) + FfiConverterUInt64.write(value.sessionEnd, into: &buf) + FfiConverterUInt32.write(value.actionCount, into: &buf) + FfiConverterSequenceTypeActionCount.write(value.actions, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lift(_ buf: RustBuffer) throws -> Activity { + return try FfiConverterTypeActivity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { + return FfiConverterTypeActivity.lower(value) +} + + +public struct ActivityQuery: Equatable, Hashable { + public let worldAddresses: [FieldElement] + public let namespaces: [String] + public let callerAddresses: [FieldElement] + public let fromTime: UInt64? + public let toTime: UInt64? + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddresses: [FieldElement], namespaces: [String], callerAddresses: [FieldElement], fromTime: UInt64?, toTime: UInt64?, pagination: Pagination) { + self.worldAddresses = worldAddresses + self.namespaces = namespaces + self.callerAddresses = callerAddresses + self.fromTime = fromTime + self.toTime = toTime + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension ActivityQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivityQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityQuery { + return + try ActivityQuery( + worldAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + namespaces: FfiConverterSequenceString.read(from: &buf), + callerAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + fromTime: FfiConverterOptionUInt64.read(from: &buf), + toTime: FfiConverterOptionUInt64.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: ActivityQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.worldAddresses, into: &buf) + FfiConverterSequenceString.write(value.namespaces, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.callerAddresses, into: &buf) + FfiConverterOptionUInt64.write(value.fromTime, into: &buf) + FfiConverterOptionUInt64.write(value.toTime, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityQuery_lift(_ buf: RustBuffer) throws -> ActivityQuery { + return try FfiConverterTypeActivityQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityQuery_lower(_ value: ActivityQuery) -> RustBuffer { + return FfiConverterTypeActivityQuery.lower(value) +} + + +public struct AggregationEntry: Equatable, Hashable { + public let id: String + public let aggregatorId: String + public let entityId: String + public let value: U256 + public let displayValue: String + public let position: UInt64 + public let modelId: String + public let createdAt: UInt64 + public let updatedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, aggregatorId: String, entityId: String, value: U256, displayValue: String, position: UInt64, modelId: String, createdAt: UInt64, updatedAt: UInt64) { + self.id = id + self.aggregatorId = aggregatorId + self.entityId = entityId + self.value = value + self.displayValue = displayValue + self.position = position + self.modelId = modelId + self.createdAt = createdAt + self.updatedAt = updatedAt + } + + +} + +#if compiler(>=6) +extension AggregationEntry: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAggregationEntry: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AggregationEntry { + return + try AggregationEntry( + id: FfiConverterString.read(from: &buf), + aggregatorId: FfiConverterString.read(from: &buf), + entityId: FfiConverterString.read(from: &buf), + value: FfiConverterTypeU256.read(from: &buf), + displayValue: FfiConverterString.read(from: &buf), + position: FfiConverterUInt64.read(from: &buf), + modelId: FfiConverterString.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: AggregationEntry, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.aggregatorId, into: &buf) + FfiConverterString.write(value.entityId, into: &buf) + FfiConverterTypeU256.write(value.value, into: &buf) + FfiConverterString.write(value.displayValue, into: &buf) + FfiConverterUInt64.write(value.position, into: &buf) + FfiConverterString.write(value.modelId, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAggregationEntry_lift(_ buf: RustBuffer) throws -> AggregationEntry { + return try FfiConverterTypeAggregationEntry.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAggregationEntry_lower(_ value: AggregationEntry) -> RustBuffer { + return FfiConverterTypeAggregationEntry.lower(value) +} + + +public struct AggregationQuery: Equatable, Hashable { + public let aggregatorIds: [String] + public let entityIds: [String] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(aggregatorIds: [String], entityIds: [String], pagination: Pagination) { + self.aggregatorIds = aggregatorIds + self.entityIds = entityIds + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension AggregationQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAggregationQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AggregationQuery { + return + try AggregationQuery( + aggregatorIds: FfiConverterSequenceString.read(from: &buf), + entityIds: FfiConverterSequenceString.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: AggregationQuery, into buf: inout [UInt8]) { + FfiConverterSequenceString.write(value.aggregatorIds, into: &buf) + FfiConverterSequenceString.write(value.entityIds, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAggregationQuery_lift(_ buf: RustBuffer) throws -> AggregationQuery { + return try FfiConverterTypeAggregationQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAggregationQuery_lower(_ value: AggregationQuery) -> RustBuffer { + return FfiConverterTypeAggregationQuery.lower(value) +} + + +public struct AttributeFilter: Equatable, Hashable { + public let traitName: String + public let traitValue: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(traitName: String, traitValue: String) { + self.traitName = traitName + self.traitValue = traitValue + } + + +} + +#if compiler(>=6) +extension AttributeFilter: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAttributeFilter: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AttributeFilter { + return + try AttributeFilter( + traitName: FfiConverterString.read(from: &buf), + traitValue: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: AttributeFilter, into buf: inout [UInt8]) { + FfiConverterString.write(value.traitName, into: &buf) + FfiConverterString.write(value.traitValue, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAttributeFilter_lift(_ buf: RustBuffer) throws -> AttributeFilter { + return try FfiConverterTypeAttributeFilter.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAttributeFilter_lower(_ value: AttributeFilter) -> RustBuffer { + return FfiConverterTypeAttributeFilter.lower(value) +} + + +public struct CompositeClause: Equatable, Hashable { + public let `operator`: LogicalOperator + public let clauses: [Clause] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(`operator`: LogicalOperator, clauses: [Clause]) { + self.`operator` = `operator` + self.clauses = clauses + } + + +} + +#if compiler(>=6) +extension CompositeClause: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeCompositeClause: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CompositeClause { + return + try CompositeClause( + operator: FfiConverterTypeLogicalOperator.read(from: &buf), + clauses: FfiConverterSequenceTypeClause.read(from: &buf) + ) + } + + public static func write(_ value: CompositeClause, into buf: inout [UInt8]) { + FfiConverterTypeLogicalOperator.write(value.`operator`, into: &buf) + FfiConverterSequenceTypeClause.write(value.clauses, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCompositeClause_lift(_ buf: RustBuffer) throws -> CompositeClause { + return try FfiConverterTypeCompositeClause.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCompositeClause_lower(_ value: CompositeClause) -> RustBuffer { + return FfiConverterTypeCompositeClause.lower(value) +} + + +public struct Contract: Equatable, Hashable { + public let contractAddress: FieldElement + public let contractType: ContractType + public let head: UInt64? + public let tps: UInt64? + public let lastBlockTimestamp: UInt64? + public let lastPendingBlockTx: FieldElement? + public let updatedAt: UInt64 + public let createdAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddress: FieldElement, contractType: ContractType, head: UInt64?, tps: UInt64?, lastBlockTimestamp: UInt64?, lastPendingBlockTx: FieldElement?, updatedAt: UInt64, createdAt: UInt64) { + self.contractAddress = contractAddress + self.contractType = contractType + self.head = head + self.tps = tps + self.lastBlockTimestamp = lastBlockTimestamp + self.lastPendingBlockTx = lastPendingBlockTx + self.updatedAt = updatedAt + self.createdAt = createdAt + } + + +} + +#if compiler(>=6) +extension Contract: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeContract: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Contract { + return + try Contract( + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + contractType: FfiConverterTypeContractType.read(from: &buf), + head: FfiConverterOptionUInt64.read(from: &buf), + tps: FfiConverterOptionUInt64.read(from: &buf), + lastBlockTimestamp: FfiConverterOptionUInt64.read(from: &buf), + lastPendingBlockTx: FfiConverterOptionTypeFieldElement.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: Contract, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterTypeContractType.write(value.contractType, into: &buf) + FfiConverterOptionUInt64.write(value.head, into: &buf) + FfiConverterOptionUInt64.write(value.tps, into: &buf) + FfiConverterOptionUInt64.write(value.lastBlockTimestamp, into: &buf) + FfiConverterOptionTypeFieldElement.write(value.lastPendingBlockTx, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContract_lift(_ buf: RustBuffer) throws -> Contract { + return try FfiConverterTypeContract.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContract_lower(_ value: Contract) -> RustBuffer { + return FfiConverterTypeContract.lower(value) +} + + +public struct ContractQuery: Equatable, Hashable { + public let contractAddresses: [FieldElement] + public let contractTypes: [ContractType] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddresses: [FieldElement], contractTypes: [ContractType]) { + self.contractAddresses = contractAddresses + self.contractTypes = contractTypes + } + + +} + +#if compiler(>=6) +extension ContractQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeContractQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContractQuery { + return + try ContractQuery( + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + contractTypes: FfiConverterSequenceTypeContractType.read(from: &buf) + ) + } + + public static func write(_ value: ContractQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceTypeContractType.write(value.contractTypes, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContractQuery_lift(_ buf: RustBuffer) throws -> ContractQuery { + return try FfiConverterTypeContractQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContractQuery_lower(_ value: ContractQuery) -> RustBuffer { + return FfiConverterTypeContractQuery.lower(value) +} + + +public struct Controller: Equatable, Hashable { + public let address: FieldElement + public let username: String + public let deployedAtTimestamp: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(address: FieldElement, username: String, deployedAtTimestamp: UInt64) { + self.address = address + self.username = username + self.deployedAtTimestamp = deployedAtTimestamp + } + + +} + +#if compiler(>=6) +extension Controller: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeController: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Controller { + return + try Controller( + address: FfiConverterTypeFieldElement.read(from: &buf), + username: FfiConverterString.read(from: &buf), + deployedAtTimestamp: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: Controller, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.address, into: &buf) + FfiConverterString.write(value.username, into: &buf) + FfiConverterUInt64.write(value.deployedAtTimestamp, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeController_lift(_ buf: RustBuffer) throws -> Controller { + return try FfiConverterTypeController.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeController_lower(_ value: Controller) -> RustBuffer { + return FfiConverterTypeController.lower(value) +} + + +public struct ControllerQuery: Equatable, Hashable { + public let pagination: Pagination + public let contractAddresses: [FieldElement] + public let usernames: [String] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(pagination: Pagination, contractAddresses: [FieldElement], usernames: [String]) { + self.pagination = pagination + self.contractAddresses = contractAddresses + self.usernames = usernames + } + + +} + +#if compiler(>=6) +extension ControllerQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeControllerQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ControllerQuery { + return + try ControllerQuery( + pagination: FfiConverterTypePagination.read(from: &buf), + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + usernames: FfiConverterSequenceString.read(from: &buf) + ) + } + + public static func write(_ value: ControllerQuery, into buf: inout [UInt8]) { + FfiConverterTypePagination.write(value.pagination, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceString.write(value.usernames, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeControllerQuery_lift(_ buf: RustBuffer) throws -> ControllerQuery { + return try FfiConverterTypeControllerQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeControllerQuery_lower(_ value: ControllerQuery) -> RustBuffer { + return FfiConverterTypeControllerQuery.lower(value) +} + + +public struct Entity: Equatable, Hashable { + public let worldAddress: FieldElement + public let hashedKeys: FieldElement + public let models: [Struct] + public let createdAt: UInt64 + public let updatedAt: UInt64 + public let executedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddress: FieldElement, hashedKeys: FieldElement, models: [Struct], createdAt: UInt64, updatedAt: UInt64, executedAt: UInt64) { + self.worldAddress = worldAddress + self.hashedKeys = hashedKeys + self.models = models + self.createdAt = createdAt + self.updatedAt = updatedAt + self.executedAt = executedAt + } + + +} + +#if compiler(>=6) +extension Entity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeEntity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Entity { + return + try Entity( + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + hashedKeys: FfiConverterTypeFieldElement.read(from: &buf), + models: FfiConverterSequenceTypeStruct.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf), + executedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: Entity, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterTypeFieldElement.write(value.hashedKeys, into: &buf) + FfiConverterSequenceTypeStruct.write(value.models, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + FfiConverterUInt64.write(value.executedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEntity_lift(_ buf: RustBuffer) throws -> Entity { + return try FfiConverterTypeEntity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEntity_lower(_ value: Entity) -> RustBuffer { + return FfiConverterTypeEntity.lower(value) +} + + +public struct EnumOption: Equatable, Hashable { + public let name: String + public let ty: Ty + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, ty: Ty) { + self.name = name + self.ty = ty + } + + +} + +#if compiler(>=6) +extension EnumOption: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeEnumOption: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnumOption { + return + try EnumOption( + name: FfiConverterString.read(from: &buf), + ty: FfiConverterTypeTy.read(from: &buf) + ) + } + + public static func write(_ value: EnumOption, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeTy.write(value.ty, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEnumOption_lift(_ buf: RustBuffer) throws -> EnumOption { + return try FfiConverterTypeEnumOption.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEnumOption_lower(_ value: EnumOption) -> RustBuffer { + return FfiConverterTypeEnumOption.lower(value) +} + + +public struct EnumType: Equatable, Hashable { + public let name: String + public let option: UInt8 + public let options: [EnumOption] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, option: UInt8, options: [EnumOption]) { + self.name = name + self.option = option + self.options = options + } + + +} + +#if compiler(>=6) +extension EnumType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeEnumType: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnumType { + return + try EnumType( + name: FfiConverterString.read(from: &buf), + option: FfiConverterUInt8.read(from: &buf), + options: FfiConverterSequenceTypeEnumOption.read(from: &buf) + ) + } + + public static func write(_ value: EnumType, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterUInt8.write(value.option, into: &buf) + FfiConverterSequenceTypeEnumOption.write(value.options, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEnumType_lift(_ buf: RustBuffer) throws -> EnumType { + return try FfiConverterTypeEnumType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEnumType_lower(_ value: EnumType) -> RustBuffer { + return FfiConverterTypeEnumType.lower(value) +} + + +public struct Event: Equatable, Hashable { + public let keys: [FieldElement] + public let data: [FieldElement] + public let transactionHash: FieldElement + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(keys: [FieldElement], data: [FieldElement], transactionHash: FieldElement) { + self.keys = keys + self.data = data + self.transactionHash = transactionHash + } + + +} + +#if compiler(>=6) +extension Event: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeEvent: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Event { + return + try Event( + keys: FfiConverterSequenceTypeFieldElement.read(from: &buf), + data: FfiConverterSequenceTypeFieldElement.read(from: &buf), + transactionHash: FfiConverterTypeFieldElement.read(from: &buf) + ) + } + + public static func write(_ value: Event, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.keys, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.data, into: &buf) + FfiConverterTypeFieldElement.write(value.transactionHash, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEvent_lift(_ buf: RustBuffer) throws -> Event { + return try FfiConverterTypeEvent.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEvent_lower(_ value: Event) -> RustBuffer { + return FfiConverterTypeEvent.lower(value) +} + + +public struct EventQuery: Equatable, Hashable { + public let keys: KeysClause? + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(keys: KeysClause?, pagination: Pagination) { + self.keys = keys + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension EventQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeEventQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EventQuery { + return + try EventQuery( + keys: FfiConverterOptionTypeKeysClause.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: EventQuery, into buf: inout [UInt8]) { + FfiConverterOptionTypeKeysClause.write(value.keys, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEventQuery_lift(_ buf: RustBuffer) throws -> EventQuery { + return try FfiConverterTypeEventQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeEventQuery_lower(_ value: EventQuery) -> RustBuffer { + return FfiConverterTypeEventQuery.lower(value) +} + + +public struct FixedSizeArray: Equatable, Hashable { + public let array: [Ty] + public let size: UInt32 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(array: [Ty], size: UInt32) { + self.array = array + self.size = size + } + + +} + +#if compiler(>=6) +extension FixedSizeArray: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeFixedSizeArray: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FixedSizeArray { + return + try FixedSizeArray( + array: FfiConverterSequenceTypeTy.read(from: &buf), + size: FfiConverterUInt32.read(from: &buf) + ) + } + + public static func write(_ value: FixedSizeArray, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTy.write(value.array, into: &buf) + FfiConverterUInt32.write(value.size, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeFixedSizeArray_lift(_ buf: RustBuffer) throws -> FixedSizeArray { + return try FfiConverterTypeFixedSizeArray.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeFixedSizeArray_lower(_ value: FixedSizeArray) -> RustBuffer { + return FfiConverterTypeFixedSizeArray.lower(value) +} + + +public struct KeysClause: Equatable, Hashable { + public let keys: [FieldElement?] + public let patternMatching: PatternMatching + public let models: [String] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(keys: [FieldElement?], patternMatching: PatternMatching, models: [String]) { + self.keys = keys + self.patternMatching = patternMatching + self.models = models + } + + +} + +#if compiler(>=6) +extension KeysClause: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeKeysClause: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> KeysClause { + return + try KeysClause( + keys: FfiConverterSequenceOptionTypeFieldElement.read(from: &buf), + patternMatching: FfiConverterTypePatternMatching.read(from: &buf), + models: FfiConverterSequenceString.read(from: &buf) + ) + } + + public static func write(_ value: KeysClause, into buf: inout [UInt8]) { + FfiConverterSequenceOptionTypeFieldElement.write(value.keys, into: &buf) + FfiConverterTypePatternMatching.write(value.patternMatching, into: &buf) + FfiConverterSequenceString.write(value.models, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeKeysClause_lift(_ buf: RustBuffer) throws -> KeysClause { + return try FfiConverterTypeKeysClause.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeKeysClause_lower(_ value: KeysClause) -> RustBuffer { + return FfiConverterTypeKeysClause.lower(value) +} + + +public struct Member: Equatable, Hashable { + public let name: String + public let ty: Ty + public let key: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, ty: Ty, key: Bool) { + self.name = name + self.ty = ty + self.key = key + } + + +} + +#if compiler(>=6) +extension Member: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeMember: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Member { + return + try Member( + name: FfiConverterString.read(from: &buf), + ty: FfiConverterTypeTy.read(from: &buf), + key: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: Member, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeTy.write(value.ty, into: &buf) + FfiConverterBool.write(value.key, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMember_lift(_ buf: RustBuffer) throws -> Member { + return try FfiConverterTypeMember.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMember_lower(_ value: Member) -> RustBuffer { + return FfiConverterTypeMember.lower(value) +} + + +public struct MemberClause: Equatable, Hashable { + public let model: String + public let member: String + public let `operator`: ComparisonOperator + public let value: MemberValue + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(model: String, member: String, `operator`: ComparisonOperator, value: MemberValue) { + self.model = model + self.member = member + self.`operator` = `operator` + self.value = value + } + + +} + +#if compiler(>=6) +extension MemberClause: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeMemberClause: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MemberClause { + return + try MemberClause( + model: FfiConverterString.read(from: &buf), + member: FfiConverterString.read(from: &buf), + operator: FfiConverterTypeComparisonOperator.read(from: &buf), + value: FfiConverterTypeMemberValue.read(from: &buf) + ) + } + + public static func write(_ value: MemberClause, into buf: inout [UInt8]) { + FfiConverterString.write(value.model, into: &buf) + FfiConverterString.write(value.member, into: &buf) + FfiConverterTypeComparisonOperator.write(value.`operator`, into: &buf) + FfiConverterTypeMemberValue.write(value.value, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMemberClause_lift(_ buf: RustBuffer) throws -> MemberClause { + return try FfiConverterTypeMemberClause.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMemberClause_lower(_ value: MemberClause) -> RustBuffer { + return FfiConverterTypeMemberClause.lower(value) +} + + +public struct Message: Equatable, Hashable { + public let message: String + public let signature: [FieldElement] + public let worldAddress: FieldElement + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(message: String, signature: [FieldElement], worldAddress: FieldElement) { + self.message = message + self.signature = signature + self.worldAddress = worldAddress + } + + +} + +#if compiler(>=6) +extension Message: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeMessage: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Message { + return + try Message( + message: FfiConverterString.read(from: &buf), + signature: FfiConverterSequenceTypeFieldElement.read(from: &buf), + worldAddress: FfiConverterTypeFieldElement.read(from: &buf) + ) + } + + public static func write(_ value: Message, into buf: inout [UInt8]) { + FfiConverterString.write(value.message, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.signature, into: &buf) + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMessage_lift(_ buf: RustBuffer) throws -> Message { + return try FfiConverterTypeMessage.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMessage_lower(_ value: Message) -> RustBuffer { + return FfiConverterTypeMessage.lower(value) +} + + +public struct Model: Equatable, Hashable { + public let worldAddress: FieldElement + public let schema: Ty + public let namespace: String + public let name: String + public let selector: FieldElement + public let packedSize: UInt32 + public let unpackedSize: UInt32 + public let classHash: FieldElement + public let contractAddress: FieldElement + public let layout: String + public let useLegacyStore: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddress: FieldElement, schema: Ty, namespace: String, name: String, selector: FieldElement, packedSize: UInt32, unpackedSize: UInt32, classHash: FieldElement, contractAddress: FieldElement, layout: String, useLegacyStore: Bool) { + self.worldAddress = worldAddress + self.schema = schema + self.namespace = namespace + self.name = name + self.selector = selector + self.packedSize = packedSize + self.unpackedSize = unpackedSize + self.classHash = classHash + self.contractAddress = contractAddress + self.layout = layout + self.useLegacyStore = useLegacyStore + } + + +} + +#if compiler(>=6) +extension Model: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeModel: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Model { + return + try Model( + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + schema: FfiConverterTypeTy.read(from: &buf), + namespace: FfiConverterString.read(from: &buf), + name: FfiConverterString.read(from: &buf), + selector: FfiConverterTypeFieldElement.read(from: &buf), + packedSize: FfiConverterUInt32.read(from: &buf), + unpackedSize: FfiConverterUInt32.read(from: &buf), + classHash: FfiConverterTypeFieldElement.read(from: &buf), + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + layout: FfiConverterString.read(from: &buf), + useLegacyStore: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: Model, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterTypeTy.write(value.schema, into: &buf) + FfiConverterString.write(value.namespace, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeFieldElement.write(value.selector, into: &buf) + FfiConverterUInt32.write(value.packedSize, into: &buf) + FfiConverterUInt32.write(value.unpackedSize, into: &buf) + FfiConverterTypeFieldElement.write(value.classHash, into: &buf) + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterString.write(value.layout, into: &buf) + FfiConverterBool.write(value.useLegacyStore, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeModel_lift(_ buf: RustBuffer) throws -> Model { + return try FfiConverterTypeModel.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeModel_lower(_ value: Model) -> RustBuffer { + return FfiConverterTypeModel.lower(value) +} + + +public struct OrderBy: Equatable, Hashable { + public let field: String + public let direction: OrderDirection + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(field: String, direction: OrderDirection) { + self.field = field + self.direction = direction + } + + +} + +#if compiler(>=6) +extension OrderBy: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeOrderBy: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OrderBy { + return + try OrderBy( + field: FfiConverterString.read(from: &buf), + direction: FfiConverterTypeOrderDirection.read(from: &buf) + ) + } + + public static func write(_ value: OrderBy, into buf: inout [UInt8]) { + FfiConverterString.write(value.field, into: &buf) + FfiConverterTypeOrderDirection.write(value.direction, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeOrderBy_lift(_ buf: RustBuffer) throws -> OrderBy { + return try FfiConverterTypeOrderBy.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeOrderBy_lower(_ value: OrderBy) -> RustBuffer { + return FfiConverterTypeOrderBy.lower(value) +} + + +public struct PageAchievement: Equatable, Hashable { + public let items: [Achievement] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Achievement], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageAchievement: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageAchievement: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageAchievement { + return + try PageAchievement( + items: FfiConverterSequenceTypeAchievement.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageAchievement, into buf: inout [UInt8]) { + FfiConverterSequenceTypeAchievement.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageAchievement_lift(_ buf: RustBuffer) throws -> PageAchievement { + return try FfiConverterTypePageAchievement.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageAchievement_lower(_ value: PageAchievement) -> RustBuffer { + return FfiConverterTypePageAchievement.lower(value) +} + + +public struct PageActivity: Equatable, Hashable { + public let items: [Activity] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Activity], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageActivity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageActivity { + return + try PageActivity( + items: FfiConverterSequenceTypeActivity.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageActivity, into buf: inout [UInt8]) { + FfiConverterSequenceTypeActivity.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageActivity_lift(_ buf: RustBuffer) throws -> PageActivity { + return try FfiConverterTypePageActivity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageActivity_lower(_ value: PageActivity) -> RustBuffer { + return FfiConverterTypePageActivity.lower(value) +} + + +public struct PageAggregationEntry: Equatable, Hashable { + public let items: [AggregationEntry] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [AggregationEntry], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageAggregationEntry: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageAggregationEntry: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageAggregationEntry { + return + try PageAggregationEntry( + items: FfiConverterSequenceTypeAggregationEntry.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageAggregationEntry, into buf: inout [UInt8]) { + FfiConverterSequenceTypeAggregationEntry.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageAggregationEntry_lift(_ buf: RustBuffer) throws -> PageAggregationEntry { + return try FfiConverterTypePageAggregationEntry.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageAggregationEntry_lower(_ value: PageAggregationEntry) -> RustBuffer { + return FfiConverterTypePageAggregationEntry.lower(value) +} + + +public struct PageController: Equatable, Hashable { + public let items: [Controller] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Controller], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageController: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageController: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageController { + return + try PageController( + items: FfiConverterSequenceTypeController.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageController, into buf: inout [UInt8]) { + FfiConverterSequenceTypeController.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageController_lift(_ buf: RustBuffer) throws -> PageController { + return try FfiConverterTypePageController.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageController_lower(_ value: PageController) -> RustBuffer { + return FfiConverterTypePageController.lower(value) +} + + +public struct PageEntity: Equatable, Hashable { + public let items: [Entity] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Entity], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageEntity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageEntity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageEntity { + return + try PageEntity( + items: FfiConverterSequenceTypeEntity.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageEntity, into buf: inout [UInt8]) { + FfiConverterSequenceTypeEntity.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageEntity_lift(_ buf: RustBuffer) throws -> PageEntity { + return try FfiConverterTypePageEntity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageEntity_lower(_ value: PageEntity) -> RustBuffer { + return FfiConverterTypePageEntity.lower(value) +} + + +public struct PageEvent: Equatable, Hashable { + public let items: [Event] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Event], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageEvent: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageEvent: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageEvent { + return + try PageEvent( + items: FfiConverterSequenceTypeEvent.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageEvent, into buf: inout [UInt8]) { + FfiConverterSequenceTypeEvent.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageEvent_lift(_ buf: RustBuffer) throws -> PageEvent { + return try FfiConverterTypePageEvent.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageEvent_lower(_ value: PageEvent) -> RustBuffer { + return FfiConverterTypePageEvent.lower(value) +} + + +public struct PagePlayerAchievement: Equatable, Hashable { + public let items: [PlayerAchievementEntry] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [PlayerAchievementEntry], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PagePlayerAchievement: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePagePlayerAchievement: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PagePlayerAchievement { + return + try PagePlayerAchievement( + items: FfiConverterSequenceTypePlayerAchievementEntry.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PagePlayerAchievement, into buf: inout [UInt8]) { + FfiConverterSequenceTypePlayerAchievementEntry.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePagePlayerAchievement_lift(_ buf: RustBuffer) throws -> PagePlayerAchievement { + return try FfiConverterTypePagePlayerAchievement.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePagePlayerAchievement_lower(_ value: PagePlayerAchievement) -> RustBuffer { + return FfiConverterTypePagePlayerAchievement.lower(value) +} + + +public struct PageToken: Equatable, Hashable { + public let items: [Token] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Token], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageToken: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageToken: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageToken { + return + try PageToken( + items: FfiConverterSequenceTypeToken.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageToken, into buf: inout [UInt8]) { + FfiConverterSequenceTypeToken.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageToken_lift(_ buf: RustBuffer) throws -> PageToken { + return try FfiConverterTypePageToken.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageToken_lower(_ value: PageToken) -> RustBuffer { + return FfiConverterTypePageToken.lower(value) +} + + +public struct PageTokenBalance: Equatable, Hashable { + public let items: [TokenBalance] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [TokenBalance], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageTokenBalance: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageTokenBalance: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageTokenBalance { + return + try PageTokenBalance( + items: FfiConverterSequenceTypeTokenBalance.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageTokenBalance, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTokenBalance.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenBalance_lift(_ buf: RustBuffer) throws -> PageTokenBalance { + return try FfiConverterTypePageTokenBalance.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenBalance_lower(_ value: PageTokenBalance) -> RustBuffer { + return FfiConverterTypePageTokenBalance.lower(value) +} + + +public struct PageTokenContract: Equatable, Hashable { + public let items: [TokenContract] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [TokenContract], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageTokenContract: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageTokenContract: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageTokenContract { + return + try PageTokenContract( + items: FfiConverterSequenceTypeTokenContract.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageTokenContract, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTokenContract.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenContract_lift(_ buf: RustBuffer) throws -> PageTokenContract { + return try FfiConverterTypePageTokenContract.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenContract_lower(_ value: PageTokenContract) -> RustBuffer { + return FfiConverterTypePageTokenContract.lower(value) +} + + +public struct PageTokenTransfer: Equatable, Hashable { + public let items: [TokenTransfer] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [TokenTransfer], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageTokenTransfer: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageTokenTransfer: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageTokenTransfer { + return + try PageTokenTransfer( + items: FfiConverterSequenceTypeTokenTransfer.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageTokenTransfer, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTokenTransfer.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenTransfer_lift(_ buf: RustBuffer) throws -> PageTokenTransfer { + return try FfiConverterTypePageTokenTransfer.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTokenTransfer_lower(_ value: PageTokenTransfer) -> RustBuffer { + return FfiConverterTypePageTokenTransfer.lower(value) +} + + +public struct PageTransaction: Equatable, Hashable { + public let items: [Transaction] + public let nextCursor: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(items: [Transaction], nextCursor: String?) { + self.items = items + self.nextCursor = nextCursor + } + + +} + +#if compiler(>=6) +extension PageTransaction: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePageTransaction: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageTransaction { + return + try PageTransaction( + items: FfiConverterSequenceTypeTransaction.read(from: &buf), + nextCursor: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PageTransaction, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTransaction.write(value.items, into: &buf) + FfiConverterOptionString.write(value.nextCursor, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTransaction_lift(_ buf: RustBuffer) throws -> PageTransaction { + return try FfiConverterTypePageTransaction.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePageTransaction_lower(_ value: PageTransaction) -> RustBuffer { + return FfiConverterTypePageTransaction.lower(value) +} + + +public struct Pagination: Equatable, Hashable { + public let cursor: String? + public let limit: UInt32? + public let direction: PaginationDirection + public let orderBy: [OrderBy] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(cursor: String?, limit: UInt32?, direction: PaginationDirection, orderBy: [OrderBy]) { + self.cursor = cursor + self.limit = limit + self.direction = direction + self.orderBy = orderBy + } + + +} + +#if compiler(>=6) +extension Pagination: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePagination: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Pagination { + return + try Pagination( + cursor: FfiConverterOptionString.read(from: &buf), + limit: FfiConverterOptionUInt32.read(from: &buf), + direction: FfiConverterTypePaginationDirection.read(from: &buf), + orderBy: FfiConverterSequenceTypeOrderBy.read(from: &buf) + ) + } + + public static func write(_ value: Pagination, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.cursor, into: &buf) + FfiConverterOptionUInt32.write(value.limit, into: &buf) + FfiConverterTypePaginationDirection.write(value.direction, into: &buf) + FfiConverterSequenceTypeOrderBy.write(value.orderBy, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePagination_lift(_ buf: RustBuffer) throws -> Pagination { + return try FfiConverterTypePagination.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePagination_lower(_ value: Pagination) -> RustBuffer { + return FfiConverterTypePagination.lower(value) +} + + +public struct PlayerAchievementEntry: Equatable, Hashable { + public let playerAddress: FieldElement + public let stats: PlayerAchievementStats + public let achievements: [PlayerAchievementProgress] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(playerAddress: FieldElement, stats: PlayerAchievementStats, achievements: [PlayerAchievementProgress]) { + self.playerAddress = playerAddress + self.stats = stats + self.achievements = achievements + } + + +} + +#if compiler(>=6) +extension PlayerAchievementEntry: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePlayerAchievementEntry: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerAchievementEntry { + return + try PlayerAchievementEntry( + playerAddress: FfiConverterTypeFieldElement.read(from: &buf), + stats: FfiConverterTypePlayerAchievementStats.read(from: &buf), + achievements: FfiConverterSequenceTypePlayerAchievementProgress.read(from: &buf) + ) + } + + public static func write(_ value: PlayerAchievementEntry, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.playerAddress, into: &buf) + FfiConverterTypePlayerAchievementStats.write(value.stats, into: &buf) + FfiConverterSequenceTypePlayerAchievementProgress.write(value.achievements, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementEntry_lift(_ buf: RustBuffer) throws -> PlayerAchievementEntry { + return try FfiConverterTypePlayerAchievementEntry.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementEntry_lower(_ value: PlayerAchievementEntry) -> RustBuffer { + return FfiConverterTypePlayerAchievementEntry.lower(value) +} + + +public struct PlayerAchievementProgress: Equatable, Hashable { + public let achievement: Achievement + public let taskProgress: [TaskProgress] + public let completed: Bool + public let progressPercentage: Double + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(achievement: Achievement, taskProgress: [TaskProgress], completed: Bool, progressPercentage: Double) { + self.achievement = achievement + self.taskProgress = taskProgress + self.completed = completed + self.progressPercentage = progressPercentage + } + + +} + +#if compiler(>=6) +extension PlayerAchievementProgress: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePlayerAchievementProgress: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerAchievementProgress { + return + try PlayerAchievementProgress( + achievement: FfiConverterTypeAchievement.read(from: &buf), + taskProgress: FfiConverterSequenceTypeTaskProgress.read(from: &buf), + completed: FfiConverterBool.read(from: &buf), + progressPercentage: FfiConverterDouble.read(from: &buf) + ) + } + + public static func write(_ value: PlayerAchievementProgress, into buf: inout [UInt8]) { + FfiConverterTypeAchievement.write(value.achievement, into: &buf) + FfiConverterSequenceTypeTaskProgress.write(value.taskProgress, into: &buf) + FfiConverterBool.write(value.completed, into: &buf) + FfiConverterDouble.write(value.progressPercentage, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementProgress_lift(_ buf: RustBuffer) throws -> PlayerAchievementProgress { + return try FfiConverterTypePlayerAchievementProgress.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementProgress_lower(_ value: PlayerAchievementProgress) -> RustBuffer { + return FfiConverterTypePlayerAchievementProgress.lower(value) +} + + +public struct PlayerAchievementQuery: Equatable, Hashable { + public let worldAddresses: [FieldElement] + public let namespaces: [String] + public let playerAddresses: [FieldElement] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddresses: [FieldElement], namespaces: [String], playerAddresses: [FieldElement], pagination: Pagination) { + self.worldAddresses = worldAddresses + self.namespaces = namespaces + self.playerAddresses = playerAddresses + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension PlayerAchievementQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePlayerAchievementQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerAchievementQuery { + return + try PlayerAchievementQuery( + worldAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + namespaces: FfiConverterSequenceString.read(from: &buf), + playerAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: PlayerAchievementQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.worldAddresses, into: &buf) + FfiConverterSequenceString.write(value.namespaces, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.playerAddresses, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementQuery_lift(_ buf: RustBuffer) throws -> PlayerAchievementQuery { + return try FfiConverterTypePlayerAchievementQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementQuery_lower(_ value: PlayerAchievementQuery) -> RustBuffer { + return FfiConverterTypePlayerAchievementQuery.lower(value) +} + + +public struct PlayerAchievementStats: Equatable, Hashable { + public let totalPoints: UInt32 + public let completedAchievements: UInt32 + public let totalAchievements: UInt32 + public let completionPercentage: Double + public let lastAchievementAt: UInt64? + public let createdAt: UInt64 + public let updatedAt: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(totalPoints: UInt32, completedAchievements: UInt32, totalAchievements: UInt32, completionPercentage: Double, lastAchievementAt: UInt64?, createdAt: UInt64, updatedAt: UInt64) { + self.totalPoints = totalPoints + self.completedAchievements = completedAchievements + self.totalAchievements = totalAchievements + self.completionPercentage = completionPercentage + self.lastAchievementAt = lastAchievementAt + self.createdAt = createdAt + self.updatedAt = updatedAt + } + + +} + +#if compiler(>=6) +extension PlayerAchievementStats: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePlayerAchievementStats: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerAchievementStats { + return + try PlayerAchievementStats( + totalPoints: FfiConverterUInt32.read(from: &buf), + completedAchievements: FfiConverterUInt32.read(from: &buf), + totalAchievements: FfiConverterUInt32.read(from: &buf), + completionPercentage: FfiConverterDouble.read(from: &buf), + lastAchievementAt: FfiConverterOptionUInt64.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf), + updatedAt: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: PlayerAchievementStats, into buf: inout [UInt8]) { + FfiConverterUInt32.write(value.totalPoints, into: &buf) + FfiConverterUInt32.write(value.completedAchievements, into: &buf) + FfiConverterUInt32.write(value.totalAchievements, into: &buf) + FfiConverterDouble.write(value.completionPercentage, into: &buf) + FfiConverterOptionUInt64.write(value.lastAchievementAt, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) + FfiConverterUInt64.write(value.updatedAt, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementStats_lift(_ buf: RustBuffer) throws -> PlayerAchievementStats { + return try FfiConverterTypePlayerAchievementStats.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePlayerAchievementStats_lower(_ value: PlayerAchievementStats) -> RustBuffer { + return FfiConverterTypePlayerAchievementStats.lower(value) +} + + +public struct Query: Equatable, Hashable { + public let worldAddresses: [FieldElement] + public let pagination: Pagination + public let clause: Clause? + public let noHashedKeys: Bool + public let models: [String] + public let historical: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddresses: [FieldElement], pagination: Pagination, clause: Clause?, noHashedKeys: Bool, models: [String], historical: Bool) { + self.worldAddresses = worldAddresses + self.pagination = pagination + self.clause = clause + self.noHashedKeys = noHashedKeys + self.models = models + self.historical = historical + } + + +} + +#if compiler(>=6) +extension Query: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Query { + return + try Query( + worldAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf), + clause: FfiConverterOptionTypeClause.read(from: &buf), + noHashedKeys: FfiConverterBool.read(from: &buf), + models: FfiConverterSequenceString.read(from: &buf), + historical: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: Query, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.worldAddresses, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + FfiConverterOptionTypeClause.write(value.clause, into: &buf) + FfiConverterBool.write(value.noHashedKeys, into: &buf) + FfiConverterSequenceString.write(value.models, into: &buf) + FfiConverterBool.write(value.historical, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeQuery_lift(_ buf: RustBuffer) throws -> Query { + return try FfiConverterTypeQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeQuery_lower(_ value: Query) -> RustBuffer { + return FfiConverterTypeQuery.lower(value) +} + + +public struct Signature: Equatable, Hashable { + public let r: FieldElement + public let s: FieldElement + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(r: FieldElement, s: FieldElement) { + self.r = r + self.s = s + } + + +} + +#if compiler(>=6) +extension Signature: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSignature: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Signature { + return + try Signature( + r: FfiConverterTypeFieldElement.read(from: &buf), + s: FfiConverterTypeFieldElement.read(from: &buf) + ) + } + + public static func write(_ value: Signature, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.r, into: &buf) + FfiConverterTypeFieldElement.write(value.s, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSignature_lift(_ buf: RustBuffer) throws -> Signature { + return try FfiConverterTypeSignature.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSignature_lower(_ value: Signature) -> RustBuffer { + return FfiConverterTypeSignature.lower(value) +} + + +public struct SqlField: Equatable, Hashable { + public let name: String + public let value: SqlValue + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, value: SqlValue) { + self.name = name + self.value = value + } + + +} + +#if compiler(>=6) +extension SqlField: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSqlField: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SqlField { + return + try SqlField( + name: FfiConverterString.read(from: &buf), + value: FfiConverterTypeSqlValue.read(from: &buf) + ) + } + + public static func write(_ value: SqlField, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeSqlValue.write(value.value, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlField_lift(_ buf: RustBuffer) throws -> SqlField { + return try FfiConverterTypeSqlField.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlField_lower(_ value: SqlField) -> RustBuffer { + return FfiConverterTypeSqlField.lower(value) +} + + +public struct SqlRow: Equatable, Hashable { + public let fields: [SqlField] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(fields: [SqlField]) { + self.fields = fields + } + + +} + +#if compiler(>=6) +extension SqlRow: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSqlRow: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SqlRow { + return + try SqlRow( + fields: FfiConverterSequenceTypeSqlField.read(from: &buf) + ) + } + + public static func write(_ value: SqlRow, into buf: inout [UInt8]) { + FfiConverterSequenceTypeSqlField.write(value.fields, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlRow_lift(_ buf: RustBuffer) throws -> SqlRow { + return try FfiConverterTypeSqlRow.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlRow_lower(_ value: SqlRow) -> RustBuffer { + return FfiConverterTypeSqlRow.lower(value) +} + + +public struct Struct: Equatable, Hashable { + public let name: String + public let children: [Member] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, children: [Member]) { + self.name = name + self.children = children + } + + +} + +#if compiler(>=6) +extension Struct: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeStruct: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Struct { + return + try Struct( + name: FfiConverterString.read(from: &buf), + children: FfiConverterSequenceTypeMember.read(from: &buf) + ) + } + + public static func write(_ value: Struct, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterSequenceTypeMember.write(value.children, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeStruct_lift(_ buf: RustBuffer) throws -> Struct { + return try FfiConverterTypeStruct.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeStruct_lower(_ value: Struct) -> RustBuffer { + return FfiConverterTypeStruct.lower(value) +} + + +public struct TaskProgress: Equatable, Hashable { + public let taskId: String + public let count: UInt32 + public let completed: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(taskId: String, count: UInt32, completed: Bool) { + self.taskId = taskId + self.count = count + self.completed = completed + } + + +} + +#if compiler(>=6) +extension TaskProgress: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTaskProgress: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TaskProgress { + return + try TaskProgress( + taskId: FfiConverterString.read(from: &buf), + count: FfiConverterUInt32.read(from: &buf), + completed: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: TaskProgress, into buf: inout [UInt8]) { + FfiConverterString.write(value.taskId, into: &buf) + FfiConverterUInt32.write(value.count, into: &buf) + FfiConverterBool.write(value.completed, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTaskProgress_lift(_ buf: RustBuffer) throws -> TaskProgress { + return try FfiConverterTypeTaskProgress.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTaskProgress_lower(_ value: TaskProgress) -> RustBuffer { + return FfiConverterTypeTaskProgress.lower(value) +} + + +public struct Token: Equatable, Hashable { + public let contractAddress: FieldElement + public let tokenId: U256? + public let name: String + public let symbol: String + public let decimals: UInt8 + public let metadata: String + public let totalSupply: U256? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddress: FieldElement, tokenId: U256?, name: String, symbol: String, decimals: UInt8, metadata: String, totalSupply: U256?) { + self.contractAddress = contractAddress + self.tokenId = tokenId + self.name = name + self.symbol = symbol + self.decimals = decimals + self.metadata = metadata + self.totalSupply = totalSupply + } + + +} + +#if compiler(>=6) +extension Token: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeToken: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Token { + return + try Token( + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + tokenId: FfiConverterOptionTypeU256.read(from: &buf), + name: FfiConverterString.read(from: &buf), + symbol: FfiConverterString.read(from: &buf), + decimals: FfiConverterUInt8.read(from: &buf), + metadata: FfiConverterString.read(from: &buf), + totalSupply: FfiConverterOptionTypeU256.read(from: &buf) + ) + } + + public static func write(_ value: Token, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterOptionTypeU256.write(value.tokenId, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterString.write(value.symbol, into: &buf) + FfiConverterUInt8.write(value.decimals, into: &buf) + FfiConverterString.write(value.metadata, into: &buf) + FfiConverterOptionTypeU256.write(value.totalSupply, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeToken_lift(_ buf: RustBuffer) throws -> Token { + return try FfiConverterTypeToken.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeToken_lower(_ value: Token) -> RustBuffer { + return FfiConverterTypeToken.lower(value) +} + + +public struct TokenBalance: Equatable, Hashable { + public let balance: U256 + public let accountAddress: FieldElement + public let contractAddress: FieldElement + public let tokenId: U256? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(balance: U256, accountAddress: FieldElement, contractAddress: FieldElement, tokenId: U256?) { + self.balance = balance + self.accountAddress = accountAddress + self.contractAddress = contractAddress + self.tokenId = tokenId + } + + +} + +#if compiler(>=6) +extension TokenBalance: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenBalance: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenBalance { + return + try TokenBalance( + balance: FfiConverterTypeU256.read(from: &buf), + accountAddress: FfiConverterTypeFieldElement.read(from: &buf), + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + tokenId: FfiConverterOptionTypeU256.read(from: &buf) + ) + } + + public static func write(_ value: TokenBalance, into buf: inout [UInt8]) { + FfiConverterTypeU256.write(value.balance, into: &buf) + FfiConverterTypeFieldElement.write(value.accountAddress, into: &buf) + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterOptionTypeU256.write(value.tokenId, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenBalance_lift(_ buf: RustBuffer) throws -> TokenBalance { + return try FfiConverterTypeTokenBalance.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenBalance_lower(_ value: TokenBalance) -> RustBuffer { + return FfiConverterTypeTokenBalance.lower(value) +} + + +public struct TokenBalanceQuery: Equatable, Hashable { + public let contractAddresses: [FieldElement] + public let accountAddresses: [FieldElement] + public let tokenIds: [U256] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddresses: [FieldElement], accountAddresses: [FieldElement], tokenIds: [U256], pagination: Pagination) { + self.contractAddresses = contractAddresses + self.accountAddresses = accountAddresses + self.tokenIds = tokenIds + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension TokenBalanceQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenBalanceQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenBalanceQuery { + return + try TokenBalanceQuery( + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + accountAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + tokenIds: FfiConverterSequenceTypeU256.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: TokenBalanceQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.accountAddresses, into: &buf) + FfiConverterSequenceTypeU256.write(value.tokenIds, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenBalanceQuery_lift(_ buf: RustBuffer) throws -> TokenBalanceQuery { + return try FfiConverterTypeTokenBalanceQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenBalanceQuery_lower(_ value: TokenBalanceQuery) -> RustBuffer { + return FfiConverterTypeTokenBalanceQuery.lower(value) +} + + +public struct TokenContract: Equatable, Hashable { + public let contractAddress: FieldElement + public let name: String + public let symbol: String + public let decimals: UInt8 + public let metadata: String + public let tokenMetadata: String + public let totalSupply: U256? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddress: FieldElement, name: String, symbol: String, decimals: UInt8, metadata: String, tokenMetadata: String, totalSupply: U256?) { + self.contractAddress = contractAddress + self.name = name + self.symbol = symbol + self.decimals = decimals + self.metadata = metadata + self.tokenMetadata = tokenMetadata + self.totalSupply = totalSupply + } + + +} + +#if compiler(>=6) +extension TokenContract: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenContract: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenContract { + return + try TokenContract( + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + name: FfiConverterString.read(from: &buf), + symbol: FfiConverterString.read(from: &buf), + decimals: FfiConverterUInt8.read(from: &buf), + metadata: FfiConverterString.read(from: &buf), + tokenMetadata: FfiConverterString.read(from: &buf), + totalSupply: FfiConverterOptionTypeU256.read(from: &buf) + ) + } + + public static func write(_ value: TokenContract, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterString.write(value.symbol, into: &buf) + FfiConverterUInt8.write(value.decimals, into: &buf) + FfiConverterString.write(value.metadata, into: &buf) + FfiConverterString.write(value.tokenMetadata, into: &buf) + FfiConverterOptionTypeU256.write(value.totalSupply, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenContract_lift(_ buf: RustBuffer) throws -> TokenContract { + return try FfiConverterTypeTokenContract.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenContract_lower(_ value: TokenContract) -> RustBuffer { + return FfiConverterTypeTokenContract.lower(value) +} + + +public struct TokenContractQuery: Equatable, Hashable { + public let contractAddresses: [FieldElement] + public let contractTypes: [ContractType] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddresses: [FieldElement], contractTypes: [ContractType], pagination: Pagination) { + self.contractAddresses = contractAddresses + self.contractTypes = contractTypes + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension TokenContractQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenContractQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenContractQuery { + return + try TokenContractQuery( + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + contractTypes: FfiConverterSequenceTypeContractType.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: TokenContractQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceTypeContractType.write(value.contractTypes, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenContractQuery_lift(_ buf: RustBuffer) throws -> TokenContractQuery { + return try FfiConverterTypeTokenContractQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenContractQuery_lower(_ value: TokenContractQuery) -> RustBuffer { + return FfiConverterTypeTokenContractQuery.lower(value) +} + + +public struct TokenQuery: Equatable, Hashable { + public let contractAddresses: [FieldElement] + public let tokenIds: [U256] + public let attributeFilters: [AttributeFilter] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddresses: [FieldElement], tokenIds: [U256], attributeFilters: [AttributeFilter], pagination: Pagination) { + self.contractAddresses = contractAddresses + self.tokenIds = tokenIds + self.attributeFilters = attributeFilters + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension TokenQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenQuery { + return + try TokenQuery( + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + tokenIds: FfiConverterSequenceTypeU256.read(from: &buf), + attributeFilters: FfiConverterSequenceTypeAttributeFilter.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: TokenQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceTypeU256.write(value.tokenIds, into: &buf) + FfiConverterSequenceTypeAttributeFilter.write(value.attributeFilters, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenQuery_lift(_ buf: RustBuffer) throws -> TokenQuery { + return try FfiConverterTypeTokenQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenQuery_lower(_ value: TokenQuery) -> RustBuffer { + return FfiConverterTypeTokenQuery.lower(value) +} + + +public struct TokenTransfer: Equatable, Hashable { + public let id: String + public let contractAddress: FieldElement + public let fromAddress: FieldElement + public let toAddress: FieldElement + public let amount: U256 + public let tokenId: U256? + public let executedAt: UInt64 + public let eventId: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, contractAddress: FieldElement, fromAddress: FieldElement, toAddress: FieldElement, amount: U256, tokenId: U256?, executedAt: UInt64, eventId: String?) { + self.id = id + self.contractAddress = contractAddress + self.fromAddress = fromAddress + self.toAddress = toAddress + self.amount = amount + self.tokenId = tokenId + self.executedAt = executedAt + self.eventId = eventId + } + + +} + +#if compiler(>=6) +extension TokenTransfer: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenTransfer: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenTransfer { + return + try TokenTransfer( + id: FfiConverterString.read(from: &buf), + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + fromAddress: FfiConverterTypeFieldElement.read(from: &buf), + toAddress: FfiConverterTypeFieldElement.read(from: &buf), + amount: FfiConverterTypeU256.read(from: &buf), + tokenId: FfiConverterOptionTypeU256.read(from: &buf), + executedAt: FfiConverterUInt64.read(from: &buf), + eventId: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: TokenTransfer, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterTypeFieldElement.write(value.fromAddress, into: &buf) + FfiConverterTypeFieldElement.write(value.toAddress, into: &buf) + FfiConverterTypeU256.write(value.amount, into: &buf) + FfiConverterOptionTypeU256.write(value.tokenId, into: &buf) + FfiConverterUInt64.write(value.executedAt, into: &buf) + FfiConverterOptionString.write(value.eventId, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenTransfer_lift(_ buf: RustBuffer) throws -> TokenTransfer { + return try FfiConverterTypeTokenTransfer.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenTransfer_lower(_ value: TokenTransfer) -> RustBuffer { + return FfiConverterTypeTokenTransfer.lower(value) +} + + +public struct TokenTransferQuery: Equatable, Hashable { + public let contractAddresses: [FieldElement] + public let accountAddresses: [FieldElement] + public let tokenIds: [U256] + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddresses: [FieldElement], accountAddresses: [FieldElement], tokenIds: [U256], pagination: Pagination) { + self.contractAddresses = contractAddresses + self.accountAddresses = accountAddresses + self.tokenIds = tokenIds + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension TokenTransferQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTokenTransferQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenTransferQuery { + return + try TokenTransferQuery( + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + accountAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + tokenIds: FfiConverterSequenceTypeU256.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: TokenTransferQuery, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.accountAddresses, into: &buf) + FfiConverterSequenceTypeU256.write(value.tokenIds, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenTransferQuery_lift(_ buf: RustBuffer) throws -> TokenTransferQuery { + return try FfiConverterTypeTokenTransferQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTokenTransferQuery_lower(_ value: TokenTransferQuery) -> RustBuffer { + return FfiConverterTypeTokenTransferQuery.lower(value) +} + + +public struct Transaction: Equatable, Hashable { + public let transactionHash: FieldElement + public let senderAddress: FieldElement + public let calldata: [FieldElement] + public let maxFee: FieldElement + public let signature: [FieldElement] + public let nonce: FieldElement + public let blockNumber: UInt64 + public let transactionType: String + public let blockTimestamp: UInt64 + public let calls: [TransactionCall] + public let uniqueModels: [FieldElement] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(transactionHash: FieldElement, senderAddress: FieldElement, calldata: [FieldElement], maxFee: FieldElement, signature: [FieldElement], nonce: FieldElement, blockNumber: UInt64, transactionType: String, blockTimestamp: UInt64, calls: [TransactionCall], uniqueModels: [FieldElement]) { + self.transactionHash = transactionHash + self.senderAddress = senderAddress + self.calldata = calldata + self.maxFee = maxFee + self.signature = signature + self.nonce = nonce + self.blockNumber = blockNumber + self.transactionType = transactionType + self.blockTimestamp = blockTimestamp + self.calls = calls + self.uniqueModels = uniqueModels + } + + +} + +#if compiler(>=6) +extension Transaction: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTransaction: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Transaction { + return + try Transaction( + transactionHash: FfiConverterTypeFieldElement.read(from: &buf), + senderAddress: FfiConverterTypeFieldElement.read(from: &buf), + calldata: FfiConverterSequenceTypeFieldElement.read(from: &buf), + maxFee: FfiConverterTypeFieldElement.read(from: &buf), + signature: FfiConverterSequenceTypeFieldElement.read(from: &buf), + nonce: FfiConverterTypeFieldElement.read(from: &buf), + blockNumber: FfiConverterUInt64.read(from: &buf), + transactionType: FfiConverterString.read(from: &buf), + blockTimestamp: FfiConverterUInt64.read(from: &buf), + calls: FfiConverterSequenceTypeTransactionCall.read(from: &buf), + uniqueModels: FfiConverterSequenceTypeFieldElement.read(from: &buf) + ) + } + + public static func write(_ value: Transaction, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.transactionHash, into: &buf) + FfiConverterTypeFieldElement.write(value.senderAddress, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.calldata, into: &buf) + FfiConverterTypeFieldElement.write(value.maxFee, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.signature, into: &buf) + FfiConverterTypeFieldElement.write(value.nonce, into: &buf) + FfiConverterUInt64.write(value.blockNumber, into: &buf) + FfiConverterString.write(value.transactionType, into: &buf) + FfiConverterUInt64.write(value.blockTimestamp, into: &buf) + FfiConverterSequenceTypeTransactionCall.write(value.calls, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.uniqueModels, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransaction_lift(_ buf: RustBuffer) throws -> Transaction { + return try FfiConverterTypeTransaction.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransaction_lower(_ value: Transaction) -> RustBuffer { + return FfiConverterTypeTransaction.lower(value) +} + + +public struct TransactionCall: Equatable, Hashable { + public let contractAddress: FieldElement + public let entrypoint: String + public let calldata: [FieldElement] + public let callType: CallType + public let callerAddress: FieldElement + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(contractAddress: FieldElement, entrypoint: String, calldata: [FieldElement], callType: CallType, callerAddress: FieldElement) { + self.contractAddress = contractAddress + self.entrypoint = entrypoint + self.calldata = calldata + self.callType = callType + self.callerAddress = callerAddress + } + + +} + +#if compiler(>=6) +extension TransactionCall: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTransactionCall: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionCall { + return + try TransactionCall( + contractAddress: FfiConverterTypeFieldElement.read(from: &buf), + entrypoint: FfiConverterString.read(from: &buf), + calldata: FfiConverterSequenceTypeFieldElement.read(from: &buf), + callType: FfiConverterTypeCallType.read(from: &buf), + callerAddress: FfiConverterTypeFieldElement.read(from: &buf) + ) + } + + public static func write(_ value: TransactionCall, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.contractAddress, into: &buf) + FfiConverterString.write(value.entrypoint, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.calldata, into: &buf) + FfiConverterTypeCallType.write(value.callType, into: &buf) + FfiConverterTypeFieldElement.write(value.callerAddress, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionCall_lift(_ buf: RustBuffer) throws -> TransactionCall { + return try FfiConverterTypeTransactionCall.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionCall_lower(_ value: TransactionCall) -> RustBuffer { + return FfiConverterTypeTransactionCall.lower(value) +} + + +public struct TransactionFilter: Equatable, Hashable { + public let transactionHashes: [FieldElement] + public let callerAddresses: [FieldElement] + public let contractAddresses: [FieldElement] + public let entrypoints: [String] + public let modelSelectors: [FieldElement] + public let fromBlock: UInt64? + public let toBlock: UInt64? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(transactionHashes: [FieldElement], callerAddresses: [FieldElement], contractAddresses: [FieldElement], entrypoints: [String], modelSelectors: [FieldElement], fromBlock: UInt64?, toBlock: UInt64?) { + self.transactionHashes = transactionHashes + self.callerAddresses = callerAddresses + self.contractAddresses = contractAddresses + self.entrypoints = entrypoints + self.modelSelectors = modelSelectors + self.fromBlock = fromBlock + self.toBlock = toBlock + } + + +} + +#if compiler(>=6) +extension TransactionFilter: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTransactionFilter: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionFilter { + return + try TransactionFilter( + transactionHashes: FfiConverterSequenceTypeFieldElement.read(from: &buf), + callerAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + contractAddresses: FfiConverterSequenceTypeFieldElement.read(from: &buf), + entrypoints: FfiConverterSequenceString.read(from: &buf), + modelSelectors: FfiConverterSequenceTypeFieldElement.read(from: &buf), + fromBlock: FfiConverterOptionUInt64.read(from: &buf), + toBlock: FfiConverterOptionUInt64.read(from: &buf) + ) + } + + public static func write(_ value: TransactionFilter, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFieldElement.write(value.transactionHashes, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.callerAddresses, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.contractAddresses, into: &buf) + FfiConverterSequenceString.write(value.entrypoints, into: &buf) + FfiConverterSequenceTypeFieldElement.write(value.modelSelectors, into: &buf) + FfiConverterOptionUInt64.write(value.fromBlock, into: &buf) + FfiConverterOptionUInt64.write(value.toBlock, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionFilter_lift(_ buf: RustBuffer) throws -> TransactionFilter { + return try FfiConverterTypeTransactionFilter.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionFilter_lower(_ value: TransactionFilter) -> RustBuffer { + return FfiConverterTypeTransactionFilter.lower(value) +} + + +public struct TransactionQuery: Equatable, Hashable { + public let filter: TransactionFilter? + public let pagination: Pagination + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(filter: TransactionFilter?, pagination: Pagination) { + self.filter = filter + self.pagination = pagination + } + + +} + +#if compiler(>=6) +extension TransactionQuery: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTransactionQuery: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionQuery { + return + try TransactionQuery( + filter: FfiConverterOptionTypeTransactionFilter.read(from: &buf), + pagination: FfiConverterTypePagination.read(from: &buf) + ) + } + + public static func write(_ value: TransactionQuery, into buf: inout [UInt8]) { + FfiConverterOptionTypeTransactionFilter.write(value.filter, into: &buf) + FfiConverterTypePagination.write(value.pagination, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionQuery_lift(_ buf: RustBuffer) throws -> TransactionQuery { + return try FfiConverterTypeTransactionQuery.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionQuery_lower(_ value: TransactionQuery) -> RustBuffer { + return FfiConverterTypeTransactionQuery.lower(value) +} + + +public struct World: Equatable, Hashable { + public let worldAddress: FieldElement + public let models: [Model] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(worldAddress: FieldElement, models: [Model]) { + self.worldAddress = worldAddress + self.models = models + } + + +} + +#if compiler(>=6) +extension World: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWorld: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> World { + return + try World( + worldAddress: FfiConverterTypeFieldElement.read(from: &buf), + models: FfiConverterSequenceTypeModel.read(from: &buf) + ) + } + + public static func write(_ value: World, into buf: inout [UInt8]) { + FfiConverterTypeFieldElement.write(value.worldAddress, into: &buf) + FfiConverterSequenceTypeModel.write(value.models, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWorld_lift(_ buf: RustBuffer) throws -> World { + return try FfiConverterTypeWorld.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWorld_lower(_ value: World) -> RustBuffer { + return FfiConverterTypeWorld.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum CallType: Equatable, Hashable { + + case execute + case executeFromOutside + + + +} + +#if compiler(>=6) +extension CallType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeCallType: FfiConverterRustBuffer { + typealias SwiftType = CallType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CallType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .execute + + case 2: return .executeFromOutside + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: CallType, into buf: inout [UInt8]) { + switch value { + + + case .execute: + writeInt(&buf, Int32(1)) + + + case .executeFromOutside: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCallType_lift(_ buf: RustBuffer) throws -> CallType { + return try FfiConverterTypeCallType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCallType_lower(_ value: CallType) -> RustBuffer { + return FfiConverterTypeCallType.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum Clause: Equatable, Hashable { + + case hashedKeys(keys: [FieldElement] + ) + case keys(clause: KeysClause + ) + case member(clause: MemberClause + ) + case composite(clause: CompositeClause + ) + + + +} + +#if compiler(>=6) +extension Clause: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeClause: FfiConverterRustBuffer { + typealias SwiftType = Clause + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Clause { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .hashedKeys(keys: try FfiConverterSequenceTypeFieldElement.read(from: &buf) + ) + + case 2: return .keys(clause: try FfiConverterTypeKeysClause.read(from: &buf) + ) + + case 3: return .member(clause: try FfiConverterTypeMemberClause.read(from: &buf) + ) + + case 4: return .composite(clause: try FfiConverterTypeCompositeClause.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Clause, into buf: inout [UInt8]) { + switch value { + + + case let .hashedKeys(keys): + writeInt(&buf, Int32(1)) + FfiConverterSequenceTypeFieldElement.write(keys, into: &buf) + + + case let .keys(clause): + writeInt(&buf, Int32(2)) + FfiConverterTypeKeysClause.write(clause, into: &buf) + + + case let .member(clause): + writeInt(&buf, Int32(3)) + FfiConverterTypeMemberClause.write(clause, into: &buf) + + + case let .composite(clause): + writeInt(&buf, Int32(4)) + FfiConverterTypeCompositeClause.write(clause, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeClause_lift(_ buf: RustBuffer) throws -> Clause { + return try FfiConverterTypeClause.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeClause_lower(_ value: Clause) -> RustBuffer { + return FfiConverterTypeClause.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ComparisonOperator: Equatable, Hashable { + + case eq + case neq + case gt + case gte + case lt + case lte + case `in` + case notIn + case contains + case containsAll + case containsAny + case arrayLengthEq + case arrayLengthGt + case arrayLengthLt + + + +} + +#if compiler(>=6) +extension ComparisonOperator: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeComparisonOperator: FfiConverterRustBuffer { + typealias SwiftType = ComparisonOperator + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComparisonOperator { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .eq + + case 2: return .neq + + case 3: return .gt + + case 4: return .gte + + case 5: return .lt + + case 6: return .lte + + case 7: return .`in` + + case 8: return .notIn + + case 9: return .contains + + case 10: return .containsAll + + case 11: return .containsAny + + case 12: return .arrayLengthEq + + case 13: return .arrayLengthGt + + case 14: return .arrayLengthLt + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ComparisonOperator, into buf: inout [UInt8]) { + switch value { + + + case .eq: + writeInt(&buf, Int32(1)) + + + case .neq: + writeInt(&buf, Int32(2)) + + + case .gt: + writeInt(&buf, Int32(3)) + + + case .gte: + writeInt(&buf, Int32(4)) + + + case .lt: + writeInt(&buf, Int32(5)) + + + case .lte: + writeInt(&buf, Int32(6)) + + + case .`in`: + writeInt(&buf, Int32(7)) + + + case .notIn: + writeInt(&buf, Int32(8)) + + + case .contains: + writeInt(&buf, Int32(9)) + + + case .containsAll: + writeInt(&buf, Int32(10)) + + + case .containsAny: + writeInt(&buf, Int32(11)) + + + case .arrayLengthEq: + writeInt(&buf, Int32(12)) + + + case .arrayLengthGt: + writeInt(&buf, Int32(13)) + + + case .arrayLengthLt: + writeInt(&buf, Int32(14)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeComparisonOperator_lift(_ buf: RustBuffer) throws -> ComparisonOperator { + return try FfiConverterTypeComparisonOperator.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeComparisonOperator_lower(_ value: ComparisonOperator) -> RustBuffer { + return FfiConverterTypeComparisonOperator.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ContractType: Equatable, Hashable { + + case world + case erc20 + case erc721 + case erc1155 + case udc + case other + + + +} + +#if compiler(>=6) +extension ContractType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeContractType: FfiConverterRustBuffer { + typealias SwiftType = ContractType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContractType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .world + + case 2: return .erc20 + + case 3: return .erc721 + + case 4: return .erc1155 + + case 5: return .udc + + case 6: return .other + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ContractType, into buf: inout [UInt8]) { + switch value { + + + case .world: + writeInt(&buf, Int32(1)) + + + case .erc20: + writeInt(&buf, Int32(2)) + + + case .erc721: + writeInt(&buf, Int32(3)) + + + case .erc1155: + writeInt(&buf, Int32(4)) + + + case .udc: + writeInt(&buf, Int32(5)) + + + case .other: + writeInt(&buf, Int32(6)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContractType_lift(_ buf: RustBuffer) throws -> ContractType { + return try FfiConverterTypeContractType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeContractType_lower(_ value: ContractType) -> RustBuffer { + return FfiConverterTypeContractType.lower(value) +} + + + +public enum DojoError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { + + + + case ClientError(message: String) + + case SerializationError(message: String) + + case NetworkError(message: String) + + case InvalidInput(message: String) + + case ConnectionError(message: String) + + case PublishError(message: String) + + case QueryError(message: String) + + case SubscriptionError(message: String) + + + + + + public var errorDescription: String? { + String(reflecting: self) + } + +} + +#if compiler(>=6) +extension DojoError: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeDojoError: FfiConverterRustBuffer { + typealias SwiftType = DojoError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DojoError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .ClientError( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .SerializationError( + message: try FfiConverterString.read(from: &buf) + ) + + case 3: return .NetworkError( + message: try FfiConverterString.read(from: &buf) + ) + + case 4: return .InvalidInput( + message: try FfiConverterString.read(from: &buf) + ) + + case 5: return .ConnectionError( + message: try FfiConverterString.read(from: &buf) + ) + + case 6: return .PublishError( + message: try FfiConverterString.read(from: &buf) + ) + + case 7: return .QueryError( + message: try FfiConverterString.read(from: &buf) + ) + + case 8: return .SubscriptionError( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: DojoError, into buf: inout [UInt8]) { + switch value { + + + + + case .ClientError(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .SerializationError(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + case .NetworkError(_ /* message is ignored*/): + writeInt(&buf, Int32(3)) + case .InvalidInput(_ /* message is ignored*/): + writeInt(&buf, Int32(4)) + case .ConnectionError(_ /* message is ignored*/): + writeInt(&buf, Int32(5)) + case .PublishError(_ /* message is ignored*/): + writeInt(&buf, Int32(6)) + case .QueryError(_ /* message is ignored*/): + writeInt(&buf, Int32(7)) + case .SubscriptionError(_ /* message is ignored*/): + writeInt(&buf, Int32(8)) + + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeDojoError_lift(_ buf: RustBuffer) throws -> DojoError { + return try FfiConverterTypeDojoError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeDojoError_lower(_ value: DojoError) -> RustBuffer { + return FfiConverterTypeDojoError.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum LogicalOperator: Equatable, Hashable { + + case and + case or + + + +} + +#if compiler(>=6) +extension LogicalOperator: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeLogicalOperator: FfiConverterRustBuffer { + typealias SwiftType = LogicalOperator + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LogicalOperator { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .and + + case 2: return .or + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: LogicalOperator, into buf: inout [UInt8]) { + switch value { + + + case .and: + writeInt(&buf, Int32(1)) + + + case .or: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeLogicalOperator_lift(_ buf: RustBuffer) throws -> LogicalOperator { + return try FfiConverterTypeLogicalOperator.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeLogicalOperator_lower(_ value: LogicalOperator) -> RustBuffer { + return FfiConverterTypeLogicalOperator.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum MemberValue: Equatable, Hashable { + + case primitive(value: Primitive + ) + case string(value: String + ) + case list(values: [MemberValue] + ) + + + +} + +#if compiler(>=6) +extension MemberValue: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeMemberValue: FfiConverterRustBuffer { + typealias SwiftType = MemberValue + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MemberValue { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .primitive(value: try FfiConverterTypePrimitive.read(from: &buf) + ) + + case 2: return .string(value: try FfiConverterString.read(from: &buf) + ) + + case 3: return .list(values: try FfiConverterSequenceTypeMemberValue.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MemberValue, into buf: inout [UInt8]) { + switch value { + + + case let .primitive(value): + writeInt(&buf, Int32(1)) + FfiConverterTypePrimitive.write(value, into: &buf) + + + case let .string(value): + writeInt(&buf, Int32(2)) + FfiConverterString.write(value, into: &buf) + + + case let .list(values): + writeInt(&buf, Int32(3)) + FfiConverterSequenceTypeMemberValue.write(values, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMemberValue_lift(_ buf: RustBuffer) throws -> MemberValue { + return try FfiConverterTypeMemberValue.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeMemberValue_lower(_ value: MemberValue) -> RustBuffer { + return FfiConverterTypeMemberValue.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum OrderDirection: Equatable, Hashable { + + case asc + case desc + + + +} + +#if compiler(>=6) +extension OrderDirection: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeOrderDirection: FfiConverterRustBuffer { + typealias SwiftType = OrderDirection + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OrderDirection { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .asc + + case 2: return .desc + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: OrderDirection, into buf: inout [UInt8]) { + switch value { + + + case .asc: + writeInt(&buf, Int32(1)) + + + case .desc: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeOrderDirection_lift(_ buf: RustBuffer) throws -> OrderDirection { + return try FfiConverterTypeOrderDirection.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeOrderDirection_lower(_ value: OrderDirection) -> RustBuffer { + return FfiConverterTypeOrderDirection.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum PaginationDirection: Equatable, Hashable { + + case forward + case backward + + + +} + +#if compiler(>=6) +extension PaginationDirection: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePaginationDirection: FfiConverterRustBuffer { + typealias SwiftType = PaginationDirection + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaginationDirection { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .forward + + case 2: return .backward + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: PaginationDirection, into buf: inout [UInt8]) { + switch value { + + + case .forward: + writeInt(&buf, Int32(1)) + + + case .backward: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaginationDirection_lift(_ buf: RustBuffer) throws -> PaginationDirection { + return try FfiConverterTypePaginationDirection.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaginationDirection_lower(_ value: PaginationDirection) -> RustBuffer { + return FfiConverterTypePaginationDirection.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum PatternMatching: Equatable, Hashable { + + case fixedLen + case variableLen + + + +} + +#if compiler(>=6) +extension PatternMatching: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePatternMatching: FfiConverterRustBuffer { + typealias SwiftType = PatternMatching + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PatternMatching { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .fixedLen + + case 2: return .variableLen + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: PatternMatching, into buf: inout [UInt8]) { + switch value { + + + case .fixedLen: + writeInt(&buf, Int32(1)) + + + case .variableLen: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePatternMatching_lift(_ buf: RustBuffer) throws -> PatternMatching { + return try FfiConverterTypePatternMatching.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePatternMatching_lower(_ value: PatternMatching) -> RustBuffer { + return FfiConverterTypePatternMatching.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum Primitive: Equatable, Hashable { + + case i8(value: Int8 + ) + case i16(value: Int16 + ) + case i32(value: Int32 + ) + case i64(value: Int64 + ) + case i128(value: [UInt8] + ) + case u8(value: UInt8 + ) + case u16(value: UInt16 + ) + case u32(value: UInt32 + ) + case u64(value: UInt64 + ) + case u128(value: [UInt8] + ) + case u256(value: U256 + ) + case bool(value: Bool + ) + case felt252(value: FieldElement + ) + case classHash(value: FieldElement + ) + case contractAddress(value: FieldElement + ) + case ethAddress(value: FieldElement + ) + + + +} + +#if compiler(>=6) +extension Primitive: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePrimitive: FfiConverterRustBuffer { + typealias SwiftType = Primitive + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Primitive { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .i8(value: try FfiConverterInt8.read(from: &buf) + ) + + case 2: return .i16(value: try FfiConverterInt16.read(from: &buf) + ) + + case 3: return .i32(value: try FfiConverterInt32.read(from: &buf) + ) + + case 4: return .i64(value: try FfiConverterInt64.read(from: &buf) + ) + + case 5: return .i128(value: try FfiConverterSequenceUInt8.read(from: &buf) + ) + + case 6: return .u8(value: try FfiConverterUInt8.read(from: &buf) + ) + + case 7: return .u16(value: try FfiConverterUInt16.read(from: &buf) + ) + + case 8: return .u32(value: try FfiConverterUInt32.read(from: &buf) + ) + + case 9: return .u64(value: try FfiConverterUInt64.read(from: &buf) + ) + + case 10: return .u128(value: try FfiConverterSequenceUInt8.read(from: &buf) + ) + + case 11: return .u256(value: try FfiConverterTypeU256.read(from: &buf) + ) + + case 12: return .bool(value: try FfiConverterBool.read(from: &buf) + ) + + case 13: return .felt252(value: try FfiConverterTypeFieldElement.read(from: &buf) + ) + + case 14: return .classHash(value: try FfiConverterTypeFieldElement.read(from: &buf) + ) + + case 15: return .contractAddress(value: try FfiConverterTypeFieldElement.read(from: &buf) + ) + + case 16: return .ethAddress(value: try FfiConverterTypeFieldElement.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Primitive, into buf: inout [UInt8]) { + switch value { + + + case let .i8(value): + writeInt(&buf, Int32(1)) + FfiConverterInt8.write(value, into: &buf) + + + case let .i16(value): + writeInt(&buf, Int32(2)) + FfiConverterInt16.write(value, into: &buf) + + + case let .i32(value): + writeInt(&buf, Int32(3)) + FfiConverterInt32.write(value, into: &buf) + + + case let .i64(value): + writeInt(&buf, Int32(4)) + FfiConverterInt64.write(value, into: &buf) + + + case let .i128(value): + writeInt(&buf, Int32(5)) + FfiConverterSequenceUInt8.write(value, into: &buf) + + + case let .u8(value): + writeInt(&buf, Int32(6)) + FfiConverterUInt8.write(value, into: &buf) + + + case let .u16(value): + writeInt(&buf, Int32(7)) + FfiConverterUInt16.write(value, into: &buf) + + + case let .u32(value): + writeInt(&buf, Int32(8)) + FfiConverterUInt32.write(value, into: &buf) + + + case let .u64(value): + writeInt(&buf, Int32(9)) + FfiConverterUInt64.write(value, into: &buf) + + + case let .u128(value): + writeInt(&buf, Int32(10)) + FfiConverterSequenceUInt8.write(value, into: &buf) + + + case let .u256(value): + writeInt(&buf, Int32(11)) + FfiConverterTypeU256.write(value, into: &buf) + + + case let .bool(value): + writeInt(&buf, Int32(12)) + FfiConverterBool.write(value, into: &buf) + + + case let .felt252(value): + writeInt(&buf, Int32(13)) + FfiConverterTypeFieldElement.write(value, into: &buf) + + + case let .classHash(value): + writeInt(&buf, Int32(14)) + FfiConverterTypeFieldElement.write(value, into: &buf) + + + case let .contractAddress(value): + writeInt(&buf, Int32(15)) + FfiConverterTypeFieldElement.write(value, into: &buf) + + + case let .ethAddress(value): + writeInt(&buf, Int32(16)) + FfiConverterTypeFieldElement.write(value, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePrimitive_lift(_ buf: RustBuffer) throws -> Primitive { + return try FfiConverterTypePrimitive.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePrimitive_lower(_ value: Primitive) -> RustBuffer { + return FfiConverterTypePrimitive.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum SqlValue: Equatable, Hashable { + + case text(value: String + ) + case integer(value: Int64 + ) + case real(value: Double + ) + case blob(value: [UInt8] + ) + case null + + + +} + +#if compiler(>=6) +extension SqlValue: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSqlValue: FfiConverterRustBuffer { + typealias SwiftType = SqlValue + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SqlValue { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .text(value: try FfiConverterString.read(from: &buf) + ) + + case 2: return .integer(value: try FfiConverterInt64.read(from: &buf) + ) + + case 3: return .real(value: try FfiConverterDouble.read(from: &buf) + ) + + case 4: return .blob(value: try FfiConverterSequenceUInt8.read(from: &buf) + ) + + case 5: return .null + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: SqlValue, into buf: inout [UInt8]) { + switch value { + + + case let .text(value): + writeInt(&buf, Int32(1)) + FfiConverterString.write(value, into: &buf) + + + case let .integer(value): + writeInt(&buf, Int32(2)) + FfiConverterInt64.write(value, into: &buf) + + + case let .real(value): + writeInt(&buf, Int32(3)) + FfiConverterDouble.write(value, into: &buf) + + + case let .blob(value): + writeInt(&buf, Int32(4)) + FfiConverterSequenceUInt8.write(value, into: &buf) + + + case .null: + writeInt(&buf, Int32(5)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlValue_lift(_ buf: RustBuffer) throws -> SqlValue { + return try FfiConverterTypeSqlValue.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSqlValue_lower(_ value: SqlValue) -> RustBuffer { + return FfiConverterTypeSqlValue.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum Ty: Equatable, Hashable { + + case primitive(value: Primitive + ) + case `struct`(value: Struct + ) + case `enum`(value: EnumType + ) + case tuple(values: [Ty] + ) + case array(values: [Ty] + ) + case fixedSizeArray(value: FixedSizeArray + ) + case byteArray(value: String + ) + + + +} + +#if compiler(>=6) +extension Ty: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTy: FfiConverterRustBuffer { + typealias SwiftType = Ty + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Ty { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .primitive(value: try FfiConverterTypePrimitive.read(from: &buf) + ) + + case 2: return .`struct`(value: try FfiConverterTypeStruct.read(from: &buf) + ) + + case 3: return .`enum`(value: try FfiConverterTypeEnumType.read(from: &buf) + ) + + case 4: return .tuple(values: try FfiConverterSequenceTypeTy.read(from: &buf) + ) + + case 5: return .array(values: try FfiConverterSequenceTypeTy.read(from: &buf) + ) + + case 6: return .fixedSizeArray(value: try FfiConverterTypeFixedSizeArray.read(from: &buf) + ) + + case 7: return .byteArray(value: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Ty, into buf: inout [UInt8]) { + switch value { + + + case let .primitive(value): + writeInt(&buf, Int32(1)) + FfiConverterTypePrimitive.write(value, into: &buf) + + + case let .`struct`(value): + writeInt(&buf, Int32(2)) + FfiConverterTypeStruct.write(value, into: &buf) + + + case let .`enum`(value): + writeInt(&buf, Int32(3)) + FfiConverterTypeEnumType.write(value, into: &buf) + + + case let .tuple(values): + writeInt(&buf, Int32(4)) + FfiConverterSequenceTypeTy.write(values, into: &buf) + + + case let .array(values): + writeInt(&buf, Int32(5)) + FfiConverterSequenceTypeTy.write(values, into: &buf) + + + case let .fixedSizeArray(value): + writeInt(&buf, Int32(6)) + FfiConverterTypeFixedSizeArray.write(value, into: &buf) + + + case let .byteArray(value): + writeInt(&buf, Int32(7)) + FfiConverterString.write(value, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTy_lift(_ buf: RustBuffer) throws -> Ty { + return try FfiConverterTypeTy.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTy_lower(_ value: Ty) -> RustBuffer { + return FfiConverterTypeTy.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ValueType: Equatable, Hashable { + + case string(value: String + ) + case int(value: Int64 + ) + case uInt(value: UInt64 + ) + case bool(value: Bool + ) + case bytes(value: [UInt8] + ) + + + +} + +#if compiler(>=6) +extension ValueType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeValueType: FfiConverterRustBuffer { + typealias SwiftType = ValueType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValueType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .string(value: try FfiConverterString.read(from: &buf) + ) + + case 2: return .int(value: try FfiConverterInt64.read(from: &buf) + ) + + case 3: return .uInt(value: try FfiConverterUInt64.read(from: &buf) + ) + + case 4: return .bool(value: try FfiConverterBool.read(from: &buf) + ) + + case 5: return .bytes(value: try FfiConverterSequenceUInt8.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ValueType, into buf: inout [UInt8]) { + switch value { + + + case let .string(value): + writeInt(&buf, Int32(1)) + FfiConverterString.write(value, into: &buf) + + + case let .int(value): + writeInt(&buf, Int32(2)) + FfiConverterInt64.write(value, into: &buf) + + + case let .uInt(value): + writeInt(&buf, Int32(3)) + FfiConverterUInt64.write(value, into: &buf) + + + case let .bool(value): + writeInt(&buf, Int32(4)) + FfiConverterBool.write(value, into: &buf) + + + case let .bytes(value): + writeInt(&buf, Int32(5)) + FfiConverterSequenceUInt8.write(value, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValueType_lift(_ buf: RustBuffer) throws -> ValueType { + return try FfiConverterTypeValueType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValueType_lower(_ value: ValueType) -> RustBuffer { + return FfiConverterTypeValueType.lower(value) +} + + + + + +public protocol EntityUpdateCallback: AnyObject, Sendable { + + func onUpdate(entity: Entity) + + func onError(error: String) + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceEntityUpdateCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceEntityUpdateCallback] = [UniffiVTableCallbackInterfaceEntityUpdateCallback( + uniffiFree: { (uniffiHandle: UInt64) -> () in + do { + try FfiConverterCallbackInterfaceEntityUpdateCallback.handleMap.remove(handle: uniffiHandle) + } catch { + print("Uniffi callback interface EntityUpdateCallback: handle missing in uniffiFree") + } + }, + uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in + do { + return try FfiConverterCallbackInterfaceEntityUpdateCallback.handleMap.clone(handle: uniffiHandle) + } catch { + fatalError("Uniffi callback interface EntityUpdateCallback: handle missing in uniffiClone") + } + }, + onUpdate: { ( + uniffiHandle: UInt64, + entity: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceEntityUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onUpdate( + entity: try FfiConverterTypeEntity_lift(entity) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onError: { ( + uniffiHandle: UInt64, + error: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceEntityUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onError( + error: try FfiConverterString.lift(error) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + } + )] +} + +private func uniffiCallbackInitEntityUpdateCallback() { + uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(UniffiCallbackInterfaceEntityUpdateCallback.vtable) +} + +// FfiConverter protocol for callback interfaces +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterCallbackInterfaceEntityUpdateCallback { + fileprivate static let handleMap = UniffiHandleMap() +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +extension FfiConverterCallbackInterfaceEntityUpdateCallback : FfiConverter { + typealias SwiftType = EntityUpdateCallback + typealias FfiType = UInt64 + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ handle: UInt64) throws -> SwiftType { + try handleMap.get(handle: handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ v: SwiftType) -> UInt64 { + return handleMap.insert(obj: v) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceEntityUpdateCallback_lift(_ handle: UInt64) throws -> EntityUpdateCallback { + return try FfiConverterCallbackInterfaceEntityUpdateCallback.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceEntityUpdateCallback_lower(_ v: EntityUpdateCallback) -> UInt64 { + return FfiConverterCallbackInterfaceEntityUpdateCallback.lower(v) +} + + + + +public protocol EventUpdateCallback: AnyObject, Sendable { + + func onUpdate(event: Event) + + func onError(error: String) + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceEventUpdateCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceEventUpdateCallback] = [UniffiVTableCallbackInterfaceEventUpdateCallback( + uniffiFree: { (uniffiHandle: UInt64) -> () in + do { + try FfiConverterCallbackInterfaceEventUpdateCallback.handleMap.remove(handle: uniffiHandle) + } catch { + print("Uniffi callback interface EventUpdateCallback: handle missing in uniffiFree") + } + }, + uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in + do { + return try FfiConverterCallbackInterfaceEventUpdateCallback.handleMap.clone(handle: uniffiHandle) + } catch { + fatalError("Uniffi callback interface EventUpdateCallback: handle missing in uniffiClone") + } + }, + onUpdate: { ( + uniffiHandle: UInt64, + event: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceEventUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onUpdate( + event: try FfiConverterTypeEvent_lift(event) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onError: { ( + uniffiHandle: UInt64, + error: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceEventUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onError( + error: try FfiConverterString.lift(error) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + } + )] +} + +private func uniffiCallbackInitEventUpdateCallback() { + uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(UniffiCallbackInterfaceEventUpdateCallback.vtable) +} + +// FfiConverter protocol for callback interfaces +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterCallbackInterfaceEventUpdateCallback { + fileprivate static let handleMap = UniffiHandleMap() +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +extension FfiConverterCallbackInterfaceEventUpdateCallback : FfiConverter { + typealias SwiftType = EventUpdateCallback + typealias FfiType = UInt64 + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ handle: UInt64) throws -> SwiftType { + try handleMap.get(handle: handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ v: SwiftType) -> UInt64 { + return handleMap.insert(obj: v) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceEventUpdateCallback_lift(_ handle: UInt64) throws -> EventUpdateCallback { + return try FfiConverterCallbackInterfaceEventUpdateCallback.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceEventUpdateCallback_lower(_ v: EventUpdateCallback) -> UInt64 { + return FfiConverterCallbackInterfaceEventUpdateCallback.lower(v) +} + + + + +public protocol TokenBalanceUpdateCallback: AnyObject, Sendable { + + func onUpdate(balance: TokenBalance) + + func onError(error: String) + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceTokenBalanceUpdateCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback] = [UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback( + uniffiFree: { (uniffiHandle: UInt64) -> () in + do { + try FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.handleMap.remove(handle: uniffiHandle) + } catch { + print("Uniffi callback interface TokenBalanceUpdateCallback: handle missing in uniffiFree") + } + }, + uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in + do { + return try FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.handleMap.clone(handle: uniffiHandle) + } catch { + fatalError("Uniffi callback interface TokenBalanceUpdateCallback: handle missing in uniffiClone") + } + }, + onUpdate: { ( + uniffiHandle: UInt64, + balance: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onUpdate( + balance: try FfiConverterTypeTokenBalance_lift(balance) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onError: { ( + uniffiHandle: UInt64, + error: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onError( + error: try FfiConverterString.lift(error) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + } + )] +} + +private func uniffiCallbackInitTokenBalanceUpdateCallback() { + uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(UniffiCallbackInterfaceTokenBalanceUpdateCallback.vtable) +} + +// FfiConverter protocol for callback interfaces +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterCallbackInterfaceTokenBalanceUpdateCallback { + fileprivate static let handleMap = UniffiHandleMap() +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +extension FfiConverterCallbackInterfaceTokenBalanceUpdateCallback : FfiConverter { + typealias SwiftType = TokenBalanceUpdateCallback + typealias FfiType = UInt64 + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ handle: UInt64) throws -> SwiftType { + try handleMap.get(handle: handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ v: SwiftType) -> UInt64 { + return handleMap.insert(obj: v) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTokenBalanceUpdateCallback_lift(_ handle: UInt64) throws -> TokenBalanceUpdateCallback { + return try FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTokenBalanceUpdateCallback_lower(_ v: TokenBalanceUpdateCallback) -> UInt64 { + return FfiConverterCallbackInterfaceTokenBalanceUpdateCallback.lower(v) +} + + + + +public protocol TokenUpdateCallback: AnyObject, Sendable { + + func onUpdate(token: Token) + + func onError(error: String) + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceTokenUpdateCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceTokenUpdateCallback] = [UniffiVTableCallbackInterfaceTokenUpdateCallback( + uniffiFree: { (uniffiHandle: UInt64) -> () in + do { + try FfiConverterCallbackInterfaceTokenUpdateCallback.handleMap.remove(handle: uniffiHandle) + } catch { + print("Uniffi callback interface TokenUpdateCallback: handle missing in uniffiFree") + } + }, + uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in + do { + return try FfiConverterCallbackInterfaceTokenUpdateCallback.handleMap.clone(handle: uniffiHandle) + } catch { + fatalError("Uniffi callback interface TokenUpdateCallback: handle missing in uniffiClone") + } + }, + onUpdate: { ( + uniffiHandle: UInt64, + token: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTokenUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onUpdate( + token: try FfiConverterTypeToken_lift(token) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onError: { ( + uniffiHandle: UInt64, + error: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTokenUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onError( + error: try FfiConverterString.lift(error) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + } + )] +} + +private func uniffiCallbackInitTokenUpdateCallback() { + uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(UniffiCallbackInterfaceTokenUpdateCallback.vtable) +} + +// FfiConverter protocol for callback interfaces +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterCallbackInterfaceTokenUpdateCallback { + fileprivate static let handleMap = UniffiHandleMap() +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +extension FfiConverterCallbackInterfaceTokenUpdateCallback : FfiConverter { + typealias SwiftType = TokenUpdateCallback + typealias FfiType = UInt64 + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ handle: UInt64) throws -> SwiftType { + try handleMap.get(handle: handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ v: SwiftType) -> UInt64 { + return handleMap.insert(obj: v) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTokenUpdateCallback_lift(_ handle: UInt64) throws -> TokenUpdateCallback { + return try FfiConverterCallbackInterfaceTokenUpdateCallback.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTokenUpdateCallback_lower(_ v: TokenUpdateCallback) -> UInt64 { + return FfiConverterCallbackInterfaceTokenUpdateCallback.lower(v) +} + + + + +public protocol TransactionUpdateCallback: AnyObject, Sendable { + + func onUpdate(transaction: Transaction) + + func onError(error: String) + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceTransactionUpdateCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceTransactionUpdateCallback] = [UniffiVTableCallbackInterfaceTransactionUpdateCallback( + uniffiFree: { (uniffiHandle: UInt64) -> () in + do { + try FfiConverterCallbackInterfaceTransactionUpdateCallback.handleMap.remove(handle: uniffiHandle) + } catch { + print("Uniffi callback interface TransactionUpdateCallback: handle missing in uniffiFree") + } + }, + uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in + do { + return try FfiConverterCallbackInterfaceTransactionUpdateCallback.handleMap.clone(handle: uniffiHandle) + } catch { + fatalError("Uniffi callback interface TransactionUpdateCallback: handle missing in uniffiClone") + } + }, + onUpdate: { ( + uniffiHandle: UInt64, + transaction: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTransactionUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onUpdate( + transaction: try FfiConverterTypeTransaction_lift(transaction) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onError: { ( + uniffiHandle: UInt64, + error: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterCallbackInterfaceTransactionUpdateCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onError( + error: try FfiConverterString.lift(error) + ) + } + + + let writeReturn = { () } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + } + )] +} + +private func uniffiCallbackInitTransactionUpdateCallback() { + uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(UniffiCallbackInterfaceTransactionUpdateCallback.vtable) +} + +// FfiConverter protocol for callback interfaces +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterCallbackInterfaceTransactionUpdateCallback { + fileprivate static let handleMap = UniffiHandleMap() +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +extension FfiConverterCallbackInterfaceTransactionUpdateCallback : FfiConverter { + typealias SwiftType = TransactionUpdateCallback + typealias FfiType = UInt64 + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ handle: UInt64) throws -> SwiftType { + try handleMap.get(handle: handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ v: SwiftType) -> UInt64 { + return handleMap.insert(obj: v) + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTransactionUpdateCallback_lift(_ handle: UInt64) throws -> TransactionUpdateCallback { + return try FfiConverterCallbackInterfaceTransactionUpdateCallback.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterCallbackInterfaceTransactionUpdateCallback_lower(_ v: TransactionUpdateCallback) -> UInt64 { + return FfiConverterCallbackInterfaceTransactionUpdateCallback.lower(v) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { + typealias SwiftType = UInt32? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterUInt32.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterUInt32.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer { + typealias SwiftType = UInt64? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterUInt64.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterUInt64.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer { + typealias SwiftType = Bool? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterBool.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterBool.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterString.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeKeysClause: FfiConverterRustBuffer { + typealias SwiftType = KeysClause? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeKeysClause.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeKeysClause.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeTransactionFilter: FfiConverterRustBuffer { + typealias SwiftType = TransactionFilter? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeTransactionFilter.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeTransactionFilter.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeClause: FfiConverterRustBuffer { + typealias SwiftType = Clause? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeClause.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeClause.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeFieldElement: FfiConverterRustBuffer { + typealias SwiftType = FieldElement? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeFieldElement.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeFieldElement.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeU256: FfiConverterRustBuffer { + typealias SwiftType = U256? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeU256.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeU256.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceUInt8: FfiConverterRustBuffer { + typealias SwiftType = [UInt8] + + public static func write(_ value: [UInt8], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterUInt8.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [UInt8] { + let len: Int32 = try readInt(&buf) + var seq = [UInt8]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterUInt8.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { + typealias SwiftType = [String] + + public static func write(_ value: [String], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterString.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] { + let len: Int32 = try readInt(&buf) + var seq = [String]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterString.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeAchievement: FfiConverterRustBuffer { + typealias SwiftType = [Achievement] + + public static func write(_ value: [Achievement], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAchievement.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Achievement] { + let len: Int32 = try readInt(&buf) + var seq = [Achievement]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAchievement.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeAchievementTask: FfiConverterRustBuffer { + typealias SwiftType = [AchievementTask] + + public static func write(_ value: [AchievementTask], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAchievementTask.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AchievementTask] { + let len: Int32 = try readInt(&buf) + var seq = [AchievementTask]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAchievementTask.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeActionCount: FfiConverterRustBuffer { + typealias SwiftType = [ActionCount] + + public static func write(_ value: [ActionCount], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeActionCount.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ActionCount] { + let len: Int32 = try readInt(&buf) + var seq = [ActionCount]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeActionCount.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeActivity: FfiConverterRustBuffer { + typealias SwiftType = [Activity] + + public static func write(_ value: [Activity], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeActivity.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Activity] { + let len: Int32 = try readInt(&buf) + var seq = [Activity]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeActivity.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeAggregationEntry: FfiConverterRustBuffer { + typealias SwiftType = [AggregationEntry] + + public static func write(_ value: [AggregationEntry], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAggregationEntry.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AggregationEntry] { + let len: Int32 = try readInt(&buf) + var seq = [AggregationEntry]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAggregationEntry.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeAttributeFilter: FfiConverterRustBuffer { + typealias SwiftType = [AttributeFilter] + + public static func write(_ value: [AttributeFilter], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAttributeFilter.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AttributeFilter] { + let len: Int32 = try readInt(&buf) + var seq = [AttributeFilter]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAttributeFilter.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeContract: FfiConverterRustBuffer { + typealias SwiftType = [Contract] + + public static func write(_ value: [Contract], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeContract.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Contract] { + let len: Int32 = try readInt(&buf) + var seq = [Contract]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeContract.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeController: FfiConverterRustBuffer { + typealias SwiftType = [Controller] + + public static func write(_ value: [Controller], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeController.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Controller] { + let len: Int32 = try readInt(&buf) + var seq = [Controller]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeController.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeEntity: FfiConverterRustBuffer { + typealias SwiftType = [Entity] + + public static func write(_ value: [Entity], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeEntity.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Entity] { + let len: Int32 = try readInt(&buf) + var seq = [Entity]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeEntity.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeEnumOption: FfiConverterRustBuffer { + typealias SwiftType = [EnumOption] + + public static func write(_ value: [EnumOption], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeEnumOption.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EnumOption] { + let len: Int32 = try readInt(&buf) + var seq = [EnumOption]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeEnumOption.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeEvent: FfiConverterRustBuffer { + typealias SwiftType = [Event] + + public static func write(_ value: [Event], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeEvent.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Event] { + let len: Int32 = try readInt(&buf) + var seq = [Event]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeEvent.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeKeysClause: FfiConverterRustBuffer { + typealias SwiftType = [KeysClause] + + public static func write(_ value: [KeysClause], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeKeysClause.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [KeysClause] { + let len: Int32 = try readInt(&buf) + var seq = [KeysClause]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeKeysClause.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeMember: FfiConverterRustBuffer { + typealias SwiftType = [Member] + + public static func write(_ value: [Member], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeMember.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Member] { + let len: Int32 = try readInt(&buf) + var seq = [Member]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeMember.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeMessage: FfiConverterRustBuffer { + typealias SwiftType = [Message] + + public static func write(_ value: [Message], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeMessage.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Message] { + let len: Int32 = try readInt(&buf) + var seq = [Message]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeMessage.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeModel: FfiConverterRustBuffer { + typealias SwiftType = [Model] + + public static func write(_ value: [Model], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeModel.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Model] { + let len: Int32 = try readInt(&buf) + var seq = [Model]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeModel.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeOrderBy: FfiConverterRustBuffer { + typealias SwiftType = [OrderBy] + + public static func write(_ value: [OrderBy], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeOrderBy.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OrderBy] { + let len: Int32 = try readInt(&buf) + var seq = [OrderBy]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeOrderBy.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypePlayerAchievementEntry: FfiConverterRustBuffer { + typealias SwiftType = [PlayerAchievementEntry] + + public static func write(_ value: [PlayerAchievementEntry], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypePlayerAchievementEntry.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PlayerAchievementEntry] { + let len: Int32 = try readInt(&buf) + var seq = [PlayerAchievementEntry]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypePlayerAchievementEntry.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypePlayerAchievementProgress: FfiConverterRustBuffer { + typealias SwiftType = [PlayerAchievementProgress] + + public static func write(_ value: [PlayerAchievementProgress], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypePlayerAchievementProgress.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PlayerAchievementProgress] { + let len: Int32 = try readInt(&buf) + var seq = [PlayerAchievementProgress]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypePlayerAchievementProgress.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeSqlField: FfiConverterRustBuffer { + typealias SwiftType = [SqlField] + + public static func write(_ value: [SqlField], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeSqlField.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [SqlField] { + let len: Int32 = try readInt(&buf) + var seq = [SqlField]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeSqlField.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeSqlRow: FfiConverterRustBuffer { + typealias SwiftType = [SqlRow] + + public static func write(_ value: [SqlRow], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeSqlRow.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [SqlRow] { + let len: Int32 = try readInt(&buf) + var seq = [SqlRow]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeSqlRow.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeStruct: FfiConverterRustBuffer { + typealias SwiftType = [Struct] + + public static func write(_ value: [Struct], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeStruct.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Struct] { + let len: Int32 = try readInt(&buf) + var seq = [Struct]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeStruct.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTaskProgress: FfiConverterRustBuffer { + typealias SwiftType = [TaskProgress] + + public static func write(_ value: [TaskProgress], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTaskProgress.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TaskProgress] { + let len: Int32 = try readInt(&buf) + var seq = [TaskProgress]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTaskProgress.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeToken: FfiConverterRustBuffer { + typealias SwiftType = [Token] + + public static func write(_ value: [Token], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeToken.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Token] { + let len: Int32 = try readInt(&buf) + var seq = [Token]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeToken.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTokenBalance: FfiConverterRustBuffer { + typealias SwiftType = [TokenBalance] + + public static func write(_ value: [TokenBalance], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTokenBalance.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TokenBalance] { + let len: Int32 = try readInt(&buf) + var seq = [TokenBalance]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTokenBalance.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTokenContract: FfiConverterRustBuffer { + typealias SwiftType = [TokenContract] + + public static func write(_ value: [TokenContract], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTokenContract.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TokenContract] { + let len: Int32 = try readInt(&buf) + var seq = [TokenContract]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTokenContract.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTokenTransfer: FfiConverterRustBuffer { + typealias SwiftType = [TokenTransfer] + + public static func write(_ value: [TokenTransfer], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTokenTransfer.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TokenTransfer] { + let len: Int32 = try readInt(&buf) + var seq = [TokenTransfer]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTokenTransfer.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTransaction: FfiConverterRustBuffer { + typealias SwiftType = [Transaction] + + public static func write(_ value: [Transaction], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTransaction.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Transaction] { + let len: Int32 = try readInt(&buf) + var seq = [Transaction]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTransaction.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTransactionCall: FfiConverterRustBuffer { + typealias SwiftType = [TransactionCall] + + public static func write(_ value: [TransactionCall], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTransactionCall.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TransactionCall] { + let len: Int32 = try readInt(&buf) + var seq = [TransactionCall]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTransactionCall.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeWorld: FfiConverterRustBuffer { + typealias SwiftType = [World] + + public static func write(_ value: [World], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeWorld.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [World] { + let len: Int32 = try readInt(&buf) + var seq = [World]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeWorld.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeClause: FfiConverterRustBuffer { + typealias SwiftType = [Clause] + + public static func write(_ value: [Clause], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeClause.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Clause] { + let len: Int32 = try readInt(&buf) + var seq = [Clause]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeClause.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeContractType: FfiConverterRustBuffer { + typealias SwiftType = [ContractType] + + public static func write(_ value: [ContractType], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeContractType.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ContractType] { + let len: Int32 = try readInt(&buf) + var seq = [ContractType]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeContractType.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeMemberValue: FfiConverterRustBuffer { + typealias SwiftType = [MemberValue] + + public static func write(_ value: [MemberValue], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeMemberValue.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [MemberValue] { + let len: Int32 = try readInt(&buf) + var seq = [MemberValue]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeMemberValue.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeTy: FfiConverterRustBuffer { + typealias SwiftType = [Ty] + + public static func write(_ value: [Ty], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeTy.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Ty] { + let len: Int32 = try readInt(&buf) + var seq = [Ty]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeTy.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceOptionTypeFieldElement: FfiConverterRustBuffer { + typealias SwiftType = [FieldElement?] + + public static func write(_ value: [FieldElement?], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterOptionTypeFieldElement.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FieldElement?] { + let len: Int32 = try readInt(&buf) + var seq = [FieldElement?]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterOptionTypeFieldElement.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeFieldElement: FfiConverterRustBuffer { + typealias SwiftType = [FieldElement] + + public static func write(_ value: [FieldElement], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeFieldElement.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FieldElement] { + let len: Int32 = try readInt(&buf) + var seq = [FieldElement]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeFieldElement.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeU256: FfiConverterRustBuffer { + typealias SwiftType = [U256] + + public static func write(_ value: [U256], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeU256.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [U256] { + let len: Int32 = try readInt(&buf) + var seq = [U256]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeU256.read(from: &buf)) + } + return seq + } +} + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias FieldElement = String + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeFieldElement: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FieldElement { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: FieldElement, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> FieldElement { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: FieldElement) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeFieldElement_lift(_ value: RustBuffer) throws -> FieldElement { + return try FfiConverterTypeFieldElement.lift(value) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeFieldElement_lower(_ value: FieldElement) -> RustBuffer { + return FfiConverterTypeFieldElement.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias U256 = String + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeU256: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> U256 { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: U256, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> U256 { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: U256) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeU256_lift(_ value: RustBuffer) throws -> U256 { + return try FfiConverterTypeU256.lift(value) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeU256_lower(_ value: U256) -> RustBuffer { + return FfiConverterTypeU256.lower(value) +} + + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variable to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private let initializationResult: InitializationResult = { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_dojo_uniffi_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_achievements() != 45327) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_activities() != 43349) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations() != 12858) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription() != 31182) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_contracts() != 1861) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_controllers() != 55573) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_entities() != 50647) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages() != 35425) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements() != 61773) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message() != 30179) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch() != 2146) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_sql() != 38286) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events() != 44694) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates() != 17350) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates() != 63983) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates() != 26741) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates() != 54836) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates() != 10040) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances() != 1716) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts() != 49563) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers() != 10363) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_tokens() != 10630) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_transactions() != 46460) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_toriiclient_worlds() != 23254) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_constructor_toriiclient_new() != 18057) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config() != 42232) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update() != 15850) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error() != 340) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update() != 13627) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error() != 61050) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update() != 10763) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error() != 46610) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update() != 40037) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error() != 14408) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update() != 11896) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error() != 18113) { + return InitializationResult.apiChecksumMismatch + } + + uniffiCallbackInitEntityUpdateCallback() + uniffiCallbackInitEventUpdateCallback() + uniffiCallbackInitTokenBalanceUpdateCallback() + uniffiCallbackInitTokenUpdateCallback() + uniffiCallbackInitTransactionUpdateCallback() + return InitializationResult.ok +}() + +// Make the ensure init function public so that other modules which have external type references to +// our types can call it. +public func uniffiEnsureDojoUniffiInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +// swiftlint:enable all \ No newline at end of file diff --git a/bindings/swift/DojoEngineFFI.h b/bindings/swift/DojoEngineFFI.h new file mode 100644 index 0000000..8dec111 --- /dev/null +++ b/bindings/swift/DojoEngineFFI.h @@ -0,0 +1,1013 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + uint64_t capacity; + uint64_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H +#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +typedef void (*UniffiCallbackInterfaceFree)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +typedef uint64_t (*UniffiCallbackInterfaceClone)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +typedef struct UniffiForeignFutureDroppedCallbackStruct { + uint64_t handle; + UniffiForeignFutureDroppedCallback _Nonnull free; +} UniffiForeignFutureDroppedCallbackStruct; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +typedef struct UniffiForeignFutureResultU8 { + uint8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +typedef struct UniffiForeignFutureResultI8 { + int8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +typedef struct UniffiForeignFutureResultU16 { + uint16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +typedef struct UniffiForeignFutureResultI16 { + int16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +typedef struct UniffiForeignFutureResultU32 { + uint32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +typedef struct UniffiForeignFutureResultI32 { + int32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +typedef struct UniffiForeignFutureResultU64 { + uint64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +typedef struct UniffiForeignFutureResultI64 { + int64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +typedef struct UniffiForeignFutureResultF32 { + float returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +typedef struct UniffiForeignFutureResultF64 { + double returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +typedef struct UniffiForeignFutureResultRustBuffer { + RustBuffer returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultRustBuffer; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +typedef struct UniffiForeignFutureResultVoid { + RustCallStatus callStatus; +} UniffiForeignFutureResultVoid; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceEntityUpdateCallbackMethod0)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceEntityUpdateCallbackMethod1)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceEventUpdateCallbackMethod0)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceEventUpdateCallbackMethod1)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTokenUpdateCallbackMethod0)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTokenUpdateCallbackMethod1)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTransactionUpdateCallbackMethod0)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTransactionUpdateCallbackMethod1)(uint64_t, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_ENTITY_UPDATE_CALLBACK +typedef struct UniffiVTableCallbackInterfaceEntityUpdateCallback { + UniffiCallbackInterfaceFree _Nonnull uniffiFree; + UniffiCallbackInterfaceClone _Nonnull uniffiClone; + UniffiCallbackInterfaceEntityUpdateCallbackMethod0 _Nonnull onUpdate; + UniffiCallbackInterfaceEntityUpdateCallbackMethod1 _Nonnull onError; +} UniffiVTableCallbackInterfaceEntityUpdateCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_EVENT_UPDATE_CALLBACK +typedef struct UniffiVTableCallbackInterfaceEventUpdateCallback { + UniffiCallbackInterfaceFree _Nonnull uniffiFree; + UniffiCallbackInterfaceClone _Nonnull uniffiClone; + UniffiCallbackInterfaceEventUpdateCallbackMethod0 _Nonnull onUpdate; + UniffiCallbackInterfaceEventUpdateCallbackMethod1 _Nonnull onError; +} UniffiVTableCallbackInterfaceEventUpdateCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TOKEN_BALANCE_UPDATE_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback { + UniffiCallbackInterfaceFree _Nonnull uniffiFree; + UniffiCallbackInterfaceClone _Nonnull uniffiClone; + UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 _Nonnull onUpdate; + UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 _Nonnull onError; +} UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TOKEN_UPDATE_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTokenUpdateCallback { + UniffiCallbackInterfaceFree _Nonnull uniffiFree; + UniffiCallbackInterfaceClone _Nonnull uniffiClone; + UniffiCallbackInterfaceTokenUpdateCallbackMethod0 _Nonnull onUpdate; + UniffiCallbackInterfaceTokenUpdateCallbackMethod1 _Nonnull onError; +} UniffiVTableCallbackInterfaceTokenUpdateCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TRANSACTION_UPDATE_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTransactionUpdateCallback { + UniffiCallbackInterfaceFree _Nonnull uniffiFree; + UniffiCallbackInterfaceClone _Nonnull uniffiClone; + UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 _Nonnull onUpdate; + UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 _Nonnull onError; +} UniffiVTableCallbackInterfaceTransactionUpdateCallback; + +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CLONE_TORIICLIENT +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CLONE_TORIICLIENT +uint64_t uniffi_dojo_uniffi_fn_clone_toriiclient(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_FREE_TORIICLIENT +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_FREE_TORIICLIENT +void uniffi_dojo_uniffi_fn_free_toriiclient(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CONSTRUCTOR_TORIICLIENT_NEW +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CONSTRUCTOR_TORIICLIENT_NEW +uint64_t uniffi_dojo_uniffi_fn_constructor_toriiclient_new(RustBuffer torii_url, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CONSTRUCTOR_TORIICLIENT_NEW_WITH_CONFIG +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_CONSTRUCTOR_TORIICLIENT_NEW_WITH_CONFIG +uint64_t uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config(RustBuffer torii_url, uint64_t max_message_size, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ACHIEVEMENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ACHIEVEMENTS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_achievements(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ACTIVITIES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ACTIVITIES +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_activities(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_AGGREGATIONS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_AGGREGATIONS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_aggregations(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CANCEL_SUBSCRIPTION +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CANCEL_SUBSCRIPTION +void uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription(uint64_t ptr, uint64_t subscription_id, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CONTRACTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CONTRACTS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_contracts(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CONTROLLERS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_CONTROLLERS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_controllers(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ENTITIES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_ENTITIES +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_entities(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_EVENT_MESSAGES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_EVENT_MESSAGES +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_event_messages(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PLAYER_ACHIEVEMENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PLAYER_ACHIEVEMENTS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PUBLISH_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PUBLISH_MESSAGE +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_publish_message(uint64_t ptr, RustBuffer message, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PUBLISH_MESSAGE_BATCH +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_PUBLISH_MESSAGE_BATCH +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch(uint64_t ptr, RustBuffer messages, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SQL +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SQL +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_sql(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_STARKNET_EVENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_STARKNET_EVENTS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_ENTITY_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_ENTITY_UPDATES +uint64_t uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates(uint64_t ptr, RustBuffer clause, RustBuffer world_addresses, uint64_t callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_EVENT_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_EVENT_UPDATES +uint64_t uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates(uint64_t ptr, RustBuffer keys, uint64_t callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_BALANCE_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_BALANCE_UPDATES +uint64_t uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates(uint64_t ptr, RustBuffer contract_addresses, RustBuffer account_addresses, RustBuffer token_ids, uint64_t callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_UPDATES +uint64_t uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates(uint64_t ptr, RustBuffer contract_addresses, RustBuffer token_ids, uint64_t callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TRANSACTION_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SUBSCRIBE_TRANSACTION_UPDATES +uint64_t uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates(uint64_t ptr, RustBuffer filter, uint64_t callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_BALANCES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_BALANCES +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_token_balances(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_CONTRACTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_CONTRACTS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_TRANSFERS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKEN_TRANSFERS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKENS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TOKENS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_tokens(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TRANSACTIONS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_TRANSACTIONS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_transactions(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_WORLDS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_WORLDS +RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_worlds(uint64_t ptr, RustBuffer world_addresses, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_ENTITYUPDATECALLBACK +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_ENTITYUPDATECALLBACK +void uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(const UniffiVTableCallbackInterfaceEntityUpdateCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_EVENTUPDATECALLBACK +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_EVENTUPDATECALLBACK +void uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(const UniffiVTableCallbackInterfaceEventUpdateCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TOKENBALANCEUPDATECALLBACK +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TOKENBALANCEUPDATECALLBACK +void uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(const UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TOKENUPDATECALLBACK +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TOKENUPDATECALLBACK +void uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(const UniffiVTableCallbackInterfaceTokenUpdateCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TRANSACTIONUPDATECALLBACK +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_INIT_CALLBACK_VTABLE_TRANSACTIONUPDATECALLBACK +void uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(const UniffiVTableCallbackInterfaceTransactionUpdateCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_ALLOC +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_ALLOC +RustBuffer ffi_dojo_uniffi_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_FROM_BYTES +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_FROM_BYTES +RustBuffer ffi_dojo_uniffi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_FREE +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_FREE +void ffi_dojo_uniffi_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_RESERVE +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUSTBUFFER_RESERVE +RustBuffer ffi_dojo_uniffi_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U8 +void ffi_dojo_uniffi_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U8 +void ffi_dojo_uniffi_rust_future_cancel_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U8 +void ffi_dojo_uniffi_rust_future_free_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U8 +uint8_t ffi_dojo_uniffi_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I8 +void ffi_dojo_uniffi_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I8 +void ffi_dojo_uniffi_rust_future_cancel_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I8 +void ffi_dojo_uniffi_rust_future_free_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I8 +int8_t ffi_dojo_uniffi_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U16 +void ffi_dojo_uniffi_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U16 +void ffi_dojo_uniffi_rust_future_cancel_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U16 +void ffi_dojo_uniffi_rust_future_free_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U16 +uint16_t ffi_dojo_uniffi_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I16 +void ffi_dojo_uniffi_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I16 +void ffi_dojo_uniffi_rust_future_cancel_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I16 +void ffi_dojo_uniffi_rust_future_free_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I16 +int16_t ffi_dojo_uniffi_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U32 +void ffi_dojo_uniffi_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U32 +void ffi_dojo_uniffi_rust_future_cancel_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U32 +void ffi_dojo_uniffi_rust_future_free_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U32 +uint32_t ffi_dojo_uniffi_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I32 +void ffi_dojo_uniffi_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I32 +void ffi_dojo_uniffi_rust_future_cancel_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I32 +void ffi_dojo_uniffi_rust_future_free_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I32 +int32_t ffi_dojo_uniffi_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_U64 +void ffi_dojo_uniffi_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_U64 +void ffi_dojo_uniffi_rust_future_cancel_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_U64 +void ffi_dojo_uniffi_rust_future_free_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_U64 +uint64_t ffi_dojo_uniffi_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_I64 +void ffi_dojo_uniffi_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_I64 +void ffi_dojo_uniffi_rust_future_cancel_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_I64 +void ffi_dojo_uniffi_rust_future_free_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_I64 +int64_t ffi_dojo_uniffi_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_F32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_F32 +void ffi_dojo_uniffi_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_F32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_F32 +void ffi_dojo_uniffi_rust_future_cancel_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_F32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_F32 +void ffi_dojo_uniffi_rust_future_free_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_F32 +float ffi_dojo_uniffi_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_F64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_F64 +void ffi_dojo_uniffi_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_F64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_F64 +void ffi_dojo_uniffi_rust_future_cancel_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_F64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_F64 +void ffi_dojo_uniffi_rust_future_free_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_F64 +double ffi_dojo_uniffi_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_RUST_BUFFER +void ffi_dojo_uniffi_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_RUST_BUFFER +void ffi_dojo_uniffi_rust_future_cancel_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_RUST_BUFFER +void ffi_dojo_uniffi_rust_future_free_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_RUST_BUFFER +RustBuffer ffi_dojo_uniffi_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_VOID +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_POLL_VOID +void ffi_dojo_uniffi_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_VOID +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_CANCEL_VOID +void ffi_dojo_uniffi_rust_future_cancel_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_VOID +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_FREE_VOID +void ffi_dojo_uniffi_rust_future_free_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_RUST_FUTURE_COMPLETE_VOID +void ffi_dojo_uniffi_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ACHIEVEMENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ACHIEVEMENTS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_achievements(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ACTIVITIES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ACTIVITIES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_activities(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_AGGREGATIONS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_AGGREGATIONS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CANCEL_SUBSCRIPTION +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CANCEL_SUBSCRIPTION +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CONTRACTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CONTRACTS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_contracts(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CONTROLLERS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_CONTROLLERS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_controllers(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ENTITIES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_ENTITIES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_entities(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_EVENT_MESSAGES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_EVENT_MESSAGES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PLAYER_ACHIEVEMENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PLAYER_ACHIEVEMENTS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PUBLISH_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PUBLISH_MESSAGE +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PUBLISH_MESSAGE_BATCH +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PUBLISH_MESSAGE_BATCH +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SQL +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SQL +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_sql(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_STARKNET_EVENTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_STARKNET_EVENTS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_ENTITY_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_ENTITY_UPDATES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_EVENT_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_EVENT_UPDATES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_BALANCE_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_BALANCE_UPDATES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TOKEN_UPDATES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TRANSACTION_UPDATES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SUBSCRIBE_TRANSACTION_UPDATES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_BALANCES +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_BALANCES +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_CONTRACTS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_CONTRACTS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_TRANSFERS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKEN_TRANSFERS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKENS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TOKENS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_tokens(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TRANSACTIONS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_TRANSACTIONS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_transactions(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_WORLDS +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_WORLDS +uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_worlds(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_CONSTRUCTOR_TORIICLIENT_NEW +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_CONSTRUCTOR_TORIICLIENT_NEW +uint16_t uniffi_dojo_uniffi_checksum_constructor_toriiclient_new(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_CONSTRUCTOR_TORIICLIENT_NEW_WITH_CONFIG +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_CONSTRUCTOR_TORIICLIENT_NEW_WITH_CONFIG +uint16_t uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_ENTITYUPDATECALLBACK_ON_UPDATE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_ENTITYUPDATECALLBACK_ON_UPDATE +uint16_t uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_ENTITYUPDATECALLBACK_ON_ERROR +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_ENTITYUPDATECALLBACK_ON_ERROR +uint16_t uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_EVENTUPDATECALLBACK_ON_UPDATE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_EVENTUPDATECALLBACK_ON_UPDATE +uint16_t uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_EVENTUPDATECALLBACK_ON_ERROR +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_EVENTUPDATECALLBACK_ON_ERROR +uint16_t uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENBALANCEUPDATECALLBACK_ON_UPDATE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENBALANCEUPDATECALLBACK_ON_UPDATE +uint16_t uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENBALANCEUPDATECALLBACK_ON_ERROR +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENBALANCEUPDATECALLBACK_ON_ERROR +uint16_t uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENUPDATECALLBACK_ON_UPDATE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENUPDATECALLBACK_ON_UPDATE +uint16_t uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENUPDATECALLBACK_ON_ERROR +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TOKENUPDATECALLBACK_ON_ERROR +uint16_t uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TRANSACTIONUPDATECALLBACK_ON_UPDATE +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TRANSACTIONUPDATECALLBACK_ON_UPDATE +uint16_t uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TRANSACTIONUPDATECALLBACK_ON_ERROR +#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TRANSACTIONUPDATECALLBACK_ON_ERROR +uint16_t uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error(void + +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_UNIFFI_CONTRACT_VERSION +#define UNIFFI_FFIDEF_FFI_DOJO_UNIFFI_UNIFFI_CONTRACT_VERSION +uint32_t ffi_dojo_uniffi_uniffi_contract_version(void + +); +#endif + diff --git a/bindings/swift/dojo_uniffi.modulemap b/bindings/swift/dojo_uniffi.modulemap new file mode 100644 index 0000000..9293ecb --- /dev/null +++ b/bindings/swift/dojo_uniffi.modulemap @@ -0,0 +1,7 @@ +module DojoEngine { + header "DojoEngineFFI.h" + export * + use "Darwin" + use "_Builtin_stdbool" + use "_Builtin_stdint" +} \ No newline at end of file diff --git a/crates/c/Cargo.toml b/crates/c/Cargo.toml index 5fa1090..8dac175 100644 --- a/crates/c/Cargo.toml +++ b/crates/c/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "c" +name = "dojo-c" version.workspace = true edition.workspace = true diff --git a/crates/c/dojo.h b/crates/c/dojo.h index f8871bf..ecb85d3 100644 --- a/crates/c/dojo.h +++ b/crates/c/dojo.h @@ -1639,8 +1639,8 @@ struct ResultPageAchievement client_achievements(struct ToriiClient *client, * * # Parameters * * `client` - Pointer to ToriiClient instance - * * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, and - * pagination + * * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, + * and pagination * * # Returns * Result containing Page of PlayerAchievementEntry or error diff --git a/crates/c/dojo.hpp b/crates/c/dojo.hpp index c06810f..dbfb5f2 100644 --- a/crates/c/dojo.hpp +++ b/crates/c/dojo.hpp @@ -1376,8 +1376,8 @@ Result> client_achievements(ToriiClient *client, AchievementQu /// /// # Parameters /// * `client` - Pointer to ToriiClient instance -/// * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, and -/// pagination +/// * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, +/// and pagination /// /// # Returns /// Result containing Page of PlayerAchievementEntry or error diff --git a/crates/c/dojo.pyx b/crates/c/dojo.pyx index 9c0dcd2..f912c48 100644 --- a/crates/c/dojo.pyx +++ b/crates/c/dojo.pyx @@ -1150,8 +1150,8 @@ cdef extern from *: # # # Parameters # * `client` - Pointer to ToriiClient instance - # * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, and - # pagination + # * `query` - PlayerAchievementQuery containing world_addresses, namespaces, player_addresses, + # and pagination # # # Returns # Result containing Page of PlayerAchievementEntry or error diff --git a/crates/dojo-core/Cargo.toml b/crates/dojo-core/Cargo.toml index 128ce0d..d83c020 100644 --- a/crates/dojo-core/Cargo.toml +++ b/crates/dojo-core/Cargo.toml @@ -7,7 +7,6 @@ edition.workspace = true starknet.workspace = true starknet-crypto.workspace = true anyhow.workspace = true -tokio.workspace = true url.workspace = true stream-cancel.workspace = true @@ -16,6 +15,13 @@ dojo-types.workspace = true torii-client.workspace = true torii-proto.workspace = true +# Platform-specific tokio configuration +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tokio.workspace = true + +[target.'cfg(target_arch = "wasm32")'.dependencies] +tokio = { version = "1.39.2", default-features = false } + [lib] crate-type = ["rlib"] diff --git a/crates/uniffi/Cargo.toml b/crates/uniffi/Cargo.toml new file mode 100644 index 0000000..293ebb4 --- /dev/null +++ b/crates/uniffi/Cargo.toml @@ -0,0 +1,79 @@ +[package] +name = "dojo-uniffi" +version.workspace = true +edition.workspace = true + +[lib] +crate-type = ["cdylib", "lib"] + +[dependencies] +dojo-core = { workspace = true } + +dojo-world.workspace = true +dojo-types.workspace = true +torii-proto.workspace = true +torii-client.workspace = true +torii-grpc-client.workspace = true + +starknet.workspace = true +starknet-crypto.workspace = true + +tokio.workspace = true +url.workspace = true +anyhow.workspace = true +serde.workspace = true +serde_json.workspace = true +tokio-stream.workspace = true +futures.workspace = true +futures-util.workspace = true +stream-cancel.workspace = true +cainome.workspace = true +lazy_static.workspace = true +crypto-bigint.workspace = true +chrono.workspace = true +num-bigint.workspace = true +num-traits.workspace = true + +# UniFFI +uniffi = { version = "0.30", features = ["bindgen", "cli"] } +uniffi_bindgen = "0.30" +camino = "1.1" +thiserror = "2" +hex = "0.4" +cargo_metadata = "0.19" + +# Platform-specific dependencies +axum = "0.8.1" +open = "5.3.2" +urlencoding = "2.1.3" +keyring = { version = "3.6.1", features = [ + "apple-native", + "windows-native", + "sync-secret-service", +] } +directories = "6.0.0" +tower-http = { version = "0.6.2", features = ["cors"] } +base64 = "0.22.1" + +[build-dependencies] +uniffi = { version = "0.30", features = ["build"] } + +[dev-dependencies] +uniffi = { version = "0.30", features = ["bindgen-tests"] } + +# UniFFI bindgen binaries +[[bin]] +name = "uniffi-bindgen-swift" +path = "src/bin/uniffi-bindgen-swift.rs" + +[[bin]] +name = "uniffi-bindgen-kotlin" +path = "src/bin/uniffi-bindgen-kotlin.rs" + +[[bin]] +name = "uniffi-bindgen-python" +path = "src/bin/uniffi-bindgen-python.rs" + +[features] +default = [] + diff --git a/crates/uniffi/build.rs b/crates/uniffi/build.rs new file mode 100644 index 0000000..c1102c6 --- /dev/null +++ b/crates/uniffi/build.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::generate_scaffolding("src/dojo.udl").expect("Failed to generate UniFFI scaffolding"); +} diff --git a/crates/uniffi/src/bin/uniffi-bindgen-kotlin.rs b/crates/uniffi/src/bin/uniffi-bindgen-kotlin.rs new file mode 100644 index 0000000..f1da634 --- /dev/null +++ b/crates/uniffi/src/bin/uniffi-bindgen-kotlin.rs @@ -0,0 +1,114 @@ +use std::{env, fs, process}; + +use camino::Utf8PathBuf; +use uniffi_bindgen::{BindgenLoader, BindingGenerator}; + +fn main() { + let args: Vec = env::args().collect(); + + // Show help if requested + if args.len() > 1 && (args[1] == "--help" || args[1] == "-h") { + eprintln!("UniFFI Kotlin Binding Generator"); + eprintln!(); + eprintln!("Usage: {} [library_path] [output_dir]", args[0]); + eprintln!(); + eprintln!("Arguments:"); + eprintln!( + " library_path Path to the compiled library (default: \ + target/release/libdojo_uniffi.dylib)" + ); + eprintln!( + " output_dir Output directory for bindings (default: bindings/kotlin)" + ); + eprintln!(); + eprintln!("Examples:"); + eprintln!(" {} # Use defaults", args[0]); + eprintln!(" {} target/release/libdojo_uniffi.dylib bindings/kotlin", args[0]); + eprintln!(); + process::exit(0); + } + + // Determine library extension based on platform + let lib_ext = if cfg!(target_os = "macos") { + "dylib" + } else if cfg!(target_os = "windows") { + "dll" + } else { + "so" + }; + + // Default paths (must match the library output name) + let default_lib = format!("target/release/libdojo_uniffi.{}", lib_ext); + let default_out = "bindings/kotlin"; + + // Parse arguments + let positional_args: Vec<&String> = + args.iter().skip(1).filter(|arg| !arg.starts_with("--")).collect(); + + let library_path = + Utf8PathBuf::from(positional_args.first().map(|s| s.as_str()).unwrap_or(&default_lib)); + let out_dir = + Utf8PathBuf::from(positional_args.get(1).map(|s| s.as_str()).unwrap_or(default_out)); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release -p dojo-uniffi"); + eprintln!(); + eprintln!("Hint: Run with --help to see usage information"); + process::exit(1); + } + + // Create output directory if it doesn't exist + if let Err(e) = fs::create_dir_all(&out_dir) { + eprintln!("Error: Failed to create output directory {}: {}", out_dir, e); + process::exit(1); + } + + println!("Generating Kotlin bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + match generate_kotlin_bindings(&library_path, &out_dir) { + Ok(_) => { + println!("✓ Kotlin bindings generated successfully!"); + } + Err(e) => { + eprintln!("Error generating bindings: {}", e); + process::exit(1); + } + } +} + +fn generate_kotlin_bindings( + library_path: &Utf8PathBuf, + out_dir: &Utf8PathBuf, +) -> anyhow::Result<()> { + use uniffi_bindgen::bindings::KotlinBindingGenerator; + use uniffi_bindgen::cargo_metadata::CrateConfigSupplier; + + // Get cargo metadata for config + let metadata = cargo_metadata::MetadataCommand::new() + .exec() + .map_err(|e| anyhow::anyhow!("Failed to get cargo metadata: {}", e))?; + + let config_supplier = CrateConfigSupplier::from(metadata); + + // Load the library metadata and components + let loader = BindgenLoader::new(&config_supplier); + let metadata = loader.load_metadata(library_path)?; + let cis = loader.load_cis(metadata)?; + + // Parse config with Kotlin binding generator + let generator = KotlinBindingGenerator; + let components = + loader.load_components(cis, |_ci, root_toml| generator.new_config(&root_toml))?; + + // Generate bindings using the Kotlin generator + use uniffi_bindgen::GenerationSettings; + let settings = + GenerationSettings { out_dir: out_dir.clone(), try_format_code: false, cdylib: None }; + + generator.write_bindings(&settings, &components)?; + + Ok(()) +} diff --git a/crates/uniffi/src/bin/uniffi-bindgen-python.rs b/crates/uniffi/src/bin/uniffi-bindgen-python.rs new file mode 100644 index 0000000..4c1ef38 --- /dev/null +++ b/crates/uniffi/src/bin/uniffi-bindgen-python.rs @@ -0,0 +1,106 @@ +use std::{env, process}; + +use camino::Utf8PathBuf; +use uniffi_bindgen::bindings::python::run_pipeline; +use uniffi_bindgen::cargo_metadata::CrateConfigSupplier; +use uniffi_bindgen::pipeline::initial::Root; + +fn main() { + let args: Vec = env::args().collect(); + + // Show help if requested + if args.len() > 1 && (args[1] == "--help" || args[1] == "-h") { + eprintln!("UniFFI Python Binding Generator"); + eprintln!(); + eprintln!("Usage: {} [library_path] [output_dir]", args[0]); + eprintln!(); + eprintln!("Arguments:"); + eprintln!( + " library_path Path to the compiled library (default: \ + target/release/libdojo_uniffi.dylib)" + ); + eprintln!( + " output_dir Output directory for bindings (default: bindings/python)" + ); + eprintln!(); + eprintln!("Examples:"); + eprintln!(" {} # Use defaults", args[0]); + eprintln!(" {} target/release/libdojo_uniffi.dylib bindings/python", args[0]); + eprintln!(); + process::exit(0); + } + + // Determine library extension based on platform + let lib_ext = if cfg!(target_os = "macos") { + "dylib" + } else if cfg!(target_os = "windows") { + "dll" + } else { + "so" + }; + + // Default paths (must match the library output name) + let default_lib = format!("target/release/libdojo_uniffi.{}", lib_ext); + let default_out = "bindings/python"; + + // Parse arguments + let positional_args: Vec<&String> = + args.iter().skip(1).filter(|arg| !arg.starts_with("--")).collect(); + + let library_path = + Utf8PathBuf::from(positional_args.first().map(|s| s.as_str()).unwrap_or(&default_lib)); + let out_dir = + Utf8PathBuf::from(positional_args.get(1).map(|s| s.as_str()).unwrap_or(default_out)); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release -p dojo-uniffi"); + eprintln!(); + eprintln!("Hint: Run with --help to see usage information"); + process::exit(1); + } + + // Create output directory if it doesn't exist + if let Err(e) = std::fs::create_dir_all(&out_dir) { + eprintln!("Error: Failed to create output directory {}: {}", out_dir, e); + process::exit(1); + } + + println!("Generating Python bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + // Find uniffi.toml config file + let config_file = Utf8PathBuf::from("crates/uniffi/uniffi.toml"); + if !config_file.exists() { + eprintln!("Warning: uniffi.toml not found at {}", config_file); + } + + // Use cargo metadata to get crate configuration + let metadata = match cargo_metadata::MetadataCommand::new().exec() { + Ok(m) => m, + Err(e) => { + eprintln!("Error getting cargo metadata: {}", e); + eprintln!("Make sure you're running this from a cargo project directory"); + process::exit(1); + } + }; + + let config_supplier = CrateConfigSupplier::from(metadata); + + match Root::from_library(config_supplier, &library_path, Some(config_file.to_string())) { + Ok(root) => match run_pipeline(root, &out_dir) { + Ok(_) => { + println!("✓ Python bindings generated successfully in {}", out_dir); + } + Err(e) => { + eprintln!("Error generating Python bindings: {}", e); + process::exit(1); + } + }, + Err(e) => { + eprintln!("Error loading library metadata: {}", e); + process::exit(1); + } + } +} diff --git a/crates/uniffi/src/bin/uniffi-bindgen-swift.rs b/crates/uniffi/src/bin/uniffi-bindgen-swift.rs new file mode 100644 index 0000000..ae70dea --- /dev/null +++ b/crates/uniffi/src/bin/uniffi-bindgen-swift.rs @@ -0,0 +1,116 @@ +use std::{env, process}; + +use camino::Utf8PathBuf; +use uniffi_bindgen::bindings::{generate_swift_bindings, SwiftBindingsOptions}; + +fn main() { + let args: Vec = env::args().collect(); + + // Show help if requested + if args.len() > 1 && (args[1] == "--help" || args[1] == "-h") { + eprintln!("UniFFI Swift Binding Generator"); + eprintln!(); + eprintln!("Usage: {} [library_path] [output_dir] [OPTIONS]", args[0]); + eprintln!(); + eprintln!("Arguments:"); + eprintln!( + " library_path Path to the compiled library (default: \ + target/release/libdojo_uniffi.dylib)" + ); + eprintln!( + " output_dir Output directory for bindings (default: bindings/swift)" + ); + eprintln!(); + eprintln!("Options:"); + eprintln!(" --swift-sources Generate .swift source files (default)"); + eprintln!(" --headers Generate .h header files"); + eprintln!(" --modulemap Generate modulemap"); + eprintln!(" --xcframework Generate XCFramework-compatible modulemap"); + eprintln!(); + eprintln!("Examples:"); + eprintln!(" {} # Use defaults", args[0]); + eprintln!(" {} target/release/libdojo_uniffi.dylib bindings/swift", args[0]); + eprintln!( + " {} target/release/libdojo_uniffi.dylib bindings/swift --swift-sources", + args[0] + ); + eprintln!( + " {} target/release/libdojo_uniffi.dylib bindings/swift --headers --modulemap", + args[0] + ); + eprintln!(); + process::exit(0); + } + + // Determine library extension based on platform + let lib_ext = if cfg!(target_os = "macos") { + "dylib" + } else if cfg!(target_os = "windows") { + "dll" + } else { + "so" + }; + + // Default paths (must match the library output name) + let default_lib = format!("target/release/libdojo_uniffi.{}", lib_ext); + let default_out = "bindings/swift"; + + // Parse arguments + let positional_args: Vec<&String> = + args.iter().skip(1).filter(|arg| !arg.starts_with("--")).collect(); + + let library_path = + Utf8PathBuf::from(positional_args.first().map(|s| s.as_str()).unwrap_or(&default_lib)); + let out_dir = + Utf8PathBuf::from(positional_args.get(1).map(|s| s.as_str()).unwrap_or(default_out)); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release -p dojo-uniffi"); + eprintln!(); + eprintln!("Hint: Run with --help to see usage information"); + process::exit(1); + } + + // Create output directory if it doesn't exist + if let Err(e) = std::fs::create_dir_all(&out_dir) { + eprintln!("Error: Failed to create output directory {}: {}", out_dir, e); + process::exit(1); + } + + // Parse options + let has_swift_sources = args.contains(&"--swift-sources".to_string()); + let has_headers = args.contains(&"--headers".to_string()); + let has_modulemap = args.contains(&"--modulemap".to_string()); + let has_xcframework = args.contains(&"--xcframework".to_string()); + + // Default to generating Swift sources if no specific flags are provided + let generate_swift_sources = has_swift_sources || (!has_headers && !has_modulemap); + + println!("Generating Swift bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + let options = SwiftBindingsOptions { + generate_swift_sources, + generate_headers: has_headers, + generate_modulemap: has_modulemap, + source: library_path, + out_dir, + xcframework: has_xcframework, + module_name: Some("DojoEngine".to_string()), + modulemap_filename: None, + metadata_no_deps: false, + link_frameworks: vec![], + }; + + match generate_swift_bindings(options) { + Ok(_) => { + println!("✓ Swift bindings generated successfully!"); + } + Err(e) => { + eprintln!("Error generating bindings: {}", e); + process::exit(1); + } + } +} diff --git a/crates/uniffi/src/dojo.udl b/crates/uniffi/src/dojo.udl new file mode 100644 index 0000000..3d6a654 --- /dev/null +++ b/crates/uniffi/src/dojo.udl @@ -0,0 +1,746 @@ +// Simplified UDL - just the types that work easily with UniFFI +// Complex recursive types (Primitive, Ty, Clause, etc.) should be handled +// via procmacros in Rust rather than UDL + +namespace dojo { +}; + +// Core types +[Custom] +typedef string FieldElement; + +[Custom] +typedef string U256; + +// Enums +enum PaginationDirection { + "Forward", + "Backward", +}; + +enum OrderDirection { + "Asc", + "Desc", +}; + +enum ContractType { + "WORLD", + "ERC20", + "ERC721", + "ERC1155", + "UDC", + "OTHER", +}; + +enum CallType { + "Execute", + "ExecuteFromOutside", +}; + +enum PatternMatching { + "FixedLen", + "VariableLen", +}; + +enum LogicalOperator { + "And", + "Or", +}; + +enum ComparisonOperator { + "Eq", + "Neq", + "Gt", + "Gte", + "Lt", + "Lte", + "In", + "NotIn", + "Contains", + "ContainsAll", + "ContainsAny", + "ArrayLengthEq", + "ArrayLengthGt", + "ArrayLengthLt", +}; + +// Basic structures +dictionary Signature { + FieldElement r; + FieldElement s; +}; + +dictionary OrderBy { + string field; + OrderDirection direction; +}; + +dictionary Pagination { + string? cursor; + u32? limit; + PaginationDirection direction; + sequence order_by; +}; + +// Controller +dictionary Controller { + FieldElement address; + string username; + u64 deployed_at_timestamp; +}; + +dictionary ControllerQuery { + Pagination pagination; + sequence contract_addresses; + sequence usernames; +}; + +// Token types +dictionary Token { + FieldElement contract_address; + U256? token_id; + string name; + string symbol; + u8 decimals; + string metadata; + U256? total_supply; +}; + +dictionary TokenBalance { + U256 balance; + FieldElement account_address; + FieldElement contract_address; + U256? token_id; +}; + +dictionary TokenContract { + FieldElement contract_address; + string name; + string symbol; + u8 decimals; + string metadata; + string token_metadata; + U256? total_supply; +}; + +dictionary AttributeFilter { + string trait_name; + string trait_value; +}; + +dictionary TokenQuery { + sequence contract_addresses; + sequence token_ids; + sequence attribute_filters; + Pagination pagination; +}; + +dictionary TokenBalanceQuery { + sequence contract_addresses; + sequence account_addresses; + sequence token_ids; + Pagination pagination; +}; + +dictionary TokenContractQuery { + sequence contract_addresses; + sequence contract_types; + Pagination pagination; +}; + +dictionary TokenTransfer { + string id; + FieldElement contract_address; + FieldElement from_address; + FieldElement to_address; + U256 amount; + U256? token_id; + u64 executed_at; + string? event_id; +}; + +dictionary TokenTransferQuery { + sequence contract_addresses; + sequence account_addresses; + sequence token_ids; + Pagination pagination; +}; + +// Contract +dictionary Contract { + FieldElement contract_address; + ContractType contract_type; + u64? head; + u64? tps; + u64? last_block_timestamp; + FieldElement? last_pending_block_tx; + u64 updated_at; + u64 created_at; +}; + +dictionary ContractQuery { + sequence contract_addresses; + sequence contract_types; +}; + +// Transaction types +dictionary TransactionCall { + FieldElement contract_address; + string entrypoint; + sequence calldata; + CallType call_type; + FieldElement caller_address; +}; + +dictionary Transaction { + FieldElement transaction_hash; + FieldElement sender_address; + sequence calldata; + FieldElement max_fee; + sequence signature; + FieldElement nonce; + u64 block_number; + string transaction_type; + u64 block_timestamp; + sequence calls; + sequence unique_models; +}; + +dictionary TransactionFilter { + sequence transaction_hashes; + sequence caller_addresses; + sequence contract_addresses; + sequence entrypoints; + sequence model_selectors; + u64? from_block; + u64? to_block; +}; + +dictionary TransactionQuery { + TransactionFilter? filter; + Pagination pagination; +}; + +// Aggregation +dictionary AggregationQuery { + sequence aggregator_ids; + sequence entity_ids; + Pagination pagination; +}; + +dictionary AggregationEntry { + string id; + string aggregator_id; + string entity_id; + U256 value; + string display_value; + u64 position; + string model_id; + u64 created_at; + u64 updated_at; +}; + +// Activity +dictionary ActionCount { + string action_name; + u32 count; +}; + +dictionary Activity { + string id; + FieldElement world_address; + string namespace; + FieldElement caller_address; + u64 session_start; + u64 session_end; + u32 action_count; + sequence actions; + u64 updated_at; +}; + +dictionary ActivityQuery { + sequence world_addresses; + sequence namespaces; + sequence caller_addresses; + u64? from_time; + u64? to_time; + Pagination pagination; +}; + +// Achievement +dictionary AchievementTask { + string task_id; + string description; + u32 total; + u32 total_completions; + f64 completion_rate; + u64 created_at; +}; + +dictionary Achievement { + string id; + FieldElement world_address; + string namespace; + string entity_id; + boolean hidden; + u32 index; + u32 points; + string start; + string end; + string group; + string icon; + string title; + string description; + sequence tasks; + string? data; + u32 total_completions; + f64 completion_rate; + u64 created_at; + u64 updated_at; +}; + +dictionary AchievementQuery { + sequence world_addresses; + sequence namespaces; + boolean? hidden; + Pagination pagination; +}; + +dictionary TaskProgress { + string task_id; + u32 count; + boolean completed; +}; + +dictionary PlayerAchievementProgress { + Achievement achievement; + sequence task_progress; + boolean completed; + f64 progress_percentage; +}; + +dictionary PlayerAchievementStats { + u32 total_points; + u32 completed_achievements; + u32 total_achievements; + f64 completion_percentage; + u64? last_achievement_at; + u64 created_at; + u64 updated_at; +}; + +dictionary PlayerAchievementEntry { + FieldElement player_address; + PlayerAchievementStats stats; + sequence achievements; +}; + +dictionary PlayerAchievementQuery { + sequence world_addresses; + sequence namespaces; + sequence player_addresses; + Pagination pagination; +}; + +// General entity query +dictionary Query { + sequence world_addresses; + Pagination pagination; + Clause? clause; + boolean no_hashed_keys; + sequence models; + boolean historical; +}; + +// Event query +dictionary EventQuery { + KeysClause? keys; + Pagination pagination; +}; + +// SQL query result types +dictionary SqlField { + string name; + SqlValue value; +}; + +dictionary SqlRow { + sequence fields; +}; + +[Enum] +interface SqlValue { + Text(string value); + Integer(i64 value); + Real(f64 value); + Blob(sequence value); + Null(); +}; + +dictionary AchievementProgression { + string id; + string achievement_id; + string task_id; + FieldElement world_address; + string namespace; + FieldElement player_id; + u32 count; + boolean completed; + u64? completed_at; + u64 created_at; + u64 updated_at; +}; + +// Schema types - Complex enums with associated data + +[Enum] +interface Primitive { + I8(i8 value); + I16(i16 value); + I32(i32 value); + I64(i64 value); + I128(sequence value); + U8(u8 value); + U16(u16 value); + U32(u32 value); + U64(u64 value); + U128(sequence value); + U256(U256 value); + Bool(boolean value); + Felt252(FieldElement value); + ClassHash(FieldElement value); + ContractAddress(FieldElement value); + EthAddress(FieldElement value); +}; + +[Enum] +interface MemberValue { + Primitive(Primitive value); + String(string value); + List(sequence values); +}; + +dictionary Member { + string name; + Ty ty; + boolean key; +}; + +dictionary Struct { + string name; + sequence children; +}; + +dictionary EnumOption { + string name; + Ty ty; +}; + +dictionary EnumType { + string name; + u8 option; + sequence options; +}; + +dictionary FixedSizeArray { + sequence array; + u32 size; +}; + +[Enum] +interface Ty { + Primitive(Primitive value); + Struct(Struct value); + Enum(EnumType value); + Tuple(sequence values); + Array(sequence values); + FixedSizeArray(FixedSizeArray value); + ByteArray(string value); +}; + +[Enum] +interface ValueType { + String(string value); + Int(i64 value); + UInt(u64 value); + Bool(boolean value); + Bytes(sequence value); +}; + +// Query types - Complex enums for query building + +dictionary KeysClause { + sequence keys; + PatternMatching pattern_matching; + sequence models; +}; + +dictionary MemberClause { + string model; + string member; + ComparisonOperator operator; + MemberValue value; +}; + +dictionary CompositeClause { + LogicalOperator operator; + sequence clauses; +}; + +[Enum] +interface Clause { + HashedKeys(sequence keys); + Keys(KeysClause clause); + Member(MemberClause clause); + Composite(CompositeClause clause); +}; + +// Event and Message types +dictionary Event { + sequence keys; + sequence data; + FieldElement transaction_hash; +}; + +dictionary Message { + string message; + sequence signature; + FieldElement world_address; +}; + +// Entity, Model, and World types +dictionary Entity { + FieldElement world_address; + FieldElement hashed_keys; + sequence models; + u64 created_at; + u64 updated_at; + u64 executed_at; +}; + +dictionary Model { + FieldElement world_address; + Ty schema; + string namespace; + string name; + FieldElement selector; + u32 packed_size; + u32 unpacked_size; + FieldElement class_hash; + FieldElement contract_address; + string layout; + boolean use_legacy_store; +}; + +dictionary World { + FieldElement world_address; + sequence models; +}; + +// Error type +[Error] +enum DojoError { + "ClientError", + "SerializationError", + "NetworkError", + "InvalidInput", + "ConnectionError", + "PublishError", + "QueryError", + "SubscriptionError", +}; + +// Callback interfaces for subscriptions +callback interface EntityUpdateCallback { + void on_update(Entity entity); + void on_error(string error); +}; + +callback interface TokenBalanceUpdateCallback { + void on_update(TokenBalance balance); + void on_error(string error); +}; + +callback interface TokenUpdateCallback { + void on_update(Token token); + void on_error(string error); +}; + +callback interface TransactionUpdateCallback { + void on_update(Transaction transaction); + void on_error(string error); +}; + +callback interface EventUpdateCallback { + void on_update(Event event); + void on_error(string error); +}; + +// Pagination wrapper types for different result types +dictionary PageController { + sequence items; + string? next_cursor; +}; + +dictionary PageToken { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenBalance { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenContract { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenTransfer { + sequence items; + string? next_cursor; +}; + +dictionary PageTransaction { + sequence items; + string? next_cursor; +}; + +dictionary PageAggregationEntry { + sequence items; + string? next_cursor; +}; + +dictionary PageActivity { + sequence items; + string? next_cursor; +}; + +dictionary PageAchievement { + sequence items; + string? next_cursor; +}; + +dictionary PagePlayerAchievement { + sequence items; + string? next_cursor; +}; + +dictionary PageEntity { + sequence items; + string? next_cursor; +}; + +dictionary PageEvent { + sequence items; + string? next_cursor; +}; + +// Main Dojo client interface +interface ToriiClient { + // Constructor - create a new client with default config (4MB max message size) + [Throws=DojoError] + constructor(string torii_url); + + // Constructor - create a new client with custom max message size + [Throws=DojoError, Name=new_with_config] + constructor(string torii_url, u64 max_message_size); + + // Publish offchain message + [Throws=DojoError] + string publish_message(Message message); + + // Publish multiple offchain messages + [Throws=DojoError] + sequence publish_message_batch(sequence messages); + + // Get world metadata + [Throws=DojoError] + sequence worlds(sequence world_addresses); + + // Query controllers + [Throws=DojoError] + PageController controllers(ControllerQuery query); + + // Query contracts + [Throws=DojoError] + sequence contracts(ContractQuery query); + + // Query tokens + [Throws=DojoError] + PageToken tokens(TokenQuery query); + + // Query token balances + [Throws=DojoError] + PageTokenBalance token_balances(TokenBalanceQuery query); + + // Query token contracts + [Throws=DojoError] + PageTokenContract token_contracts(TokenContractQuery query); + + // Query token transfers + [Throws=DojoError] + PageTokenTransfer token_transfers(TokenTransferQuery query); + + // Query transactions + [Throws=DojoError] + PageTransaction transactions(TransactionQuery query); + + // Query aggregations (leaderboards, stats, rankings) + [Throws=DojoError] + PageAggregationEntry aggregations(AggregationQuery query); + + // Query activities (user session tracking) + [Throws=DojoError] + PageActivity activities(ActivityQuery query); + + // Query achievements + [Throws=DojoError] + PageAchievement achievements(AchievementQuery query); + + // Query player achievements + [Throws=DojoError] + PagePlayerAchievement player_achievements(PlayerAchievementQuery query); + + // Query entities + [Throws=DojoError] + PageEntity entities(Query query); + + // Query event messages + [Throws=DojoError] + PageEntity event_messages(Query query); + + // Query Starknet events + [Throws=DojoError] + PageEvent starknet_events(EventQuery query); + + // Execute SQL query + [Throws=DojoError] + sequence sql(string query); + + // Subscription methods + // Subscribe to entity updates + [Throws=DojoError] + u64 subscribe_entity_updates(Clause? clause, sequence world_addresses, EntityUpdateCallback callback); + + // Subscribe to token balance updates + [Throws=DojoError] + u64 subscribe_token_balance_updates(sequence contract_addresses, sequence account_addresses, sequence token_ids, TokenBalanceUpdateCallback callback); + + // Subscribe to token updates + [Throws=DojoError] + u64 subscribe_token_updates(sequence contract_addresses, sequence token_ids, TokenUpdateCallback callback); + + // Subscribe to transaction updates + [Throws=DojoError] + u64 subscribe_transaction_updates(TransactionFilter? filter, TransactionUpdateCallback callback); + + // Subscribe to starknet event updates + [Throws=DojoError] + u64 subscribe_event_updates(sequence keys, EventUpdateCallback callback); + + // Cancel a subscription + [Throws=DojoError] + void cancel_subscription(u64 subscription_id); +}; \ No newline at end of file diff --git a/crates/uniffi/src/lib.rs b/crates/uniffi/src/lib.rs new file mode 100644 index 0000000..fe3bc29 --- /dev/null +++ b/crates/uniffi/src/lib.rs @@ -0,0 +1,10 @@ +// UniFFI bindings for Dojo +// Multi-language bindings (Swift, Kotlin, Python) using UniFFI + +pub mod uniffi; + +// Re-export all UniFFI types at crate root for scaffolding +pub use uniffi::*; + +// Include the generated UniFFI scaffolding +::uniffi::include_scaffolding!("dojo"); diff --git a/crates/uniffi/src/uniffi/.gitignore b/crates/uniffi/src/uniffi/.gitignore new file mode 100644 index 0000000..a1277a6 --- /dev/null +++ b/crates/uniffi/src/uniffi/.gitignore @@ -0,0 +1 @@ +bindings/ diff --git a/crates/uniffi/src/uniffi/README.md b/crates/uniffi/src/uniffi/README.md new file mode 100644 index 0000000..5b17f1e --- /dev/null +++ b/crates/uniffi/src/uniffi/README.md @@ -0,0 +1,307 @@ +# UniFFI Types - Organized by Category + +This directory contains UniFFI-compatible Rust types for Dojo, organized by functional category for better maintainability and discoverability. + +## File Structure + +``` +src/uniffi/ +├── mod.rs # Module definitions and re-exports +├── core.rs # Core types and utilities +├── achievement.rs # Achievement system types +├── activity.rs # Activity tracking types +├── aggregation.rs # Data aggregation types +├── contract.rs # Smart contract types +├── controller.rs # Controller/account types +├── entity.rs # Entity, Model, and World types +├── event.rs # Event and Message types +├── query.rs # Query and filtering types +├── schema.rs # Schema definition types +├── token.rs # Token and NFT types +└── transaction.rs # Transaction types +``` + +## Module Organization + +### `core.rs` - Core Types and Utilities +The foundation module containing: +- **Type Definitions**: `FieldElement`, `U256` (as hex strings) +- **Error Handling**: `DojoError` enum +- **Pagination**: `Pagination`, `PaginationDirection`, `OrderBy`, `OrderDirection` +- **Common Types**: `Signature`, `Call`, `BlockId`, `BlockTag` +- **Helper Functions**: Conversion between internal types and strings + +**Key Types:** +- `FieldElement` - String representation of Starknet field elements +- `U256` - String representation of 256-bit unsigned integers +- `DojoError` - Comprehensive error handling +- `Pagination` - Cursor-based pagination support + +### `controller.rs` - Controller Types +Account and controller management: +- `Controller` - Account controller information +- `ControllerQuery` - Query for controllers + +**Use Cases:** +- Account management +- Username lookups +- Deployment tracking + +### `token.rs` - Token Types +ERC20, ERC721, and ERC1155 token support: +- `Token` - Token information +- `TokenBalance` - Token balance per account +- `TokenContract` - Token contract metadata +- `TokenTransfer` - Transfer event data +- `TokenQuery`, `TokenBalanceQuery`, `TokenContractQuery`, `TokenTransferQuery` +- `AttributeFilter` - NFT attribute filtering + +**Use Cases:** +- Token balance queries +- NFT metadata retrieval +- Transfer history +- Token searches with filters + +### `contract.rs` - Contract Types +Smart contract information and queries: +- `Contract` - Contract metadata +- `ContractType` - Enum for contract types (WORLD, ERC20, ERC721, etc.) +- `ContractQuery` - Query contracts by address or type + +**Use Cases:** +- Contract discovery +- Type-based filtering +- Deployment information + +### `transaction.rs` - Transaction Types +Transaction data and queries: +- `Transaction` - Full transaction information +- `TransactionCall` - Individual contract call +- `TransactionFilter` - Advanced transaction filtering +- `TransactionQuery` - Query transactions +- `CallType` - Execute vs ExecuteFromOutside + +**Use Cases:** +- Transaction history +- Call analysis +- Block explorer functionality + +### `schema.rs` - Schema Types +Type system and schema definitions: +- `Primitive` - Primitive type values (integers, felts, bools, etc.) +- `Ty` - Type definitions (Struct, Enum, Array, Tuple, etc.) +- `Struct` - Struct definition +- `Enum` - Enum definition +- `Member` - Struct/enum member +- `MemberValue` - Runtime value +- `ValueType` - Value type variants + +**Use Cases:** +- Schema introspection +- Dynamic typing +- Model definitions +- Data serialization + +### `query.rs` - Query Types +Powerful querying and filtering: +- `Query` - Main query structure +- `Clause` - Query clauses (HashedKeys, Keys, Member, Composite) +- `KeysClause` - Key-based filtering +- `MemberClause` - Member-based filtering +- `CompositeClause` - Logical composition (AND/OR) +- `PatternMatching` - Key pattern matching +- `ComparisonOperator` - Rich comparison operators +- `LogicalOperator` - AND/OR operators + +**Use Cases:** +- Entity queries +- Complex filtering +- Model data retrieval +- Historical queries + +### `entity.rs` - Entity Types +Core game entity types: +- `Entity` - Game entity with models +- `Model` - Model definition +- `World` - World state + +**Use Cases:** +- Entity management +- Model introspection +- World state queries + +### `event.rs` - Event Types +Blockchain event handling: +- `Event` - Starknet event +- `Message` - Signed message + +**Use Cases:** +- Event listening +- Message verification +- Event history + +### `aggregation.rs` - Aggregation Types +Data aggregation and leaderboards: +- `AggregationEntry` - Aggregated data entry +- `AggregationQuery` - Query aggregations + +**Use Cases:** +- Leaderboards +- Statistics +- Rankings + +### `activity.rs` - Activity Types +Player activity tracking: +- `Activity` - Player activity session +- `ActivityQuery` - Query player activity +- `ActionCount` - Action frequency + +**Use Cases:** +- Player analytics +- Session tracking +- Engagement metrics + +### `achievement.rs` - Achievement Types +Achievement and progression system: +- `Achievement` - Achievement definition +- `AchievementTask` - Individual task +- `PlayerAchievementProgress` - Player's progress +- `PlayerAchievementStats` - Player's achievement stats +- `AchievementProgression` - Detailed progression +- `TaskProgress` - Task completion status +- Corresponding query types + +**Use Cases:** +- Achievement systems +- Progression tracking +- Player rewards +- Gamification + +## Usage Examples + +### Querying Entities +```rust +use uniffi::{Query, Clause, MemberClause, ComparisonOperator, Primitive}; + +let query = Query { + world_addresses: vec!["0x123...".to_string()], + clause: Some(Clause::Member(MemberClause { + model: "Player".to_string(), + member: "level".to_string(), + operator: ComparisonOperator::Gte, + value: MemberValue::Primitive(Primitive::U32(10)), + })), + pagination: Default::default(), + no_hashed_keys: false, + models: vec!["Player".to_string()], + historical: false, +}; +``` + +### Token Balance Query +```rust +use uniffi::{TokenBalanceQuery, Pagination}; + +let query = TokenBalanceQuery { + contract_addresses: vec!["0xabc...".to_string()], + account_addresses: vec!["0xdef...".to_string()], + token_ids: vec![], + pagination: Pagination::default(), +}; +``` + +### Achievement Progress +```rust +use uniffi::{PlayerAchievementQuery, Pagination}; + +let query = PlayerAchievementQuery { + world_addresses: vec!["0x123...".to_string()], + namespaces: vec!["game".to_string()], + player_addresses: vec!["0xplayer...".to_string()], + pagination: Pagination::default(), +}; +``` + +## Design Principles + +### 1. **Category-Based Organization** +Types are grouped by their domain purpose rather than technical structure: +- Easy to find related types +- Clear separation of concerns +- Logical grouping for documentation + +### 2. **Minimal Dependencies** +Each module imports only what it needs: +- `core` has no internal dependencies +- Other modules depend on `core` +- Cross-references are minimal and explicit + +### 3. **Consistent Patterns** +All modules follow the same patterns: +- Types use `FieldElement` and `U256` as strings +- Conversions to/from proto types +- Clear documentation of purpose + +### 4. **Self-Documenting** +File names and organization make the purpose clear: +- `token.rs` - obviously token-related +- `achievement.rs` - clearly achievement system +- No need to read code to understand scope + +## Adding New Types + +When adding new types: + +1. **Determine Category**: Which module does it belong to? +2. **Create/Update Module**: Add to existing or create new category file +3. **Update mod.rs**: Add module declaration and re-exports +4. **Update UDL**: Add type definitions to `src/dojo.udl` +5. **Document**: Update this README + +Example - Adding a new "Quest" system: + +```rust +// src/uniffi/quest.rs +use super::core::*; + +#[derive(Debug, Clone)] +pub struct Quest { + pub id: String, + pub name: String, + // ... +} +``` + +Update `mod.rs`: +```rust +pub mod quest; +pub use quest::*; +``` + +## Benefits of This Organization + +### For Developers +- ✅ Quick discovery of related types +- ✅ Easy navigation +- ✅ Clear module boundaries +- ✅ Reduced cognitive load + +### For Maintenance +- ✅ Easy to add new categories +- ✅ Changes are localized +- ✅ Dependencies are explicit +- ✅ Better IDE support + +### For Documentation +- ✅ Self-organizing +- ✅ Category-based docs +- ✅ Clear examples per category +- ✅ Easy to generate docs + +## See Also + +- [UniFFI Documentation](https://mozilla.github.io/uniffi-rs/) +- [UNIFFI_CONVERSION.md](../../UNIFFI_CONVERSION.md) - Detailed conversion guide +- [CONVERSION_SUMMARY.md](../../CONVERSION_SUMMARY.md) - Complete type mapping +- [dojo.udl](../dojo.udl) - UniFFI interface definition + diff --git a/crates/uniffi/src/uniffi/client.rs b/crates/uniffi/src/uniffi/client.rs new file mode 100644 index 0000000..afd17ca --- /dev/null +++ b/crates/uniffi/src/uniffi/client.rs @@ -0,0 +1,537 @@ +// Client wrapper for UniFFI - exposes torii_client functionality + +use std::collections::HashMap; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Arc, Mutex, OnceLock}; + +use tokio::runtime::Runtime; +use tokio::task::JoinHandle; + +use super::types::*; + +// Static tokio runtime for all async operations +static RUNTIME: OnceLock = OnceLock::new(); + +fn runtime() -> &'static Runtime { + RUNTIME.get_or_init(|| Runtime::new().expect("Failed to create tokio runtime")) +} + +// Callback traits for subscriptions +pub trait EntityUpdateCallback: Send + Sync { + fn on_update(&self, entity: Entity); + fn on_error(&self, error: String); +} + +pub trait TokenBalanceUpdateCallback: Send + Sync { + fn on_update(&self, balance: TokenBalance); + fn on_error(&self, error: String); +} + +pub trait TokenUpdateCallback: Send + Sync { + fn on_update(&self, token: Token); + fn on_error(&self, error: String); +} + +pub trait TransactionUpdateCallback: Send + Sync { + fn on_update(&self, transaction: Transaction); + fn on_error(&self, error: String); +} + +pub trait EventUpdateCallback: Send + Sync { + fn on_update(&self, event: Event); + fn on_error(&self, error: String); +} + +/// Main Dojo client for interacting with the Torii indexer +pub struct ToriiClient { + inner: Arc, + subscriptions: Arc>>>, + next_sub_id: Arc, +} + +impl ToriiClient { + /// Create a new Torii client with default configuration (4MB max message size) + pub fn new(torii_url: String) -> Result { + let client = runtime() + .block_on(torii_client::Client::new(torii_url)) + .map_err(|_e| DojoError::ConnectionError)?; + + Ok(Self { + inner: Arc::new(client), + subscriptions: Arc::new(Mutex::new(HashMap::new())), + next_sub_id: Arc::new(AtomicU64::new(0)), + }) + } + + /// Create a new Torii client with custom max message size + pub fn new_with_config(torii_url: String, max_message_size: u64) -> Result { + let client = runtime() + .block_on(torii_client::Client::new_with_config(torii_url, max_message_size as usize)) + .map_err(|_e| DojoError::ConnectionError)?; + + Ok(Self { + inner: Arc::new(client), + subscriptions: Arc::new(Mutex::new(HashMap::new())), + next_sub_id: Arc::new(AtomicU64::new(0)), + }) + } + + /// Publish an offchain message to the world + /// Returns the entity ID of the published message + pub fn publish_message(&self, message: Message) -> Result { + let msg: torii_proto::Message = message.into(); + let inner = self.inner.clone(); + runtime().block_on(inner.publish_message(msg)).map_err(|_| DojoError::PublishError) + } + + /// Publish multiple offchain messages to the world + /// Returns the entity IDs of the published messages + pub fn publish_message_batch(&self, messages: Vec) -> Result, DojoError> { + let msgs: Vec = messages.into_iter().map(|m| m.into()).collect(); + let inner = self.inner.clone(); + runtime().block_on(inner.publish_message_batch(msgs)).map_err(|_| DojoError::PublishError) + } + + /// Get world metadata for specified world addresses + pub fn worlds(&self, world_addresses: Vec) -> Result, DojoError> { + let addrs: Result, DojoError> = + world_addresses.iter().map(field_element_to_felt).collect(); + let addrs = addrs?; + + let inner = self.inner.clone(); + let worlds = runtime() + .block_on(inner.worlds(addrs)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(worlds.into_iter().map(|w| w.into()).collect()) + } + + /// Retrieve controllers matching the query + pub fn controllers(&self, query: ControllerQuery) -> Result { + let q: torii_proto::ControllerQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.controllers(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageController { + items: page.items.into_iter().map(|c| c.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve contracts matching the query + pub fn contracts(&self, query: ContractQuery) -> Result, DojoError> { + let q: torii_proto::ContractQuery = query.into(); + let inner = self.inner.clone(); + let contracts = runtime() + .block_on(inner.contracts(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(contracts.into_iter().map(|c| c.into()).collect()) + } + + /// Retrieve tokens matching the query + pub fn tokens(&self, query: TokenQuery) -> Result { + let q: torii_proto::TokenQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.tokens(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageToken { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token balances + pub fn token_balances(&self, query: TokenBalanceQuery) -> Result { + let q: torii_proto::TokenBalanceQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.token_balances(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageTokenBalance { + items: page.items.into_iter().map(|b| b.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token contracts + pub fn token_contracts( + &self, + query: TokenContractQuery, + ) -> Result { + let q: torii_proto::TokenContractQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.token_contracts(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageTokenContract { + items: page.items.into_iter().map(|tc| tc.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token transfers + pub fn token_transfers( + &self, + query: TokenTransferQuery, + ) -> Result { + let q: torii_proto::TokenTransferQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.token_transfers(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageTokenTransfer { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve transactions + pub fn transactions(&self, query: TransactionQuery) -> Result { + let q: torii_proto::TransactionQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.transactions(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageTransaction { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve aggregations (leaderboards, stats, rankings) + pub fn aggregations(&self, query: AggregationQuery) -> Result { + let q: torii_proto::AggregationQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.aggregations(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageAggregationEntry { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve activities (user session tracking) + pub fn activities(&self, query: ActivityQuery) -> Result { + let q: torii_proto::ActivityQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.activities(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageActivity { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve achievements + pub fn achievements(&self, query: AchievementQuery) -> Result { + let q: torii_proto::AchievementQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.achievements(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageAchievement { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve player achievements + pub fn player_achievements( + &self, + query: PlayerAchievementQuery, + ) -> Result { + let q: torii_proto::PlayerAchievementQuery = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.player_achievements(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PagePlayerAchievement { + items: page.items.into_iter().map(|p| p.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve entities matching the query + pub fn entities(&self, query: Query) -> Result { + let q: torii_proto::Query = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.entities(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageEntity { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve event messages matching the query + pub fn event_messages(&self, query: Query) -> Result { + let q: torii_proto::Query = query.into(); + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.event_messages(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageEntity { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve raw Starknet events + pub fn starknet_events(&self, query: EventQuery) -> Result { + let q: torii_proto::EventQuery = query.try_into()?; + let inner = self.inner.clone(); + let page = runtime() + .block_on(inner.starknet_events(q)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + Ok(PageEvent { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Execute a SQL query against the Torii database + pub fn sql(&self, query: String) -> Result, DojoError> { + let inner = self.inner.clone(); + let rows = runtime() + .block_on(inner.sql(query)) + .map_err(|e| DojoError::QueryError { message: e.to_string() })?; + + rows.into_iter().map(|r| r.try_into()).collect() + } + + /// Subscribe to entity updates + pub fn subscribe_entity_updates( + &self, + clause: Option, + world_addresses: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let addrs: Result, DojoError> = + world_addresses.iter().map(field_element_to_felt).collect(); + let addrs = addrs?; + + let clause_proto = clause.map(|c| c.into()); + + let inner = self.inner.clone(); + let stream = runtime() + .block_on(inner.on_entity_updated(clause_proto, addrs)) + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = runtime().spawn(async move { + use futures_util::StreamExt; + let mut stream = stream; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, entity)) => { + callback.on_update(entity.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to token balance updates + pub fn subscribe_token_balance_updates( + &self, + contract_addresses: Vec, + account_addresses: Vec, + token_ids: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let contracts: Result, DojoError> = + contract_addresses.iter().map(field_element_to_felt).collect(); + let accounts: Result, DojoError> = + account_addresses.iter().map(field_element_to_felt).collect(); + let ids: Result, DojoError> = + token_ids.iter().map(uniffi_to_u256).collect(); + + let inner = self.inner.clone(); + let stream = runtime() + .block_on(inner.on_token_balance_updated(contracts?, accounts?, ids?)) + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = runtime().spawn(async move { + use futures_util::StreamExt; + let mut stream = stream; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, balance)) => { + callback.on_update(balance.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to token updates + pub fn subscribe_token_updates( + &self, + contract_addresses: Vec, + token_ids: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let contracts: Result, DojoError> = + contract_addresses.iter().map(field_element_to_felt).collect(); + let ids: Result, DojoError> = + token_ids.iter().map(uniffi_to_u256).collect(); + + let inner = self.inner.clone(); + let stream = runtime() + .block_on(inner.on_token_updated(contracts?, ids?)) + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = runtime().spawn(async move { + use futures_util::StreamExt; + let mut stream = stream; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, token)) => { + callback.on_update(token.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to transaction updates + pub fn subscribe_transaction_updates( + &self, + filter: Option, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let filter_proto = filter.map(|f| f.into()); + + let inner = self.inner.clone(); + let stream = runtime() + .block_on(inner.on_transaction(filter_proto)) + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = runtime().spawn(async move { + use futures_util::StreamExt; + let mut stream = stream; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok(transaction) => { + callback.on_update(transaction.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to Starknet event updates + pub fn subscribe_event_updates( + &self, + keys: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let keys_proto: Vec = keys.into_iter().map(|k| k.into()).collect(); + + let inner = self.inner.clone(); + let stream = runtime() + .block_on(inner.on_starknet_event(keys_proto)) + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = runtime().spawn(async move { + use futures_util::StreamExt; + let mut stream = stream; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok(event) => { + callback.on_update(event.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Cancel a subscription + pub fn cancel_subscription(&self, subscription_id: u64) -> Result<(), DojoError> { + let mut subs = self.subscriptions.lock().unwrap(); + if let Some(handle) = subs.remove(&subscription_id) { + handle.abort(); + Ok(()) + } else { + Err(DojoError::SubscriptionError) + } + } +} diff --git a/crates/uniffi/src/uniffi/mod.rs b/crates/uniffi/src/uniffi/mod.rs new file mode 100644 index 0000000..c422a6d --- /dev/null +++ b/crates/uniffi/src/uniffi/mod.rs @@ -0,0 +1,14 @@ +// UniFFI bindings for Dojo +// +// This module provides foreign function interface bindings for multiple languages +// (Swift, Kotlin, Python) using Mozilla's UniFFI framework. + +// Type definitions organized by domain +pub mod types; + +// Client implementation +pub mod client; + +// Re-export everything for convenience +pub use client::*; +pub use types::*; diff --git a/crates/uniffi/src/uniffi/types/achievement.rs b/crates/uniffi/src/uniffi/types/achievement.rs new file mode 100644 index 0000000..d107af2 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/achievement.rs @@ -0,0 +1,239 @@ +// Achievement types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct AchievementTask { + pub task_id: String, + pub description: String, + pub total: u32, + pub total_completions: u32, + pub completion_rate: f64, + pub created_at: u64, +} + +impl From for AchievementTask { + fn from(val: torii_proto::AchievementTask) -> Self { + AchievementTask { + task_id: val.task_id, + description: val.description, + total: val.total, + total_completions: val.total_completions, + completion_rate: val.completion_rate, + created_at: val.created_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct Achievement { + pub id: String, + pub world_address: FieldElement, + pub namespace: String, + pub entity_id: String, + pub hidden: bool, + pub index: u32, + pub points: u32, + pub start: String, + pub end: String, + pub group: String, + pub icon: String, + pub title: String, + pub description: String, + pub tasks: Vec, + pub data: Option, + pub total_completions: u32, + pub completion_rate: f64, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for Achievement { + fn from(val: torii_proto::Achievement) -> Self { + let tasks: Vec = val.tasks.into_iter().map(|t| t.into()).collect(); + + Achievement { + id: val.id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + entity_id: val.entity_id, + hidden: val.hidden, + index: val.index, + points: val.points, + start: val.start, + end: val.end, + group: val.group, + icon: val.icon, + title: val.title, + description: val.description, + tasks, + data: val.data, + total_completions: val.total_completions, + completion_rate: val.completion_rate, + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct AchievementQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub hidden: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::AchievementQuery { + fn from(val: AchievementQuery) -> Self { + torii_proto::AchievementQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + hidden: val.hidden, + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TaskProgress { + pub task_id: String, + pub count: u32, + pub completed: bool, +} + +impl From for TaskProgress { + fn from(val: torii_proto::TaskProgress) -> Self { + TaskProgress { task_id: val.task_id, count: val.count, completed: val.completed } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementProgress { + pub achievement: Achievement, + pub task_progress: Vec, + pub completed: bool, + pub progress_percentage: f64, +} + +impl From for PlayerAchievementProgress { + fn from(val: torii_proto::PlayerAchievementProgress) -> Self { + let task_progress: Vec = + val.task_progress.into_iter().map(|t| t.into()).collect(); + + PlayerAchievementProgress { + achievement: val.achievement.into(), + task_progress, + completed: val.completed, + progress_percentage: val.progress_percentage, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementStats { + pub total_points: u32, + pub completed_achievements: u32, + pub total_achievements: u32, + pub completion_percentage: f64, + pub last_achievement_at: Option, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for PlayerAchievementStats { + fn from(val: torii_proto::PlayerAchievementStats) -> Self { + PlayerAchievementStats { + total_points: val.total_points, + completed_achievements: val.completed_achievements, + total_achievements: val.total_achievements, + completion_percentage: val.completion_percentage, + last_achievement_at: val.last_achievement_at.map(|t| t.timestamp() as u64), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementEntry { + pub player_address: FieldElement, + pub stats: PlayerAchievementStats, + pub achievements: Vec, +} + +impl From for PlayerAchievementEntry { + fn from(val: torii_proto::PlayerAchievementEntry) -> Self { + let achievements: Vec = + val.achievements.into_iter().map(|a| a.into()).collect(); + + PlayerAchievementEntry { + player_address: felt_to_field_element(val.player_address), + stats: val.stats.into(), + achievements, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub player_addresses: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::PlayerAchievementQuery { + fn from(val: PlayerAchievementQuery) -> Self { + torii_proto::PlayerAchievementQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + player_addresses: val + .player_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct AchievementProgression { + pub id: String, + pub achievement_id: String, + pub task_id: String, + pub world_address: FieldElement, + pub namespace: String, + pub player_id: FieldElement, + pub count: u32, + pub completed: bool, + pub completed_at: Option, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for AchievementProgression { + fn from(val: torii_proto::AchievementProgression) -> Self { + AchievementProgression { + id: val.id, + achievement_id: val.achievement_id, + task_id: val.task_id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + player_id: felt_to_field_element(val.player_id), + count: val.count, + completed: val.completed, + completed_at: val.completed_at.map(|t| t.timestamp() as u64), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} diff --git a/crates/uniffi/src/uniffi/types/activity.rs b/crates/uniffi/src/uniffi/types/activity.rs new file mode 100644 index 0000000..70b97f3 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/activity.rs @@ -0,0 +1,76 @@ +// Activity types +use chrono::DateTime; + +use super::core::*; + +#[derive(Debug, Clone)] +pub struct ActionCount { + pub action_name: String, + pub count: u32, +} + +#[derive(Debug, Clone)] +pub struct Activity { + pub id: String, + pub world_address: FieldElement, + pub namespace: String, + pub caller_address: FieldElement, + pub session_start: u64, + pub session_end: u64, + pub action_count: u32, + pub actions: Vec, + pub updated_at: u64, +} + +impl From for Activity { + fn from(val: torii_proto::Activity) -> Self { + let actions: Vec = val + .actions + .into_iter() + .map(|(name, count)| ActionCount { action_name: name, count }) + .collect(); + + Activity { + id: val.id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + caller_address: felt_to_field_element(val.caller_address), + session_start: val.session_start.timestamp() as u64, + session_end: val.session_end.timestamp() as u64, + action_count: val.action_count, + actions, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct ActivityQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub caller_addresses: Vec, + pub from_time: Option, + pub to_time: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::ActivityQuery { + fn from(val: ActivityQuery) -> Self { + torii_proto::ActivityQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + caller_addresses: val + .caller_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + from_time: val.from_time.map(|t| DateTime::from_timestamp(t as i64, 0).unwrap()), + to_time: val.to_time.map(|t| DateTime::from_timestamp(t as i64, 0).unwrap()), + pagination: val.pagination.into(), + } + } +} diff --git a/crates/uniffi/src/uniffi/types/aggregation.rs b/crates/uniffi/src/uniffi/types/aggregation.rs new file mode 100644 index 0000000..f2bad3b --- /dev/null +++ b/crates/uniffi/src/uniffi/types/aggregation.rs @@ -0,0 +1,48 @@ +// Aggregation types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct AggregationQuery { + pub aggregator_ids: Vec, + pub entity_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::AggregationQuery { + fn from(val: AggregationQuery) -> Self { + torii_proto::AggregationQuery { + aggregator_ids: val.aggregator_ids, + entity_ids: val.entity_ids, + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct AggregationEntry { + pub id: String, + pub aggregator_id: String, + pub entity_id: String, + pub value: U256, + pub display_value: String, + pub position: u64, + pub model_id: String, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for AggregationEntry { + fn from(val: torii_proto::AggregationEntry) -> Self { + AggregationEntry { + id: val.id, + aggregator_id: val.aggregator_id, + entity_id: val.entity_id, + value: u256_to_uniffi(val.value), + display_value: val.display_value, + position: val.position, + model_id: val.model_id, + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} diff --git a/crates/uniffi/src/uniffi/types/contract.rs b/crates/uniffi/src/uniffi/types/contract.rs new file mode 100644 index 0000000..30b6bce --- /dev/null +++ b/crates/uniffi/src/uniffi/types/contract.rs @@ -0,0 +1,84 @@ +// Contract types +use super::core::*; + +#[derive(Debug, Clone)] +pub enum ContractType { + WORLD, + ERC20, + ERC721, + ERC1155, + UDC, + OTHER, +} + +impl From for ContractType { + fn from(val: torii_proto::ContractType) -> Self { + match val { + torii_proto::ContractType::WORLD => ContractType::WORLD, + torii_proto::ContractType::ERC20 => ContractType::ERC20, + torii_proto::ContractType::ERC721 => ContractType::ERC721, + torii_proto::ContractType::ERC1155 => ContractType::ERC1155, + torii_proto::ContractType::UDC => ContractType::UDC, + torii_proto::ContractType::OTHER => ContractType::OTHER, + } + } +} + +impl From for torii_proto::ContractType { + fn from(val: ContractType) -> Self { + match val { + ContractType::WORLD => torii_proto::ContractType::WORLD, + ContractType::ERC20 => torii_proto::ContractType::ERC20, + ContractType::ERC721 => torii_proto::ContractType::ERC721, + ContractType::ERC1155 => torii_proto::ContractType::ERC1155, + ContractType::UDC => torii_proto::ContractType::UDC, + ContractType::OTHER => torii_proto::ContractType::OTHER, + } + } +} + +#[derive(Debug, Clone)] +pub struct Contract { + pub contract_address: FieldElement, + pub contract_type: ContractType, + pub head: Option, + pub tps: Option, + pub last_block_timestamp: Option, + pub last_pending_block_tx: Option, + pub updated_at: u64, + pub created_at: u64, +} + +impl From for Contract { + fn from(val: torii_proto::Contract) -> Self { + Contract { + contract_type: val.contract_type.into(), + head: val.head, + tps: val.tps, + last_block_timestamp: val.last_block_timestamp, + last_pending_block_tx: val.last_pending_block_tx.map(felt_to_field_element), + updated_at: val.updated_at.timestamp() as u64, + created_at: val.created_at.timestamp() as u64, + contract_address: felt_to_field_element(val.contract_address), + } + } +} + +#[derive(Debug, Clone)] +pub struct ContractQuery { + pub contract_addresses: Vec, + pub contract_types: Vec, +} + +impl From for torii_proto::ContractQuery { + fn from(val: ContractQuery) -> Self { + torii_proto::ContractQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_types: val.contract_types.into_iter().map(|t| t.into()).collect(), + } + } +} diff --git a/crates/uniffi/src/uniffi/types/controller.rs b/crates/uniffi/src/uniffi/types/controller.rs new file mode 100644 index 0000000..5b1a04f --- /dev/null +++ b/crates/uniffi/src/uniffi/types/controller.rs @@ -0,0 +1,40 @@ +// Controller types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct Controller { + pub address: FieldElement, + pub username: String, + pub deployed_at_timestamp: u64, +} + +impl From for Controller { + fn from(val: torii_proto::Controller) -> Self { + Controller { + address: felt_to_field_element(val.address), + username: val.username, + deployed_at_timestamp: val.deployed_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct ControllerQuery { + pub pagination: Pagination, + pub contract_addresses: Vec, + pub usernames: Vec, +} + +impl From for torii_proto::ControllerQuery { + fn from(val: ControllerQuery) -> Self { + torii_proto::ControllerQuery { + pagination: val.pagination.into(), + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + usernames: val.usernames, + } + } +} diff --git a/crates/uniffi/src/uniffi/types/core.rs b/crates/uniffi/src/uniffi/types/core.rs new file mode 100644 index 0000000..783256c --- /dev/null +++ b/crates/uniffi/src/uniffi/types/core.rs @@ -0,0 +1,340 @@ +// Core types - FieldElement, U256, Error, Pagination, Signature, Call, BlockId + +// Newtype wrappers for custom type conversions +// These will be represented as strings in the UDL via [Custom] attribute + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FieldElement(pub String); + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct U256(pub String); + +// Custom type implementations for UniFFI +// These newtype wrappers will be represented as their inner type (String) in foreign languages +uniffi::custom_newtype!(FieldElement, String); +uniffi::custom_newtype!(U256, String); + +// Helper functions to convert between internal types and UniFFI types +pub fn felt_to_field_element(felt: starknet::core::types::Felt) -> FieldElement { + FieldElement(format!("0x{:064x}", felt)) +} + +pub fn field_element_to_felt(fe: &FieldElement) -> Result { + starknet::core::types::Felt::from_hex(&fe.0).map_err(|_| DojoError::InvalidInput) +} + +pub fn u256_to_uniffi(u: crypto_bigint::U256) -> U256 { + U256(format!("0x{:064x}", u)) +} + +pub fn uniffi_to_u256(u: &U256) -> Result { + let s = u.0.strip_prefix("0x").unwrap_or(&u.0); + let bytes = hex::decode(s).map_err(|_| DojoError::InvalidInput)?; + Ok(crypto_bigint::U256::from_be_slice(&bytes)) +} + +// Error types +#[derive(Debug, thiserror::Error)] +pub enum DojoError { + #[error("Client error: {message}")] + ClientError { message: String }, + #[error("Serialization error: {message}")] + SerializationError { message: String }, + #[error("Network error: {message}")] + NetworkError { message: String }, + #[error("Invalid input")] + InvalidInput, + #[error("Connection error")] + ConnectionError, + #[error("Publish error")] + PublishError, + #[error("Query error: {message}")] + QueryError { message: String }, + #[error("Subscription error")] + SubscriptionError, +} + +impl From for DojoError { + fn from(e: anyhow::Error) -> Self { + DojoError::ClientError { message: e.to_string() } + } +} + +// Pagination +#[derive(Debug, Clone)] +pub enum PaginationDirection { + Forward, + Backward, +} + +impl From for torii_proto::PaginationDirection { + fn from(val: PaginationDirection) -> Self { + match val { + PaginationDirection::Forward => torii_proto::PaginationDirection::Forward, + PaginationDirection::Backward => torii_proto::PaginationDirection::Backward, + } + } +} + +impl From for PaginationDirection { + fn from(val: torii_proto::PaginationDirection) -> Self { + match val { + torii_proto::PaginationDirection::Forward => PaginationDirection::Forward, + torii_proto::PaginationDirection::Backward => PaginationDirection::Backward, + } + } +} + +#[derive(Debug, Clone)] +pub enum OrderDirection { + Asc, + Desc, +} + +impl From for torii_proto::OrderDirection { + fn from(val: OrderDirection) -> Self { + match val { + OrderDirection::Asc => torii_proto::OrderDirection::Asc, + OrderDirection::Desc => torii_proto::OrderDirection::Desc, + } + } +} + +impl From for OrderDirection { + fn from(val: torii_proto::OrderDirection) -> Self { + match val { + torii_proto::OrderDirection::Asc => OrderDirection::Asc, + torii_proto::OrderDirection::Desc => OrderDirection::Desc, + } + } +} + +#[derive(Debug, Clone)] +pub struct OrderBy { + pub field: String, + pub direction: OrderDirection, +} + +impl From for torii_proto::OrderBy { + fn from(val: OrderBy) -> Self { + torii_proto::OrderBy { field: val.field, direction: val.direction.into() } + } +} + +impl From for OrderBy { + fn from(val: torii_proto::OrderBy) -> Self { + OrderBy { field: val.field, direction: val.direction.into() } + } +} + +#[derive(Debug, Clone)] +pub struct Pagination { + pub cursor: Option, + pub limit: Option, + pub direction: PaginationDirection, + pub order_by: Vec, +} + +impl From for torii_proto::Pagination { + fn from(val: Pagination) -> Self { + torii_proto::Pagination { + cursor: val.cursor, + limit: val.limit, + direction: val.direction.into(), + order_by: val.order_by.into_iter().map(|o| o.into()).collect(), + } + } +} + +impl From for Pagination { + fn from(val: torii_proto::Pagination) -> Self { + Pagination { + cursor: val.cursor, + limit: val.limit, + direction: val.direction.into(), + order_by: val.order_by.into_iter().map(|o| o.into()).collect(), + } + } +} + +// Note: Page is not included in UniFFI as it doesn't support generics. +// If you need paginated results, use the specific query methods that return +// collections directly (e.g., Vec, Vec, etc.) + +// Signature +#[derive(Debug, Clone)] +pub struct Signature { + pub r: FieldElement, + pub s: FieldElement, +} + +impl From for starknet::core::crypto::Signature { + fn from(val: Signature) -> Self { + Self { + r: field_element_to_felt(&val.r).unwrap(), + s: field_element_to_felt(&val.s).unwrap(), + } + } +} + +impl From for Signature { + fn from(val: starknet::core::crypto::Signature) -> Self { + Signature { r: felt_to_field_element(val.r), s: felt_to_field_element(val.s) } + } +} + +// Call +#[derive(Debug, Clone)] +pub struct Call { + pub to: FieldElement, + pub selector: String, + pub calldata: Vec, +} + +impl From for starknet::core::types::Call { + fn from(val: Call) -> Self { + starknet::core::types::Call { + to: field_element_to_felt(&val.to).unwrap(), + selector: starknet::core::utils::get_selector_from_name(&val.selector).unwrap(), + calldata: val + .calldata + .into_iter() + .map(|f| field_element_to_felt(&f).unwrap()) + .collect(), + } + } +} + +impl From for starknet::core::types::FunctionCall { + fn from(val: Call) -> Self { + starknet::core::types::FunctionCall { + contract_address: field_element_to_felt(&val.to).unwrap(), + entry_point_selector: starknet::core::utils::get_selector_from_name(&val.selector) + .unwrap(), + calldata: val + .calldata + .into_iter() + .map(|f| field_element_to_felt(&f).unwrap()) + .collect(), + } + } +} + +// BlockId and BlockTag +#[derive(Debug, Clone)] +pub enum BlockTag { + Latest, + PreConfirmed, +} + +impl From for starknet::core::types::BlockTag { + fn from(val: BlockTag) -> Self { + match val { + BlockTag::Latest => starknet::core::types::BlockTag::Latest, + BlockTag::PreConfirmed => starknet::core::types::BlockTag::PreConfirmed, + } + } +} + +#[derive(Debug, Clone)] +pub enum BlockId { + Hash(FieldElement), + Number(u64), + Tag(BlockTag), +} + +impl From for starknet::core::types::BlockId { + fn from(val: BlockId) -> Self { + match val { + BlockId::Hash(hash) => { + starknet::core::types::BlockId::Hash(field_element_to_felt(&hash).unwrap()) + } + BlockId::Number(number) => starknet::core::types::BlockId::Number(number), + BlockId::Tag(tag) => starknet::core::types::BlockId::Tag(tag.into()), + } + } +} + +// Pagination wrapper types for different result types +// These are used by the client but defined here for availability + +use super::achievement::{Achievement, PlayerAchievementEntry}; +use super::activity::Activity; +use super::aggregation::AggregationEntry; +use super::controller::Controller; +use super::entity::Entity; +use super::event::Event; +use super::token::{Token, TokenBalance, TokenContract, TokenTransfer}; +use super::transaction::Transaction; + +#[derive(Debug, Clone)] +pub struct PageController { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageToken { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenBalance { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenContract { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenTransfer { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTransaction { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageAggregationEntry { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageActivity { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageAchievement { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PagePlayerAchievement { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageEntity { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageEvent { + pub items: Vec, + pub next_cursor: Option, +} diff --git a/crates/uniffi/src/uniffi/types/entity.rs b/crates/uniffi/src/uniffi/types/entity.rs new file mode 100644 index 0000000..164450e --- /dev/null +++ b/crates/uniffi/src/uniffi/types/entity.rs @@ -0,0 +1,125 @@ +// Entity, Model, and World types +use chrono::DateTime; + +use super::core::*; +use super::schema::{Struct, Ty}; + +#[derive(Debug, Clone)] +pub struct Entity { + pub world_address: FieldElement, + pub hashed_keys: FieldElement, + pub models: Vec, + pub created_at: u64, + pub updated_at: u64, + pub executed_at: u64, +} + +impl From for torii_proto::schema::Entity { + fn from(val: Entity) -> Self { + torii_proto::schema::Entity { + world_address: field_element_to_felt(&val.world_address).unwrap(), + hashed_keys: field_element_to_felt(&val.hashed_keys).unwrap(), + models: val.models.into_iter().map(|m| m.into()).collect(), + created_at: DateTime::from_timestamp(val.created_at as i64, 0).unwrap(), + updated_at: DateTime::from_timestamp(val.updated_at as i64, 0).unwrap(), + executed_at: DateTime::from_timestamp(val.executed_at as i64, 0).unwrap(), + } + } +} + +impl From for Entity { + fn from(val: torii_proto::schema::Entity) -> Self { + Entity { + world_address: felt_to_field_element(val.world_address), + hashed_keys: felt_to_field_element(val.hashed_keys), + models: val.models.into_iter().map(|m| m.into()).collect(), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + executed_at: val.executed_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct Model { + pub world_address: FieldElement, + pub schema: Ty, + pub namespace: String, + pub name: String, + pub selector: FieldElement, + pub packed_size: u32, + pub unpacked_size: u32, + pub class_hash: FieldElement, + pub contract_address: FieldElement, + pub layout: String, + pub use_legacy_store: bool, +} + +impl From for Model { + fn from(value: torii_proto::Model) -> Self { + let layout = serde_json::to_string(&value.layout).unwrap(); + + Model { + world_address: felt_to_field_element(value.world_address), + schema: value.schema.into(), + name: value.name, + namespace: value.namespace, + selector: felt_to_field_element(value.selector), + packed_size: value.packed_size, + unpacked_size: value.unpacked_size, + class_hash: felt_to_field_element(value.class_hash), + contract_address: felt_to_field_element(value.contract_address), + layout, + use_legacy_store: value.use_legacy_store, + } + } +} + +impl From for torii_proto::Model { + fn from(value: Model) -> Self { + let layout = serde_json::from_str(&value.layout).unwrap(); + + torii_proto::Model { + world_address: field_element_to_felt(&value.world_address).unwrap(), + schema: value.schema.into(), + namespace: value.namespace, + name: value.name, + selector: field_element_to_felt(&value.selector).unwrap(), + packed_size: value.packed_size, + unpacked_size: value.unpacked_size, + class_hash: field_element_to_felt(&value.class_hash).unwrap(), + contract_address: field_element_to_felt(&value.contract_address).unwrap(), + layout, + use_legacy_store: value.use_legacy_store, + } + } +} + +#[derive(Debug, Clone)] +pub struct World { + pub world_address: FieldElement, + pub models: Vec, +} + +impl From for World { + fn from(value: torii_proto::World) -> Self { + let models: Vec = value.models.into_values().map(|v| v.into()).collect(); + + World { world_address: felt_to_field_element(value.world_address), models } + } +} + +impl From for torii_proto::World { + fn from(value: World) -> Self { + let models: Vec = value.models.into_iter().map(|m| m.into()).collect(); + let models = models + .into_iter() + .map(|m| (dojo_types::naming::compute_selector_from_names(&m.namespace, &m.name), m)) + .collect(); + + torii_proto::World { + world_address: field_element_to_felt(&value.world_address).unwrap(), + models, + } + } +} diff --git a/crates/uniffi/src/uniffi/types/event.rs b/crates/uniffi/src/uniffi/types/event.rs new file mode 100644 index 0000000..b95c48d --- /dev/null +++ b/crates/uniffi/src/uniffi/types/event.rs @@ -0,0 +1,68 @@ +// Event and Message types +use super::core::*; +use super::query::*; + +#[derive(Debug, Clone)] +pub struct Event { + pub keys: Vec, + pub data: Vec, + pub transaction_hash: FieldElement, +} + +#[derive(Debug, Clone)] +pub struct EventQuery { + pub keys: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::Event { + fn from(val: Event) -> Self { + torii_proto::Event { + keys: val.keys.into_iter().map(|k| field_element_to_felt(&k).unwrap()).collect(), + data: val.data.into_iter().map(|d| field_element_to_felt(&d).unwrap()).collect(), + transaction_hash: field_element_to_felt(&val.transaction_hash).unwrap(), + } + } +} + +impl From for Event { + fn from(val: torii_proto::Event) -> Self { + Event { + keys: val.keys.into_iter().map(felt_to_field_element).collect(), + data: val.data.into_iter().map(felt_to_field_element).collect(), + transaction_hash: felt_to_field_element(val.transaction_hash), + } + } +} + +#[derive(Debug, Clone)] +pub struct Message { + pub message: String, + pub signature: Vec, + pub world_address: FieldElement, +} + +impl From for torii_proto::Message { + fn from(val: Message) -> Self { + torii_proto::Message { + message: val.message, + signature: val + .signature + .into_iter() + .map(|s| field_element_to_felt(&s).unwrap()) + .collect(), + world_address: field_element_to_felt(&val.world_address).unwrap(), + } + } +} + +impl TryInto for EventQuery { + type Error = DojoError; + + fn try_into(self) -> Result { + Ok(torii_proto::EventQuery { + keys: self.keys.map(|k| k.into()), + pagination: self.pagination.into(), + }) + } +} diff --git a/crates/uniffi/src/uniffi/types/mod.rs b/crates/uniffi/src/uniffi/types/mod.rs new file mode 100644 index 0000000..3352270 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/mod.rs @@ -0,0 +1,30 @@ +// Core types and error handling +pub mod core; + +// Domain types organized by category +pub mod achievement; +pub mod activity; +pub mod aggregation; +pub mod contract; +pub mod controller; +pub mod entity; +pub mod event; +pub mod query; +pub mod schema; +pub mod token; +pub mod transaction; + +// Re-export all public types for convenience +pub use core::*; + +pub use achievement::*; +pub use activity::*; +pub use aggregation::*; +pub use contract::*; +pub use controller::*; +pub use entity::*; +pub use event::*; +pub use query::*; +pub use schema::*; +pub use token::*; +pub use transaction::*; diff --git a/crates/uniffi/src/uniffi/types/query.rs b/crates/uniffi/src/uniffi/types/query.rs new file mode 100644 index 0000000..c80ae42 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/query.rs @@ -0,0 +1,313 @@ +// Query types - Query, Clause, KeysClause, MemberClause, CompositeClause +use super::core::*; +use super::schema::MemberValue; + +// SQL query result types +#[derive(Debug, Clone)] +pub struct SqlField { + pub name: String, + pub value: SqlValue, +} + +#[derive(Debug, Clone)] +pub struct SqlRow { + pub fields: Vec, +} + +#[derive(Debug, Clone)] +pub enum SqlValue { + Text { value: String }, + Integer { value: i64 }, + Real { value: f64 }, + Blob { value: Vec }, + Null, +} + +impl TryInto for torii_proto::SqlRow { + type Error = DojoError; + + fn try_into(self) -> Result { + let fields = self + .fields + .into_iter() + .map(|(name, v)| { + let value = match v { + torii_proto::SqlValue::Text(s) => SqlValue::Text { value: s }, + torii_proto::SqlValue::Integer(i) => SqlValue::Integer { value: i }, + torii_proto::SqlValue::Real(r) => SqlValue::Real { value: r }, + torii_proto::SqlValue::Blob(b) => SqlValue::Blob { value: b }, + torii_proto::SqlValue::Null => SqlValue::Null, + }; + SqlField { name, value } + }) + .collect(); + Ok(SqlRow { fields }) + } +} + +#[derive(Debug, Clone)] +pub enum PatternMatching { + FixedLen, + VariableLen, +} + +impl From for torii_proto::PatternMatching { + fn from(val: PatternMatching) -> Self { + match val { + PatternMatching::FixedLen => torii_proto::PatternMatching::FixedLen, + PatternMatching::VariableLen => torii_proto::PatternMatching::VariableLen, + } + } +} + +impl From for PatternMatching { + fn from(val: torii_proto::PatternMatching) -> Self { + match val { + torii_proto::PatternMatching::FixedLen => PatternMatching::FixedLen, + torii_proto::PatternMatching::VariableLen => PatternMatching::VariableLen, + } + } +} + +#[derive(Debug, Clone)] +pub struct KeysClause { + pub keys: Vec>, + pub pattern_matching: PatternMatching, + pub models: Vec, +} + +impl From for torii_proto::KeysClause { + fn from(val: KeysClause) -> Self { + torii_proto::KeysClause { + keys: val + .keys + .into_iter() + .map(|k| k.map(|s| field_element_to_felt(&s).unwrap())) + .collect(), + pattern_matching: val.pattern_matching.into(), + models: val.models, + } + } +} + +impl From for KeysClause { + fn from(val: torii_proto::KeysClause) -> Self { + KeysClause { + models: val.models, + keys: val.keys.into_iter().map(|k| k.map(felt_to_field_element)).collect(), + pattern_matching: val.pattern_matching.into(), + } + } +} + +#[derive(Debug, Clone)] +pub enum LogicalOperator { + And, + Or, +} + +impl From for torii_proto::LogicalOperator { + fn from(val: LogicalOperator) -> Self { + match val { + LogicalOperator::And => torii_proto::LogicalOperator::And, + LogicalOperator::Or => torii_proto::LogicalOperator::Or, + } + } +} + +impl From for LogicalOperator { + fn from(val: torii_proto::LogicalOperator) -> Self { + match val { + torii_proto::LogicalOperator::And => LogicalOperator::And, + torii_proto::LogicalOperator::Or => LogicalOperator::Or, + } + } +} + +#[derive(Debug, Clone)] +pub enum ComparisonOperator { + Eq, + Neq, + Gt, + Gte, + Lt, + Lte, + In, + NotIn, + Contains, + ContainsAll, + ContainsAny, + ArrayLengthEq, + ArrayLengthGt, + ArrayLengthLt, +} + +impl From for torii_proto::ComparisonOperator { + fn from(val: ComparisonOperator) -> Self { + match val { + ComparisonOperator::Eq => torii_proto::ComparisonOperator::Eq, + ComparisonOperator::Neq => torii_proto::ComparisonOperator::Neq, + ComparisonOperator::Gt => torii_proto::ComparisonOperator::Gt, + ComparisonOperator::Gte => torii_proto::ComparisonOperator::Gte, + ComparisonOperator::Lt => torii_proto::ComparisonOperator::Lt, + ComparisonOperator::Lte => torii_proto::ComparisonOperator::Lte, + ComparisonOperator::In => torii_proto::ComparisonOperator::In, + ComparisonOperator::NotIn => torii_proto::ComparisonOperator::NotIn, + ComparisonOperator::Contains => torii_proto::ComparisonOperator::Contains, + ComparisonOperator::ContainsAll => torii_proto::ComparisonOperator::ContainsAll, + ComparisonOperator::ContainsAny => torii_proto::ComparisonOperator::ContainsAny, + ComparisonOperator::ArrayLengthEq => torii_proto::ComparisonOperator::ArrayLengthEq, + ComparisonOperator::ArrayLengthGt => torii_proto::ComparisonOperator::ArrayLengthGt, + ComparisonOperator::ArrayLengthLt => torii_proto::ComparisonOperator::ArrayLengthLt, + } + } +} + +impl From for ComparisonOperator { + fn from(val: torii_proto::ComparisonOperator) -> Self { + match val { + torii_proto::ComparisonOperator::Eq => ComparisonOperator::Eq, + torii_proto::ComparisonOperator::Neq => ComparisonOperator::Neq, + torii_proto::ComparisonOperator::Gt => ComparisonOperator::Gt, + torii_proto::ComparisonOperator::Gte => ComparisonOperator::Gte, + torii_proto::ComparisonOperator::Lt => ComparisonOperator::Lt, + torii_proto::ComparisonOperator::Lte => ComparisonOperator::Lte, + torii_proto::ComparisonOperator::In => ComparisonOperator::In, + torii_proto::ComparisonOperator::NotIn => ComparisonOperator::NotIn, + torii_proto::ComparisonOperator::Contains => ComparisonOperator::Contains, + torii_proto::ComparisonOperator::ContainsAll => ComparisonOperator::ContainsAll, + torii_proto::ComparisonOperator::ContainsAny => ComparisonOperator::ContainsAny, + torii_proto::ComparisonOperator::ArrayLengthEq => ComparisonOperator::ArrayLengthEq, + torii_proto::ComparisonOperator::ArrayLengthGt => ComparisonOperator::ArrayLengthGt, + torii_proto::ComparisonOperator::ArrayLengthLt => ComparisonOperator::ArrayLengthLt, + } + } +} + +#[derive(Debug, Clone)] +pub struct MemberClause { + pub model: String, + pub member: String, + pub operator: ComparisonOperator, + pub value: MemberValue, +} + +impl From for torii_proto::MemberClause { + fn from(val: MemberClause) -> Self { + torii_proto::MemberClause { + member: val.member, + model: val.model, + operator: val.operator.into(), + value: val.value.into(), + } + } +} + +impl From for MemberClause { + fn from(val: torii_proto::MemberClause) -> Self { + MemberClause { + model: val.model, + member: val.member, + operator: val.operator.into(), + value: val.value.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct CompositeClause { + pub operator: LogicalOperator, + pub clauses: Vec, +} + +impl From for torii_proto::CompositeClause { + fn from(val: CompositeClause) -> Self { + torii_proto::CompositeClause { + operator: val.operator.into(), + clauses: val.clauses.into_iter().map(|c| c.into()).collect(), + } + } +} + +impl From for CompositeClause { + fn from(val: torii_proto::CompositeClause) -> Self { + CompositeClause { + operator: val.operator.into(), + clauses: val.clauses.into_iter().map(|c| c.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub enum Clause { + HashedKeys { keys: Vec }, + Keys { clause: KeysClause }, + Member { clause: MemberClause }, + Composite { clause: CompositeClause }, +} + +impl From for torii_proto::Clause { + fn from(val: Clause) -> Self { + match val { + Clause::HashedKeys { keys } => torii_proto::Clause::HashedKeys( + keys.into_iter().map(|k| field_element_to_felt(&k).unwrap()).collect(), + ), + Clause::Keys { clause } => torii_proto::Clause::Keys(clause.into()), + Clause::Member { clause } => torii_proto::Clause::Member(clause.into()), + Clause::Composite { clause } => torii_proto::Clause::Composite(clause.into()), + } + } +} + +impl From for Clause { + fn from(val: torii_proto::Clause) -> Self { + match val { + torii_proto::Clause::HashedKeys(keys) => { + Clause::HashedKeys { keys: keys.into_iter().map(felt_to_field_element).collect() } + } + torii_proto::Clause::Keys(clause) => Clause::Keys { clause: clause.into() }, + torii_proto::Clause::Member(clause) => Clause::Member { clause: clause.into() }, + torii_proto::Clause::Composite(clause) => Clause::Composite { clause: clause.into() }, + } + } +} + +#[derive(Debug, Clone)] +pub struct Query { + pub world_addresses: Vec, + pub pagination: Pagination, + pub clause: Option, + pub no_hashed_keys: bool, + pub models: Vec, + pub historical: bool, +} + +impl From for torii_proto::Query { + fn from(val: Query) -> Self { + torii_proto::Query { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + pagination: val.pagination.into(), + clause: val.clause.map(|c| c.into()), + models: val.models, + no_hashed_keys: val.no_hashed_keys, + historical: val.historical, + } + } +} + +impl From for Query { + fn from(val: torii_proto::Query) -> Self { + Query { + world_addresses: val.world_addresses.into_iter().map(felt_to_field_element).collect(), + pagination: val.pagination.into(), + clause: val.clause.map(|c| c.into()), + models: val.models, + no_hashed_keys: val.no_hashed_keys, + historical: val.historical, + } + } +} diff --git a/crates/uniffi/src/uniffi/types/schema.rs b/crates/uniffi/src/uniffi/types/schema.rs new file mode 100644 index 0000000..6d74e14 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/schema.rs @@ -0,0 +1,349 @@ +// Schema types - Primitive, Ty, Struct, Enum, Member +use super::core::*; + +#[derive(Debug, Clone)] +pub enum Primitive { + I8 { value: i8 }, + I16 { value: i16 }, + I32 { value: i32 }, + I64 { value: i64 }, + I128 { value: Vec }, // 16 bytes + U8 { value: u8 }, + U16 { value: u16 }, + U32 { value: u32 }, + U64 { value: u64 }, + U128 { value: Vec }, // 16 bytes + U256 { value: U256 }, + Bool { value: bool }, + Felt252 { value: FieldElement }, + ClassHash { value: FieldElement }, + ContractAddress { value: FieldElement }, + EthAddress { value: FieldElement }, +} + +impl From for dojo_types::primitive::Primitive { + fn from(value: Primitive) -> Self { + match value { + Primitive::I8 { value: v } => dojo_types::primitive::Primitive::I8(Some(v)), + Primitive::I16 { value: v } => dojo_types::primitive::Primitive::I16(Some(v)), + Primitive::I32 { value: v } => dojo_types::primitive::Primitive::I32(Some(v)), + Primitive::I64 { value: v } => dojo_types::primitive::Primitive::I64(Some(v)), + Primitive::I128 { value: v } => { + let mut bytes = [0u8; 16]; + bytes.copy_from_slice(&v); + dojo_types::primitive::Primitive::I128(Some(i128::from_be_bytes(bytes))) + } + Primitive::U8 { value: v } => dojo_types::primitive::Primitive::U8(Some(v)), + Primitive::U16 { value: v } => dojo_types::primitive::Primitive::U16(Some(v)), + Primitive::U32 { value: v } => dojo_types::primitive::Primitive::U32(Some(v)), + Primitive::U64 { value: v } => dojo_types::primitive::Primitive::U64(Some(v)), + Primitive::U128 { value: v } => { + let mut bytes = [0u8; 16]; + bytes.copy_from_slice(&v); + dojo_types::primitive::Primitive::U128(Some(u128::from_be_bytes(bytes))) + } + Primitive::U256 { value: v } => { + dojo_types::primitive::Primitive::U256(Some(uniffi_to_u256(&v).unwrap())) + } + Primitive::Bool { value: v } => dojo_types::primitive::Primitive::Bool(Some(v)), + Primitive::Felt252 { value: v } => { + dojo_types::primitive::Primitive::Felt252(Some(field_element_to_felt(&v).unwrap())) + } + Primitive::ClassHash { value: v } => dojo_types::primitive::Primitive::ClassHash(Some( + field_element_to_felt(&v).unwrap(), + )), + Primitive::ContractAddress { value: v } => { + dojo_types::primitive::Primitive::ContractAddress(Some( + field_element_to_felt(&v).unwrap(), + )) + } + Primitive::EthAddress { value: v } => dojo_types::primitive::Primitive::EthAddress( + Some(field_element_to_felt(&v).unwrap()), + ), + } + } +} + +impl From for Primitive { + fn from(value: dojo_types::primitive::Primitive) -> Self { + match value { + dojo_types::primitive::Primitive::I8(v) => Primitive::I8 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I16(v) => Primitive::I16 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I32(v) => Primitive::I32 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I64(v) => Primitive::I64 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I128(v) => { + Primitive::I128 { value: v.unwrap_or(0).to_be_bytes().to_vec() } + } + dojo_types::primitive::Primitive::U8(v) => Primitive::U8 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U16(v) => Primitive::U16 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U32(v) => Primitive::U32 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U64(v) => Primitive::U64 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U128(v) => { + Primitive::U128 { value: v.unwrap_or(0).to_be_bytes().to_vec() } + } + dojo_types::primitive::Primitive::U256(v) => Primitive::U256 { + value: v.map(u256_to_uniffi).unwrap_or_else(|| U256("0x0".to_string())), + }, + dojo_types::primitive::Primitive::Bool(v) => { + Primitive::Bool { value: v.unwrap_or(false) } + } + dojo_types::primitive::Primitive::Felt252(v) => Primitive::Felt252 { + value: v + .map(felt_to_field_element) + .unwrap_or_else(|| FieldElement("0x0".to_string())), + }, + dojo_types::primitive::Primitive::ClassHash(v) => Primitive::ClassHash { + value: v + .map(felt_to_field_element) + .unwrap_or_else(|| FieldElement("0x0".to_string())), + }, + dojo_types::primitive::Primitive::ContractAddress(v) => Primitive::ContractAddress { + value: v + .map(felt_to_field_element) + .unwrap_or_else(|| FieldElement("0x0".to_string())), + }, + dojo_types::primitive::Primitive::EthAddress(v) => Primitive::EthAddress { + value: v + .map(felt_to_field_element) + .unwrap_or_else(|| FieldElement("0x0".to_string())), + }, + } + } +} + +#[derive(Debug, Clone)] +pub enum MemberValue { + Primitive { value: Primitive }, + String { value: String }, + List { values: Vec }, +} + +impl From for torii_proto::MemberValue { + fn from(val: MemberValue) -> Self { + match val { + MemberValue::Primitive { value } => torii_proto::MemberValue::Primitive(value.into()), + MemberValue::String { value } => torii_proto::MemberValue::String(value), + MemberValue::List { values } => { + torii_proto::MemberValue::List(values.into_iter().map(|v| v.into()).collect()) + } + } + } +} + +impl From for MemberValue { + fn from(val: torii_proto::MemberValue) -> Self { + match val { + torii_proto::MemberValue::Primitive(value) => { + MemberValue::Primitive { value: value.into() } + } + torii_proto::MemberValue::String(value) => MemberValue::String { value }, + torii_proto::MemberValue::List(values) => { + MemberValue::List { values: values.into_iter().map(|v| v.into()).collect() } + } + } + } +} + +#[derive(Debug, Clone)] +pub struct FixedSizeArray { + pub array: Vec, + pub size: u32, +} + +#[derive(Debug, Clone)] +pub enum Ty { + Primitive { value: Primitive }, + Struct { value: Struct }, + Enum { value: EnumType }, + Tuple { values: Vec }, + Array { values: Vec }, + FixedSizeArray { value: FixedSizeArray }, + ByteArray { value: String }, +} + +impl From for Ty { + fn from(val: dojo_types::schema::Ty) -> Self { + match val { + dojo_types::schema::Ty::Primitive(primitive) => { + Ty::Primitive { value: primitive.into() } + } + dojo_types::schema::Ty::Struct(struct_) => Ty::Struct { value: struct_.into() }, + dojo_types::schema::Ty::Enum(enum_) => Ty::Enum { value: enum_.into() }, + dojo_types::schema::Ty::Tuple(tuple) => { + Ty::Tuple { values: tuple.into_iter().map(|t| t.into()).collect() } + } + dojo_types::schema::Ty::Array(array) => { + Ty::Array { values: array.into_iter().map(|t| t.into()).collect() } + } + dojo_types::schema::Ty::FixedSizeArray((ty, size)) => Ty::FixedSizeArray { + value: FixedSizeArray { array: ty.into_iter().map(|t| t.into()).collect(), size }, + }, + dojo_types::schema::Ty::ByteArray(array) => Ty::ByteArray { value: array }, + } + } +} + +impl From for dojo_types::schema::Ty { + fn from(val: Ty) -> Self { + match val { + Ty::Primitive { value } => dojo_types::schema::Ty::Primitive(value.into()), + Ty::Struct { value } => dojo_types::schema::Ty::Struct(value.into()), + Ty::Enum { value } => dojo_types::schema::Ty::Enum(value.into()), + Ty::Tuple { values } => { + dojo_types::schema::Ty::Tuple(values.into_iter().map(|t| t.into()).collect()) + } + Ty::Array { values } => { + dojo_types::schema::Ty::Array(values.into_iter().map(|t| t.into()).collect()) + } + Ty::FixedSizeArray { value: fixed_size_array } => { + dojo_types::schema::Ty::FixedSizeArray(( + fixed_size_array.array.into_iter().map(|t| t.into()).collect(), + fixed_size_array.size, + )) + } + Ty::ByteArray { value } => dojo_types::schema::Ty::ByteArray(value), + } + } +} + +#[derive(Debug, Clone)] +pub struct Member { + pub name: String, + pub ty: Ty, + pub key: bool, +} + +impl From for Member { + fn from(value: dojo_types::schema::Member) -> Self { + Member { name: value.name, ty: value.ty.into(), key: value.key } + } +} + +impl From for dojo_types::schema::Member { + fn from(value: Member) -> Self { + dojo_types::schema::Member { name: value.name, ty: value.ty.into(), key: value.key } + } +} + +#[derive(Debug, Clone)] +pub struct Struct { + pub name: String, + pub children: Vec, +} + +impl From for dojo_types::schema::Struct { + fn from(value: Struct) -> Self { + dojo_types::schema::Struct { + name: value.name, + children: value.children.into_iter().map(|c| c.into()).collect(), + } + } +} + +impl From for Struct { + fn from(value: dojo_types::schema::Struct) -> Self { + Struct { + name: value.name, + children: value.children.into_iter().map(|c| c.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub struct EnumOption { + pub name: String, + pub ty: Ty, +} + +impl From for EnumOption { + fn from(value: dojo_types::schema::EnumOption) -> Self { + EnumOption { name: value.name, ty: value.ty.into() } + } +} + +impl From for dojo_types::schema::EnumOption { + fn from(value: EnumOption) -> Self { + dojo_types::schema::EnumOption { name: value.name, ty: value.ty.into() } + } +} + +#[derive(Debug, Clone)] +pub struct EnumType { + pub name: String, + pub option: u8, + pub options: Vec, +} + +impl From for EnumType { + fn from(value: dojo_types::schema::Enum) -> Self { + EnumType { + name: value.name, + option: value.option.unwrap_or(0), + options: value.options.into_iter().map(|o| o.into()).collect(), + } + } +} + +impl From for dojo_types::schema::Enum { + fn from(value: EnumType) -> Self { + dojo_types::schema::Enum { + name: value.name, + option: Some(value.option), + options: value.options.into_iter().map(|o| o.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub enum ValueType { + String { value: String }, + Int { value: i64 }, + UInt { value: u64 }, + Bool { value: bool }, + Bytes { value: Vec }, +} + +impl From for torii_proto::ValueType { + fn from(val: ValueType) -> Self { + match val { + ValueType::String { value: v } => torii_proto::ValueType::String(v), + ValueType::Int { value: v } => torii_proto::ValueType::Int(v), + ValueType::UInt { value: v } => torii_proto::ValueType::UInt(v), + ValueType::Bool { value: v } => torii_proto::ValueType::Bool(v), + ValueType::Bytes { value: v } => torii_proto::ValueType::Bytes(v), + } + } +} + +impl From for ValueType { + fn from(val: torii_proto::ValueType) -> Self { + match val { + torii_proto::ValueType::String(v) => ValueType::String { value: v }, + torii_proto::ValueType::Int(v) => ValueType::Int { value: v }, + torii_proto::ValueType::UInt(v) => ValueType::UInt { value: v }, + torii_proto::ValueType::Bool(v) => ValueType::Bool { value: v }, + torii_proto::ValueType::Bytes(v) => ValueType::Bytes { value: v }, + } + } +} + +#[derive(Debug, Clone)] +pub struct Value { + pub primitive_type: Primitive, + pub value_type: ValueType, +} + +impl From for Value { + fn from(val: torii_proto::Value) -> Self { + Value { primitive_type: val.primitive_type.into(), value_type: val.value_type.into() } + } +} + +impl From for torii_proto::Value { + fn from(val: Value) -> Self { + torii_proto::Value { + primitive_type: val.primitive_type.into(), + value_type: val.value_type.into(), + } + } +} diff --git a/crates/uniffi/src/uniffi/types/token.rs b/crates/uniffi/src/uniffi/types/token.rs new file mode 100644 index 0000000..984ca18 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/token.rs @@ -0,0 +1,211 @@ +// Token types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct Token { + pub contract_address: FieldElement, + pub token_id: Option, + pub name: String, + pub symbol: String, + pub decimals: u8, + pub metadata: String, + pub total_supply: Option, +} + +impl From for Token { + fn from(val: torii_proto::Token) -> Self { + Token { + token_id: val.token_id.map(u256_to_uniffi), + contract_address: felt_to_field_element(val.contract_address), + name: val.name, + symbol: val.symbol, + decimals: val.decimals, + metadata: val.metadata, + total_supply: val.total_supply.map(u256_to_uniffi), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenBalance { + pub balance: U256, + pub account_address: FieldElement, + pub contract_address: FieldElement, + pub token_id: Option, +} + +impl From for TokenBalance { + fn from(val: torii_proto::TokenBalance) -> Self { + TokenBalance { + balance: u256_to_uniffi(val.balance), + account_address: felt_to_field_element(val.account_address), + contract_address: felt_to_field_element(val.contract_address), + token_id: val.token_id.map(u256_to_uniffi), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenContract { + pub contract_address: FieldElement, + pub name: String, + pub symbol: String, + pub decimals: u8, + pub metadata: String, + pub token_metadata: String, + pub total_supply: Option, +} + +impl From for TokenContract { + fn from(val: torii_proto::TokenContract) -> Self { + Self { + contract_address: felt_to_field_element(val.contract_address), + name: val.name, + symbol: val.symbol, + decimals: val.decimals, + token_metadata: val.token_metadata, + total_supply: val.total_supply.map(u256_to_uniffi), + metadata: val.metadata, + } + } +} + +#[derive(Debug, Clone)] +pub struct AttributeFilter { + pub trait_name: String, + pub trait_value: String, +} + +impl From for torii_proto::TokenAttributeFilter { + fn from(val: AttributeFilter) -> Self { + torii_proto::TokenAttributeFilter { + trait_name: val.trait_name, + trait_value: val.trait_value, + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenQuery { + pub contract_addresses: Vec, + pub token_ids: Vec, + pub attribute_filters: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenQuery { + fn from(val: TokenQuery) -> Self { + torii_proto::TokenQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + attribute_filters: val.attribute_filters.into_iter().map(|f| f.into()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenBalanceQuery { + pub contract_addresses: Vec, + pub account_addresses: Vec, + pub token_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenBalanceQuery { + fn from(val: TokenBalanceQuery) -> Self { + torii_proto::TokenBalanceQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + account_addresses: val + .account_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenContractQuery { + pub contract_addresses: Vec, + pub contract_types: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenContractQuery { + fn from(val: TokenContractQuery) -> Self { + torii_proto::TokenContractQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_types: val.contract_types.into_iter().map(|t| t.into()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenTransfer { + pub id: String, + pub contract_address: FieldElement, + pub from_address: FieldElement, + pub to_address: FieldElement, + pub amount: U256, + pub token_id: Option, + pub executed_at: u64, + pub event_id: Option, +} + +impl From for TokenTransfer { + fn from(val: torii_proto::TokenTransfer) -> Self { + TokenTransfer { + id: val.id, + contract_address: felt_to_field_element(val.contract_address), + from_address: felt_to_field_element(val.from_address), + to_address: felt_to_field_element(val.to_address), + amount: u256_to_uniffi(val.amount), + token_id: val.token_id.map(u256_to_uniffi), + executed_at: val.executed_at.timestamp() as u64, + event_id: val.event_id, + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenTransferQuery { + pub contract_addresses: Vec, + pub account_addresses: Vec, + pub token_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenTransferQuery { + fn from(val: TokenTransferQuery) -> Self { + torii_proto::TokenTransferQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + account_addresses: val + .account_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + pagination: val.pagination.into(), + } + } +} diff --git a/crates/uniffi/src/uniffi/types/transaction.rs b/crates/uniffi/src/uniffi/types/transaction.rs new file mode 100644 index 0000000..cf52157 --- /dev/null +++ b/crates/uniffi/src/uniffi/types/transaction.rs @@ -0,0 +1,127 @@ +// Transaction types +use super::core::*; + +#[derive(Debug, Clone)] +pub enum CallType { + Execute, + ExecuteFromOutside, +} + +impl From for CallType { + fn from(val: torii_proto::CallType) -> Self { + match val { + torii_proto::CallType::Execute => CallType::Execute, + torii_proto::CallType::ExecuteFromOutside => CallType::ExecuteFromOutside, + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionCall { + pub contract_address: FieldElement, + pub entrypoint: String, + pub calldata: Vec, + pub call_type: CallType, + pub caller_address: FieldElement, +} + +impl From for TransactionCall { + fn from(val: torii_proto::TransactionCall) -> Self { + TransactionCall { + contract_address: felt_to_field_element(val.contract_address), + entrypoint: val.entrypoint, + calldata: val.calldata.into_iter().map(felt_to_field_element).collect(), + call_type: val.call_type.into(), + caller_address: felt_to_field_element(val.caller_address), + } + } +} + +#[derive(Debug, Clone)] +pub struct Transaction { + pub transaction_hash: FieldElement, + pub sender_address: FieldElement, + pub calldata: Vec, + pub max_fee: FieldElement, + pub signature: Vec, + pub nonce: FieldElement, + pub block_number: u64, + pub transaction_type: String, + pub block_timestamp: u64, + pub calls: Vec, + pub unique_models: Vec, +} + +impl From for Transaction { + fn from(val: torii_proto::Transaction) -> Self { + Transaction { + transaction_hash: felt_to_field_element(val.transaction_hash), + sender_address: felt_to_field_element(val.sender_address), + calldata: val.calldata.into_iter().map(felt_to_field_element).collect(), + max_fee: felt_to_field_element(val.max_fee), + signature: val.signature.into_iter().map(felt_to_field_element).collect(), + nonce: felt_to_field_element(val.nonce), + block_number: val.block_number, + transaction_type: val.transaction_type, + block_timestamp: val.block_timestamp.timestamp() as u64, + calls: val.calls.into_iter().map(|c| c.into()).collect(), + unique_models: val.unique_models.into_iter().map(felt_to_field_element).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionFilter { + pub transaction_hashes: Vec, + pub caller_addresses: Vec, + pub contract_addresses: Vec, + pub entrypoints: Vec, + pub model_selectors: Vec, + pub from_block: Option, + pub to_block: Option, +} + +impl From for torii_proto::TransactionFilter { + fn from(val: TransactionFilter) -> Self { + torii_proto::TransactionFilter { + transaction_hashes: val + .transaction_hashes + .into_iter() + .map(|h| field_element_to_felt(&h).unwrap()) + .collect(), + caller_addresses: val + .caller_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + entrypoints: val.entrypoints, + model_selectors: val + .model_selectors + .into_iter() + .map(|s| field_element_to_felt(&s).unwrap()) + .collect(), + from_block: val.from_block, + to_block: val.to_block, + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionQuery { + pub filter: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::TransactionQuery { + fn from(val: TransactionQuery) -> Self { + torii_proto::TransactionQuery { + filter: val.filter.map(|f| f.into()), + pagination: val.pagination.into(), + } + } +} diff --git a/crates/uniffi/uniffi.toml b/crates/uniffi/uniffi.toml new file mode 100644 index 0000000..4ffeea7 --- /dev/null +++ b/crates/uniffi/uniffi.toml @@ -0,0 +1,22 @@ +# UniFFI Configuration for Dojo +# This file configures language-specific bindings generation + +[bindings.kotlin] +package_name = "com.dojoengine.dojo" +cdylib_name = "dojo_uniffi" +generate_immutable_records = true + +[bindings.swift] +module_name = "DojoEngine" +cdylib_name = "dojo_uniffi" +generate_immutable_records = true +# Swift-specific naming conventions +omit_argument_labels = false + +[bindings.python] +module_name = "dojo" +cdylib_name = "dojo_uniffi" + +[bindings.ruby] +module_name = "Dojo" +cdylib_name = "dojo_uniffi" \ No newline at end of file diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml index e922b16..c74eab4 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/wasm/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasm" +name = "dojo-wasm" version.workspace = true edition.workspace = true diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 6abdd2b..d401a76 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -30,17 +30,14 @@ use wasm_bindgen::prelude::*; mod types; use types::{ - AchievementProgression, AchievementQuery, Achievements, Activities, Activity, AggregationEntry, - Aggregations, BlockId, Call, Calls, Clause, ClientConfig, Contract, Contracts, Controllers, - Entities, Entity, KeysClauses, Message, PlayerAchievementQuery, PlayerAchievements, Query, - Signature, Token, TokenBalance, TokenBalances, TokenContracts, TokenTransfer, TokenTransfers, - Tokens, Transaction, Transactions, WasmU256, -}; - -use crate::types::{ - Account, ActivityQuery, AggregationQuery, ContractQuery, ControllerQuery, Provider, - Subscription, TokenBalanceQuery, TokenContractQuery, TokenQuery, TokenTransferQuery, - ToriiClient, TransactionFilter, TransactionQuery, + Account, AchievementProgression, AchievementQuery, Achievements, Activities, Activity, + ActivityQuery, AggregationEntry, AggregationQuery, Aggregations, BlockId, Call, Calls, Clause, + ClientConfig, Contract, ContractQuery, Contracts, ControllerQuery, Controllers, Entities, + Entity, KeysClauses, Message, PlayerAchievementQuery, PlayerAchievements, Provider, Query, + Signature, Subscription, Token, TokenBalance, TokenBalanceQuery, TokenBalances, + TokenContractQuery, TokenContracts, TokenQuery, TokenTransfer, TokenTransferQuery, + TokenTransfers, Tokens, ToriiClient, Transaction, TransactionFilter, TransactionQuery, + Transactions, WasmU256, }; const JSON_COMPAT_SERIALIZER: serde_wasm_bindgen::Serializer = diff --git a/example/main b/example/main deleted file mode 100755 index d6f1d34..0000000 Binary files a/example/main and /dev/null differ diff --git a/examples/c/README.md b/examples/c/README.md new file mode 100644 index 0000000..b2a3f91 --- /dev/null +++ b/examples/c/README.md @@ -0,0 +1,44 @@ +# Dojo C Example + +This example demonstrates how to use the Dojo C bindings to interact with a Dojo world. + +## Prerequisites + +1. Build the Dojo C library: + ```bash + cargo build --release -p dojo-c + ``` + +2. Make sure you have a local Katana node running with a deployed Dojo world. + +## Building + +```bash +./build.sh +``` + +Or manually: +```bash +gcc -o main main.c \ + -I../../ \ + -L../../target/release \ + -ldojo_c \ + -Wl,-rpath,../../target/release +``` + +## Running + +```bash +./main +``` + +## Features + +This example demonstrates: +- Connecting to a Torii indexer +- Creating and connecting a controller account (Cartridge) +- Executing transactions through the controller +- Fetching entities from the world +- Subscribing to entity updates +- Using the Starknet account abstraction + diff --git a/examples/c/build.sh b/examples/c/build.sh new file mode 100755 index 0000000..c5a322f --- /dev/null +++ b/examples/c/build.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# Get the repository root (2 levels up from this script) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" + +cd "$REPO_ROOT" + +# Check if library exists +if [ ! -f "target/release/libdojo_c.dylib" ] && [ ! -f "target/release/libdojo_c.so" ]; then + echo "Error: Library not found. Building it now..." + cargo build --release -p dojo-c +fi + +# Determine library extension based on platform +if [[ "$OSTYPE" == "darwin"* ]]; then + LIB_EXT="dylib" +elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + LIB_EXT="so" +else + echo "Error: Unsupported platform: $OSTYPE" + exit 1 +fi + +echo "Building C example..." + +cd examples/c + +gcc -o main main.c \ + -I"$REPO_ROOT" \ + -L"$REPO_ROOT/target/release" \ + -ldojo_c \ + -Wl,-rpath,"$REPO_ROOT/target/release" + +echo "✓ Build successful!" +echo "" +echo "Run with: ./main" + diff --git a/example/main.c b/examples/c/main.c similarity index 100% rename from example/main.c rename to examples/c/main.c diff --git a/example/main.dSYM/Contents/Info.plist b/examples/c/main.dSYM/Contents/Info.plist similarity index 100% rename from example/main.dSYM/Contents/Info.plist rename to examples/c/main.dSYM/Contents/Info.plist diff --git a/example/main.dSYM/Contents/Resources/DWARF/main b/examples/c/main.dSYM/Contents/Resources/DWARF/main similarity index 100% rename from example/main.dSYM/Contents/Resources/DWARF/main rename to examples/c/main.dSYM/Contents/Resources/DWARF/main diff --git a/example/main.dSYM/Contents/Resources/Relocations/aarch64/main.yml b/examples/c/main.dSYM/Contents/Resources/Relocations/aarch64/main.yml similarity index 100% rename from example/main.dSYM/Contents/Resources/Relocations/aarch64/main.yml rename to examples/c/main.dSYM/Contents/Resources/Relocations/aarch64/main.yml diff --git a/examples/kotlin/FetchEntities.kt b/examples/kotlin/FetchEntities.kt new file mode 100644 index 0000000..e7f1376 --- /dev/null +++ b/examples/kotlin/FetchEntities.kt @@ -0,0 +1,95 @@ +/** + * Example: Fetch entities from a Torii server + * + * This example demonstrates how to use the Dojo Kotlin bindings to: + * 1. Connect to a Torii server + * 2. Query entities with pagination + * 3. Display entity data + */ + +package com.dojoengine.examples + +import com.dojoengine.dojo.* + +fun fetchEntities(toriiUrl: String, worldAddress: String) { + println("Connecting to Torii at $toriiUrl...") + + // Create a client with default configuration (4MB max message size) + val client = ToriiClient(toriiUrl) + + println("✓ Connected successfully!") + + // Create a query to fetch entities + val query = Query( + worldAddresses = emptyList(), + pagination = Pagination( + cursor = null, // Start from beginning + limit = 10u, // Fetch 10 entities + direction = PaginationDirection.FORWARD, + orderBy = emptyList() // No specific ordering + ), + clause = null, // No filtering clause + noHashedKeys = false, + models = emptyList(), // Empty means all models + historical = false + ) + + println("\nFetching entities...") + val page = client.entities(query) + + println("\n✓ Retrieved ${page.items.size} entities") + + if (page.nextCursor != null) { + val cursorPreview = page.nextCursor.take(20) + println("Next cursor available: $cursorPreview...") + } else { + println("No more pages available") + } + + // Display entity information + page.items.forEachIndexed { i, entity -> + println("\n${"=".repeat(60)}") + println("Entity ${i + 1}:") + println(" World Address: ${entity.worldAddress}") + println(" Hashed Keys: ${entity.hashedKeys}") + println(" Created At: ${entity.createdAt}") + println(" Updated At: ${entity.updatedAt}") + println(" Executed At: ${entity.executedAt}") + println(" Models: ${entity.models.size} model(s)") + + // Display model information + entity.models.forEachIndexed { j, model -> + println("\n Model ${j + 1}: ${model.name}") + println(" Children: ${model.children.size} field(s)") + + // Show first 3 fields + model.children.take(3).forEach { child -> + println(" - ${child.name} (key=${child.key})") + } + + if (model.children.size > 3) { + println(" ... and ${model.children.size - 3} more") + } + } + } + + println("\n${"=".repeat(60)}\n") +} + +fun main(args: Array) { + val toriiUrl = args.getOrNull(0) ?: "http://localhost:8080" + val worldAddress = args.getOrNull(1) ?: "0x0" + + println("Dojo Kotlin Example: Fetch Entities") + println("====================================\n") + + try { + fetchEntities(toriiUrl, worldAddress) + } catch (e: Exception) { + println("\n❌ Error: ${e.message}") + println("\nUsage: kotlin FetchEntities.kt [torii_url] [world_address]") + println("Example: kotlin FetchEntities.kt http://localhost:8080 0x1234...") + System.exit(1) + } +} + diff --git a/examples/kotlin/README.md b/examples/kotlin/README.md new file mode 100644 index 0000000..1ecfa75 --- /dev/null +++ b/examples/kotlin/README.md @@ -0,0 +1,172 @@ +# Dojo Kotlin Examples + +This directory contains example code for Kotlin bindings (currently non-functional). + +## 🚧 Current Status: Not Working + +The Kotlin bindings **do not currently compile** due to limitations in UniFFI v0.30's Kotlin generator when handling: +- Complex recursive types (`Clause`, `Primitive`, `Ty`, etc.) +- Generic types with custom converters +- Nested enum variants + +The generated `dojo.kt` file itself has type errors that prevent compilation. This is a known limitation of UniFFI's Kotlin backend, not an issue with our implementation. + +## ✅ Working Alternatives + +**For full functionality, please use:** +- ✅ **Swift bindings** (`examples/swift/`) - Fully functional +- ✅ **Python bindings** (`examples/python/`) - Fully functional + +Both Swift and Python bindings work perfectly with the synchronous client and all query types. + +## Future Support + +Kotlin bindings will become functional when: +1. UniFFI's Kotlin generator improves support for complex types (expected in future versions) +2. OR we simplify the type system (would limit functionality) + +## Prerequisites + +- **Kotlin**: Install via Homebrew: + ```bash + brew install kotlin + ``` + +- **Dojo Library**: Build the Dojo library: + ```bash + cargo build --release -p dojo-uniffi + ``` + +- **Kotlin Bindings**: Generate the Kotlin bindings: + ```bash + ./target/release/uniffi-bindgen-kotlin + ``` + +## Examples + +### Simple Test + +Basic test to verify Kotlin bindings work. + +**Run:** +```bash +chmod +x examples/kotlin/run_simple_test.sh +./examples/kotlin/run_simple_test.sh +``` + +**With custom Torii URL:** +```bash +./examples/kotlin/run_simple_test.sh http://localhost:8080 +``` + +**Features demonstrated:** +- Creating a Torii client connection +- Basic error handling + +### Fetch Entities (Limited) + +Full query example - currently has type generation issues with complex recursive types. + +```bash +./examples/kotlin/run_fetch_entities.sh +``` + +Note: This example demonstrates the intended API but won't compile until UniFFI's Kotlin generator better supports recursive types. + +## Project Structure + +``` +examples/kotlin/ +├── FetchEntities.kt # Fetch entities example +├── run_fetch_entities.sh # Build and run script +└── README.md # This file +``` + +## How It Works + +1. The run script copies the Kotlin bindings and native library to a build directory +2. Compiles all Kotlin files into a JAR +3. Sets up the library path for the native library (libdojo_uniffi.dylib) +4. Runs the example with the specified parameters + +## Code Example + +```kotlin +import com.dojoengine.dojo.* + +// Create a client +val client = ToriiClient("http://localhost:8080") + +// Create a query +val query = Query( + worldAddresses = emptyList(), + pagination = Pagination( + cursor = null, + limit = 10u, + direction = PaginationDirection.FORWARD, + orderBy = emptyList() + ), + clause = null, + noHashedKeys = false, + models = emptyList(), + historical = false +) + +// Fetch entities +val page = client.entities(query) + +// Process results +page.items.forEach { entity -> + println("Entity: ${entity.hashedKeys}") +} +``` + +## Error Handling + +All Dojo operations can throw `DojoException`: + +```kotlin +try { + val client = ToriiClient(toriiUrl) + val page = client.entities(query) +} catch (e: DojoException) { + println("Error: ${e.message}") +} +``` + +## Building Manually + +If you prefer to compile manually: + +```bash +cd examples/kotlin +mkdir -p build +cp -r ../../bindings/kotlin/* build/ +cp ../../target/release/libdojo_uniffi.dylib build/ +cp FetchEntities.kt build/ +cd build +kotlinc *.kt -include-runtime -d FetchEntities.jar +java -Djava.library.path=. -jar FetchEntities.jar +``` + +## Troubleshooting + +**"kotlinc not found"** +- Install Kotlin: `brew install kotlin` + +**"Library not found"** +- Build the library: `cargo build --release -p dojo-uniffi` + +**"Kotlin bindings not found"** +- Generate bindings: `./target/release/uniffi-bindgen-kotlin` + +**"java.lang.UnsatisfiedLinkError"** +- Make sure the native library is in the same directory as the JAR +- Check that `DYLD_LIBRARY_PATH` is set correctly (done automatically by the run script) + +## Additional Resources + +- [Dojo Book](https://book.dojoengine.org/) +- [Kotlin Documentation](https://kotlinlang.org/docs/home.html) +- [Torii Documentation](https://book.dojoengine.org/toolchain/torii/) + diff --git a/examples/kotlin/SimpleTest.kt b/examples/kotlin/SimpleTest.kt new file mode 100644 index 0000000..b917c5f --- /dev/null +++ b/examples/kotlin/SimpleTest.kt @@ -0,0 +1,47 @@ +/** + * Simple test to verify Kotlin bindings work + * + * This demonstrates basic connectivity to a Torii server. + * Full examples with complex queries will work once the UniFFI + * Kotlin generator better supports recursive types. + */ + +package com.dojoengine.examples + +import com.dojoengine.dojo.* + +fun simpleTest(toriiUrl: String) { + println("Testing Kotlin bindings...") + println("Torii URL: $toriiUrl") + + try { + // Create a client with default configuration + val client = ToriiClient(toriiUrl) + + println("✓ Client created successfully!") + println("✓ Kotlin bindings are working!") + + // Note: Full query examples will be available once UniFFI better supports + // complex recursive types in Kotlin bindings + println("\nNote: Complex queries with Clause, Primitive types etc. are currently") + println("limited by UniFFI's Kotlin generator for recursive types.") + println("Consider using Swift or Python bindings for full functionality.") + + } catch (e: DojoException.ConnectionError) { + println("✗ Connection error: ${e.message}") + println(" Make sure Torii server is running at $toriiUrl") + } catch (e: Exception) { + println("✗ Error: ${e.message}") + e.printStackTrace() + } +} + +fun main(args: Array) { + val toriiUrl = args.getOrNull(0) ?: "http://localhost:8080" + + println("Dojo Kotlin Simple Test") + println("========================\n") + + simpleTest(toriiUrl) +} + diff --git a/examples/kotlin/build-simple/SimpleTest.kt b/examples/kotlin/build-simple/SimpleTest.kt new file mode 100644 index 0000000..b917c5f --- /dev/null +++ b/examples/kotlin/build-simple/SimpleTest.kt @@ -0,0 +1,47 @@ +/** + * Simple test to verify Kotlin bindings work + * + * This demonstrates basic connectivity to a Torii server. + * Full examples with complex queries will work once the UniFFI + * Kotlin generator better supports recursive types. + */ + +package com.dojoengine.examples + +import com.dojoengine.dojo.* + +fun simpleTest(toriiUrl: String) { + println("Testing Kotlin bindings...") + println("Torii URL: $toriiUrl") + + try { + // Create a client with default configuration + val client = ToriiClient(toriiUrl) + + println("✓ Client created successfully!") + println("✓ Kotlin bindings are working!") + + // Note: Full query examples will be available once UniFFI better supports + // complex recursive types in Kotlin bindings + println("\nNote: Complex queries with Clause, Primitive types etc. are currently") + println("limited by UniFFI's Kotlin generator for recursive types.") + println("Consider using Swift or Python bindings for full functionality.") + + } catch (e: DojoException.ConnectionError) { + println("✗ Connection error: ${e.message}") + println(" Make sure Torii server is running at $toriiUrl") + } catch (e: Exception) { + println("✗ Error: ${e.message}") + e.printStackTrace() + } +} + +fun main(args: Array) { + val toriiUrl = args.getOrNull(0) ?: "http://localhost:8080" + + println("Dojo Kotlin Simple Test") + println("========================\n") + + simpleTest(toriiUrl) +} + diff --git a/examples/kotlin/build-simple/dojo.kt b/examples/kotlin/build-simple/dojo.kt new file mode 100644 index 0000000..360551d --- /dev/null +++ b/examples/kotlin/build-simple/dojo.kt @@ -0,0 +1,8423 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +@file:Suppress("NAME_SHADOWING") + +package com.dojoengine.dojo + +// Common helper code. +// +// Ideally this would live in a separate .kt file where it can be unittested etc +// in isolation, and perhaps even published as a re-useable package. +// +// However, it's important that the details of how this helper code works (e.g. the +// way that different builtin types are passed across the FFI) exactly match what's +// expected by the Rust code on the other side of the interface. In practice right +// now that means coming from the exact some version of `uniffi` that was used to +// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin +// helpers directly inline like we're doing here. + +import com.sun.jna.Library +import com.sun.jna.IntegerType +import com.sun.jna.Native +import com.sun.jna.Pointer +import com.sun.jna.Structure +import com.sun.jna.Callback +import com.sun.jna.ptr.* +import java.nio.ByteBuffer +import java.nio.ByteOrder +import java.nio.CharBuffer +import java.nio.charset.CodingErrorAction +import java.util.concurrent.atomic.AtomicLong +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicBoolean + +// This is a helper for safely working with byte buffers returned from the Rust code. +// A rust-owned buffer is represented by its capacity, its current length, and a +// pointer to the underlying data. + +/** + * @suppress + */ +@Structure.FieldOrder("capacity", "len", "data") +open class RustBuffer : Structure() { + // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values. + // When dealing with these fields, make sure to call `toULong()`. + @JvmField var capacity: Long = 0 + @JvmField var len: Long = 0 + @JvmField var data: Pointer? = null + + class ByValue: RustBuffer(), Structure.ByValue + class ByReference: RustBuffer(), Structure.ByReference + + internal fun setValue(other: RustBuffer) { + capacity = other.capacity + len = other.len + data = other.data + } + + companion object { + internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status -> + // Note: need to convert the size to a `Long` value to make this work with JVM. + UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc(size.toLong(), status) + }.also { + if(it.data == null) { + throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") + } + } + + internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue { + var buf = RustBuffer.ByValue() + buf.capacity = capacity.toLong() + buf.len = len.toLong() + buf.data = data + return buf + } + + internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status -> + UniffiLib.ffi_dojo_uniffi_rustbuffer_free(buf, status) + } + } + + @Suppress("TooGenericExceptionThrown") + fun asByteBuffer() = + this.data?.getByteBuffer(0, this.len.toLong())?.also { + it.order(ByteOrder.BIG_ENDIAN) + } +} + +// This is a helper for safely passing byte references into the rust code. +// It's not actually used at the moment, because there aren't many things that you +// can take a direct pointer to in the JVM, and if we're going to copy something +// then we might as well copy it into a `RustBuffer`. But it's here for API +// completeness. + +@Structure.FieldOrder("len", "data") +internal open class ForeignBytes : Structure() { + @JvmField var len: Int = 0 + @JvmField var data: Pointer? = null + + class ByValue : ForeignBytes(), Structure.ByValue +} +/** + * The FfiConverter interface handles converter types to and from the FFI + * + * All implementing objects should be public to support external types. When a + * type is external we need to import it's FfiConverter. + * + * @suppress + */ +public interface FfiConverter { + // Convert an FFI type to a Kotlin type + fun lift(value: FfiType): KotlinType + + // Convert an Kotlin type to an FFI type + fun lower(value: KotlinType): FfiType + + // Read a Kotlin type from a `ByteBuffer` + fun read(buf: ByteBuffer): KotlinType + + // Calculate bytes to allocate when creating a `RustBuffer` + // + // This must return at least as many bytes as the write() function will + // write. It can return more bytes than needed, for example when writing + // Strings we can't know the exact bytes needed until we the UTF-8 + // encoding, so we pessimistically allocate the largest size possible (3 + // bytes per codepoint). Allocating extra bytes is not really a big deal + // because the `RustBuffer` is short-lived. + fun allocationSize(value: KotlinType): ULong + + // Write a Kotlin type to a `ByteBuffer` + fun write(value: KotlinType, buf: ByteBuffer) + + // Lower a value into a `RustBuffer` + // + // This method lowers a value into a `RustBuffer` rather than the normal + // FfiType. It's used by the callback interface code. Callback interface + // returns are always serialized into a `RustBuffer` regardless of their + // normal FFI type. + fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue { + val rbuf = RustBuffer.alloc(allocationSize(value)) + try { + val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also { + it.order(ByteOrder.BIG_ENDIAN) + } + write(value, bbuf) + rbuf.writeField("len", bbuf.position().toLong()) + return rbuf + } catch (e: Throwable) { + RustBuffer.free(rbuf) + throw e + } + } + + // Lift a value from a `RustBuffer`. + // + // This here mostly because of the symmetry with `lowerIntoRustBuffer()`. + // It's currently only used by the `FfiConverterRustBuffer` class below. + fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType { + val byteBuf = rbuf.asByteBuffer()!! + try { + val item = read(byteBuf) + if (byteBuf.hasRemaining()) { + throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!") + } + return item + } finally { + RustBuffer.free(rbuf) + } + } +} + +/** + * FfiConverter that uses `RustBuffer` as the FfiType + * + * @suppress + */ +public interface FfiConverterRustBuffer: FfiConverter { + override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value) + override fun lower(value: KotlinType) = lowerIntoRustBuffer(value) +} +// A handful of classes and functions to support the generated data structures. +// This would be a good candidate for isolating in its own ffi-support lib. + +internal const val UNIFFI_CALL_SUCCESS = 0.toByte() +internal const val UNIFFI_CALL_ERROR = 1.toByte() +internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte() + +@Structure.FieldOrder("code", "error_buf") +internal open class UniffiRustCallStatus : Structure() { + @JvmField var code: Byte = 0 + @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue() + + class ByValue: UniffiRustCallStatus(), Structure.ByValue + + fun isSuccess(): Boolean { + return code == UNIFFI_CALL_SUCCESS + } + + fun isError(): Boolean { + return code == UNIFFI_CALL_ERROR + } + + fun isPanic(): Boolean { + return code == UNIFFI_CALL_UNEXPECTED_ERROR + } + + companion object { + fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue { + val callStatus = UniffiRustCallStatus.ByValue() + callStatus.code = code + callStatus.error_buf = errorBuf + return callStatus + } + } +} + +class InternalException(message: String) : kotlin.Exception(message) + +/** + * Each top-level error class has a companion object that can lift the error from the call status's rust buffer + * + * @suppress + */ +interface UniffiRustCallStatusErrorHandler { + fun lift(error_buf: RustBuffer.ByValue): E; +} + +// Helpers for calling Rust +// In practice we usually need to be synchronized to call this safely, so it doesn't +// synchronize itself + +// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err +private inline fun uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler, callback: (UniffiRustCallStatus) -> U): U { + var status = UniffiRustCallStatus() + val return_value = callback(status) + uniffiCheckCallStatus(errorHandler, status) + return return_value +} + +// Check UniffiRustCallStatus and throw an error if the call wasn't successful +private fun uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler, status: UniffiRustCallStatus) { + if (status.isSuccess()) { + return + } else if (status.isError()) { + throw errorHandler.lift(status.error_buf) + } else if (status.isPanic()) { + // when the rust code sees a panic, it tries to construct a rustbuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if (status.error_buf.len > 0) { + throw InternalException(FfiConverterString.lift(status.error_buf)) + } else { + throw InternalException("Rust panic") + } + } else { + throw InternalException("Unknown rust call status: $status.code") + } +} + +/** + * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR + * + * @suppress + */ +object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): InternalException { + RustBuffer.free(error_buf) + return InternalException("Unexpected CALL_ERROR") + } +} + +// Call a rust function that returns a plain value +private inline fun uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U { + return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback) +} + +internal inline fun uniffiTraitInterfaceCall( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } +} + +internal inline fun uniffiTraitInterfaceCallWithError( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, + lowerError: (E) -> RustBuffer.ByValue +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + if (e is E) { + callStatus.code = UNIFFI_CALL_ERROR + callStatus.error_buf = lowerError(e) + } else { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } + } +} +// Initial value and increment amount for handles. +// These ensure that Kotlin-generated handles always have the lowest bit set +private const val UNIFFI_HANDLEMAP_INITIAL = 1.toLong() +private const val UNIFFI_HANDLEMAP_DELTA = 2.toLong() + +// Map handles to objects +// +// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code. +internal class UniffiHandleMap { + private val map = ConcurrentHashMap() + // Start + private val counter = java.util.concurrent.atomic.AtomicLong(UNIFFI_HANDLEMAP_INITIAL) + + val size: Int + get() = map.size + + // Insert a new object into the handle map and get a handle for it + fun insert(obj: T): Long { + val handle = counter.getAndAdd(UNIFFI_HANDLEMAP_DELTA) + map.put(handle, obj) + return handle + } + + // Clone a handle, creating a new one + fun clone(handle: Long): Long { + val obj = map.get(handle) ?: throw InternalException("UniffiHandleMap.clone: Invalid handle") + return insert(obj) + } + + // Get an object from the handle map + fun get(handle: Long): T { + return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle") + } + + // Remove an entry from the handlemap and get the Kotlin object back + fun remove(handle: Long): T { + return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle") + } +} + +// Contains loading, initialization code, +// and the FFI Function declarations in a com.sun.jna.Library. +@Synchronized +private fun findLibraryName(componentName: String): String { + val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride") + if (libOverride != null) { + return libOverride + } + return "dojo_uniffi" +} + +// Define FFI callback types +internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback { + fun callback(`data`: Long,`pollResult`: Byte,) +} +internal interface UniffiForeignFutureDroppedCallback : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceClone : com.sun.jna.Callback { + fun callback(`handle`: Long,) + : Long +} +@Structure.FieldOrder("handle", "free") +internal open class UniffiForeignFutureDroppedCallbackStruct( + @JvmField internal var `handle`: Long = 0.toLong(), + @JvmField internal var `free`: UniffiForeignFutureDroppedCallback? = null, +) : Structure() { + class UniffiByValue( + `handle`: Long = 0.toLong(), + `free`: UniffiForeignFutureDroppedCallback? = null, + ): UniffiForeignFutureDroppedCallbackStruct(`handle`,`free`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureDroppedCallbackStruct) { + `handle` = other.`handle` + `free` = other.`free` + } + +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF32( + @JvmField internal var `returnValue`: Float = 0.0f, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Float = 0.0f, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF64( + @JvmField internal var `returnValue`: Double = 0.0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Double = 0.0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultRustBuffer( + @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultRustBuffer) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultRustBuffer.UniffiByValue,) +} +@Structure.FieldOrder("callStatus") +internal open class UniffiForeignFutureResultVoid( + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultVoid(`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultVoid) { + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultVoid.UniffiByValue,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEntityUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEntityUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEntityUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEventUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEventUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEventUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTransactionUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTransactionUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTransactionUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} + +// A JNA Library to expose the extern-C FFI definitions. +// This is an implementation detail which will be called internally by the public API. + +// For large crates we prevent `MethodTooLargeException` (see #2340) +// N.B. the name of the extension is very misleading, since it is +// rather `InterfaceTooLargeException`, caused by too many methods +// in the interface for large crates. +// +// By splitting the otherwise huge interface into two parts +// * UniffiLib (this) +// * IntegrityCheckingUniffiLib +// And all checksum methods are put into `IntegrityCheckingUniffiLib` +// we allow for ~2x as many methods in the UniffiLib interface. +// +// Note: above all written when we used JNA's `loadIndirect` etc. +// We now use JNA's "direct mapping" - unclear if same considerations apply exactly. +internal object IntegrityCheckingUniffiLib { + init { + Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCheckContractApiVersion(this) + uniffiCheckApiChecksums(this) + } + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_activities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_controllers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_entities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_sql( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_tokens( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_transactions( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_worlds( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error( + ): Short + external fun ffi_dojo_uniffi_uniffi_contract_version( + ): Int + + +} + +internal object UniffiLib { + + // The Cleaner for the whole library + internal val CLEANER: UniffiCleaner by lazy { + UniffiCleaner.create() + } + + + init { + Native.register(UniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCallbackInterfaceEntityUpdateCallback.register(this) + uniffiCallbackInterfaceEventUpdateCallback.register(this) + uniffiCallbackInterfaceTokenBalanceUpdateCallback.register(this) + uniffiCallbackInterfaceTokenUpdateCallback.register(this) + uniffiCallbackInterfaceTransactionUpdateCallback.register(this) + + } + external fun uniffi_dojo_uniffi_fn_clone_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_free_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new(`toriiUrl`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config(`toriiUrl`: RustBuffer.ByValue,`maxMessageSize`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_activities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_aggregations(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription(`ptr`: Long,`subscriptionId`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_method_toriiclient_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_controllers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_entities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_event_messages(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message(`ptr`: Long,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch(`ptr`: Long,`messages`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_sql(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates(`ptr`: Long,`clause`: RustBuffer.ByValue,`worldAddresses`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates(`ptr`: Long,`keys`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`accountAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates(`ptr`: Long,`filter`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_balances(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_tokens(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_transactions(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_worlds(`ptr`: Long,`worldAddresses`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEntityUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEventUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTransactionUpdateCallback, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Float +external fun ffi_dojo_uniffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Double +external fun ffi_dojo_uniffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit + + +} + +private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) { + // Get the bindings contract version from our ComponentInterface + val bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + val scaffolding_contract_version = lib.ffi_dojo_uniffi_uniffi_contract_version() + if (bindings_contract_version != scaffolding_contract_version) { + throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project") + } +} +@Suppress("UNUSED_PARAMETER") +private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements() != 45327.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities() != 43349.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations() != 12858.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription() != 31182.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts() != 1861.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers() != 55573.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities() != 50647.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages() != 35425.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements() != 61773.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message() != 30179.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch() != 2146.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql() != 38286.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events() != 44694.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates() != 17350.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates() != 63983.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates() != 26741.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates() != 54836.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates() != 10040.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances() != 1716.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts() != 49563.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers() != 10363.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens() != 10630.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions() != 46460.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds() != 23254.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new() != 18057.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config() != 42232.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update() != 15850.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error() != 340.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update() != 13627.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error() != 61050.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update() != 10763.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error() != 46610.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update() != 40037.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error() != 14408.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update() != 11896.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error() != 18113.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +/** + * @suppress + */ +public fun uniffiEnsureInitialized() { + IntegrityCheckingUniffiLib + // UniffiLib() initialized as objects are used, but we still need to explicitly + // reference it so initialization across crates works as expected. + UniffiLib +} + +// Async support + +// Public interface members begin here. + + +// Interface implemented by anything that can contain an object reference. +// +// Such types expose a `destroy()` method that must be called to cleanly +// dispose of the contained objects. Failure to call this method may result +// in memory leaks. +// +// The easiest way to ensure this method is called is to use the `.use` +// helper method to execute a block and destroy the object at the end. +interface Disposable { + fun destroy() + companion object { + fun destroy(vararg args: Any?) { + for (arg in args) { + when (arg) { + is Disposable -> arg.destroy() + is ArrayList<*> -> { + for (idx in arg.indices) { + val element = arg[idx] + if (element is Disposable) { + element.destroy() + } + } + } + is Map<*, *> -> { + for (element in arg.values) { + if (element is Disposable) { + element.destroy() + } + } + } + is Iterable<*> -> { + for (element in arg) { + if (element is Disposable) { + element.destroy() + } + } + } + } + } + } + } +} + +/** + * @suppress + */ +inline fun T.use(block: (T) -> R) = + try { + block(this) + } finally { + try { + // N.B. our implementation is on the nullable type `Disposable?`. + this?.destroy() + } catch (e: Throwable) { + // swallow + } + } + +/** + * Placeholder object used to signal that we're constructing an interface with a FFI handle. + * + * This is the first argument for interface constructors that input a raw handle. It exists is that + * so we can avoid signature conflicts when an interface has a regular constructor than inputs a + * Long. + * + * @suppress + * */ +object UniffiWithHandle + +/** + * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly. + * + * @suppress + * */ +object NoHandle// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +internal const val IDX_CALLBACK_FREE = 0 +// Callback return codes +internal const val UNIFFI_CALLBACK_SUCCESS = 0 +internal const val UNIFFI_CALLBACK_ERROR = 1 +internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 + +/** + * @suppress + */ +public abstract class FfiConverterCallbackInterface: FfiConverter { + internal val handleMap = UniffiHandleMap() + + internal fun drop(handle: Long) { + handleMap.remove(handle) + } + + override fun lift(value: Long): CallbackInterface { + return handleMap.get(value) + } + + override fun read(buf: ByteBuffer) = lift(buf.getLong()) + + override fun lower(value: CallbackInterface) = handleMap.insert(value) + + override fun allocationSize(value: CallbackInterface) = 8UL + + override fun write(value: CallbackInterface, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} +/** + * The cleaner interface for Object finalization code to run. + * This is the entry point to any implementation that we're using. + * + * The cleaner registers objects and returns cleanables, so now we are + * defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the + * different implmentations available at compile time. + * + * @suppress + */ +interface UniffiCleaner { + interface Cleanable { + fun clean() + } + + fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable + + companion object +} + +// The fallback Jna cleaner, which is available for both Android, and the JVM. +private class UniffiJnaCleaner : UniffiCleaner { + private val cleaner = com.sun.jna.internal.Cleaner.getCleaner() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + UniffiJnaCleanable(cleaner.register(value, cleanUpTask)) +} + +private class UniffiJnaCleanable( + private val cleanable: com.sun.jna.internal.Cleaner.Cleanable, +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + + +// We decide at uniffi binding generation time whether we were +// using Android or not. +// There are further runtime checks to chose the correct implementation +// of the cleaner. +private fun UniffiCleaner.Companion.create(): UniffiCleaner = + try { + // For safety's sake: if the library hasn't been run in android_cleaner = true + // mode, but is being run on Android, then we still need to think about + // Android API versions. + // So we check if java.lang.ref.Cleaner is there, and use that… + java.lang.Class.forName("java.lang.ref.Cleaner") + JavaLangRefCleaner() + } catch (e: ClassNotFoundException) { + // … otherwise, fallback to the JNA cleaner. + UniffiJnaCleaner() + } + +private class JavaLangRefCleaner : UniffiCleaner { + val cleaner = java.lang.ref.Cleaner.create() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + JavaLangRefCleanable(cleaner.register(value, cleanUpTask)) +} + +private class JavaLangRefCleanable( + val cleanable: java.lang.ref.Cleaner.Cleanable +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + +/** + * @suppress + */ +public object FfiConverterUByte: FfiConverter { + override fun lift(value: Byte): UByte { + return value.toUByte() + } + + override fun read(buf: ByteBuffer): UByte { + return lift(buf.get()) + } + + override fun lower(value: UByte): Byte { + return value.toByte() + } + + override fun allocationSize(value: UByte) = 1UL + + override fun write(value: UByte, buf: ByteBuffer) { + buf.put(value.toByte()) + } +} + +/** + * @suppress + */ +public object FfiConverterByte: FfiConverter { + override fun lift(value: Byte): Byte { + return value + } + + override fun read(buf: ByteBuffer): Byte { + return buf.get() + } + + override fun lower(value: Byte): Byte { + return value + } + + override fun allocationSize(value: Byte) = 1UL + + override fun write(value: Byte, buf: ByteBuffer) { + buf.put(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUShort: FfiConverter { + override fun lift(value: Short): UShort { + return value.toUShort() + } + + override fun read(buf: ByteBuffer): UShort { + return lift(buf.getShort()) + } + + override fun lower(value: UShort): Short { + return value.toShort() + } + + override fun allocationSize(value: UShort) = 2UL + + override fun write(value: UShort, buf: ByteBuffer) { + buf.putShort(value.toShort()) + } +} + +/** + * @suppress + */ +public object FfiConverterShort: FfiConverter { + override fun lift(value: Short): Short { + return value + } + + override fun read(buf: ByteBuffer): Short { + return buf.getShort() + } + + override fun lower(value: Short): Short { + return value + } + + override fun allocationSize(value: Short) = 2UL + + override fun write(value: Short, buf: ByteBuffer) { + buf.putShort(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUInt: FfiConverter { + override fun lift(value: Int): UInt { + return value.toUInt() + } + + override fun read(buf: ByteBuffer): UInt { + return lift(buf.getInt()) + } + + override fun lower(value: UInt): Int { + return value.toInt() + } + + override fun allocationSize(value: UInt) = 4UL + + override fun write(value: UInt, buf: ByteBuffer) { + buf.putInt(value.toInt()) + } +} + +/** + * @suppress + */ +public object FfiConverterInt: FfiConverter { + override fun lift(value: Int): Int { + return value + } + + override fun read(buf: ByteBuffer): Int { + return buf.getInt() + } + + override fun lower(value: Int): Int { + return value + } + + override fun allocationSize(value: Int) = 4UL + + override fun write(value: Int, buf: ByteBuffer) { + buf.putInt(value) + } +} + +/** + * @suppress + */ +public object FfiConverterULong: FfiConverter { + override fun lift(value: Long): ULong { + return value.toULong() + } + + override fun read(buf: ByteBuffer): ULong { + return lift(buf.getLong()) + } + + override fun lower(value: ULong): Long { + return value.toLong() + } + + override fun allocationSize(value: ULong) = 8UL + + override fun write(value: ULong, buf: ByteBuffer) { + buf.putLong(value.toLong()) + } +} + +/** + * @suppress + */ +public object FfiConverterLong: FfiConverter { + override fun lift(value: Long): Long { + return value + } + + override fun read(buf: ByteBuffer): Long { + return buf.getLong() + } + + override fun lower(value: Long): Long { + return value + } + + override fun allocationSize(value: Long) = 8UL + + override fun write(value: Long, buf: ByteBuffer) { + buf.putLong(value) + } +} + +/** + * @suppress + */ +public object FfiConverterDouble: FfiConverter { + override fun lift(value: Double): Double { + return value + } + + override fun read(buf: ByteBuffer): Double { + return buf.getDouble() + } + + override fun lower(value: Double): Double { + return value + } + + override fun allocationSize(value: Double) = 8UL + + override fun write(value: Double, buf: ByteBuffer) { + buf.putDouble(value) + } +} + +/** + * @suppress + */ +public object FfiConverterBoolean: FfiConverter { + override fun lift(value: Byte): Boolean { + return value.toInt() != 0 + } + + override fun read(buf: ByteBuffer): Boolean { + return lift(buf.get()) + } + + override fun lower(value: Boolean): Byte { + return if (value) 1.toByte() else 0.toByte() + } + + override fun allocationSize(value: Boolean) = 1UL + + override fun write(value: Boolean, buf: ByteBuffer) { + buf.put(lower(value)) + } +} + +/** + * @suppress + */ +public object FfiConverterString: FfiConverter { + // Note: we don't inherit from FfiConverterRustBuffer, because we use a + // special encoding when lowering/lifting. We can use `RustBuffer.len` to + // store our length and avoid writing it out to the buffer. + override fun lift(value: RustBuffer.ByValue): String { + try { + val byteArr = ByteArray(value.len.toInt()) + value.asByteBuffer()!!.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } finally { + RustBuffer.free(value) + } + } + + override fun read(buf: ByteBuffer): String { + val len = buf.getInt() + val byteArr = ByteArray(len) + buf.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } + + fun toUtf8(value: String): ByteBuffer { + // Make sure we don't have invalid UTF-16, check for lone surrogates. + return Charsets.UTF_8.newEncoder().run { + onMalformedInput(CodingErrorAction.REPORT) + encode(CharBuffer.wrap(value)) + } + } + + override fun lower(value: String): RustBuffer.ByValue { + val byteBuf = toUtf8(value) + // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us + // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`. + val rbuf = RustBuffer.alloc(byteBuf.limit().toULong()) + rbuf.asByteBuffer()!!.put(byteBuf) + return rbuf + } + + // We aren't sure exactly how many bytes our string will be once it's UTF-8 + // encoded. Allocate 3 bytes per UTF-16 code unit which will always be + // enough. + override fun allocationSize(value: String): ULong { + val sizeForLength = 4UL + val sizeForString = value.length.toULong() * 3UL + return sizeForLength + sizeForString + } + + override fun write(value: String, buf: ByteBuffer) { + val byteBuf = toUtf8(value) + buf.putInt(byteBuf.limit()) + buf.put(byteBuf) + } +} + + +// This template implements a class for working with a Rust struct via a handle +// to the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque handle to the underlying Rust struct. +// Method calls need to read this handle from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its handle should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the handle, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the handle, but is interrupted +// before it can pass the handle over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read handle value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +// +public interface ToriiClientInterface { + + fun `achievements`(`query`: AchievementQuery): PageAchievement + + fun `activities`(`query`: ActivityQuery): PageActivity + + fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry + + fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + + fun `contracts`(`query`: ContractQuery): List + + fun `controllers`(`query`: ControllerQuery): PageController + + fun `entities`(`query`: Query): PageEntity + + fun `eventMessages`(`query`: Query): PageEntity + + fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement + + fun `publishMessage`(`message`: Message): kotlin.String + + fun `publishMessageBatch`(`messages`: List): List + + fun `sql`(`query`: kotlin.String): List + + fun `starknetEvents`(`query`: EventQuery): PageEvent + + fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong + + fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong + + fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong + + fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong + + fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong + + fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance + + fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract + + fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer + + fun `tokens`(`query`: TokenQuery): PageToken + + fun `transactions`(`query`: TransactionQuery): PageTransaction + + fun `worlds`(`worldAddresses`: List): List + + companion object +} + +open class ToriiClient: Disposable, AutoCloseable, ToriiClientInterface +{ + + @Suppress("UNUSED_PARAMETER") + /** + * @suppress + */ + constructor(withHandle: UniffiWithHandle, handle: Long) { + this.handle = handle + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + + /** + * @suppress + * + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noHandle: NoHandle) { + this.handle = 0 + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + constructor(`toriiUrl`: kotlin.String) : + this(UniffiWithHandle, + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new( + + FfiConverterString.lower(`toriiUrl`),_status) +} + ) + + protected val handle: Long + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithHandle(block: (handle: Long) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the handle being freed concurrently. + try { + return block(this.uniffiCloneHandle()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val handle: Long) : Runnable { + override fun run() { + if (handle == 0.toLong()) { + // Fake object created with `NoHandle`, don't try to free. + return; + } + uniffiRustCall { status -> + UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient(handle, status) + } + } + } + + /** + * @suppress + */ + fun uniffiCloneHandle(): Long { + if (handle == 0.toLong()) { + throw InternalException("uniffiCloneHandle() called on NoHandle object"); + } + return uniffiRustCall() { status -> + UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient(handle, status) + } + } + + + @Throws(DojoException::class)override fun `achievements`(`query`: AchievementQuery): PageAchievement { + return FfiConverterTypePageAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements( + it, + FfiConverterTypeAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `activities`(`query`: ActivityQuery): PageActivity { + return FfiConverterTypePageActivity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities( + it, + FfiConverterTypeActivityQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry { + return FfiConverterTypePageAggregationEntry.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations( + it, + FfiConverterTypeAggregationQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + = + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription( + it, + FfiConverterULong.lower(`subscriptionId`),_status) +} + } + + + + + @Throws(DojoException::class)override fun `contracts`(`query`: ContractQuery): List { + return FfiConverterSequenceTypeContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts( + it, + FfiConverterTypeContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `controllers`(`query`: ControllerQuery): PageController { + return FfiConverterTypePageController.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers( + it, + FfiConverterTypeControllerQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `entities`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `eventMessages`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement { + return FfiConverterTypePagePlayerAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements( + it, + FfiConverterTypePlayerAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessage`(`message`: Message): kotlin.String { + return FfiConverterString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message( + it, + FfiConverterTypeMessage.lower(`message`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessageBatch`(`messages`: List): List { + return FfiConverterSequenceString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch( + it, + FfiConverterSequenceTypeMessage.lower(`messages`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `sql`(`query`: kotlin.String): List { + return FfiConverterSequenceTypeSqlRow.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql( + it, + FfiConverterString.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `starknetEvents`(`query`: EventQuery): PageEvent { + return FfiConverterTypePageEvent.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events( + it, + FfiConverterTypeEventQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates( + it, + FfiConverterOptionalTypeClause.lower(`clause`),FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),FfiConverterTypeEntityUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates( + it, + FfiConverterSequenceTypeKeysClause.lower(`keys`),FfiConverterTypeEventUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeFieldElement.lower(`accountAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenBalanceUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates( + it, + FfiConverterOptionalTypeTransactionFilter.lower(`filter`),FfiConverterTypeTransactionUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance { + return FfiConverterTypePageTokenBalance.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances( + it, + FfiConverterTypeTokenBalanceQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract { + return FfiConverterTypePageTokenContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts( + it, + FfiConverterTypeTokenContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer { + return FfiConverterTypePageTokenTransfer.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers( + it, + FfiConverterTypeTokenTransferQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokens`(`query`: TokenQuery): PageToken { + return FfiConverterTypePageToken.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens( + it, + FfiConverterTypeTokenQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `transactions`(`query`: TransactionQuery): PageTransaction { + return FfiConverterTypePageTransaction.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions( + it, + FfiConverterTypeTransactionQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `worlds`(`worldAddresses`: List): List { + return FfiConverterSequenceTypeWorld.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds( + it, + FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),_status) +} + } + ) + } + + + + + + + + + companion object { + + @Throws(DojoException::class) fun `newWithConfig`(`toriiUrl`: kotlin.String, `maxMessageSize`: kotlin.ULong): ToriiClient { + return FfiConverterTypeToriiClient.lift( + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config( + + FfiConverterString.lower(`toriiUrl`),FfiConverterULong.lower(`maxMessageSize`),_status) +} + ) + } + + + + } + +} + + +/** + * @suppress + */ +public object FfiConverterTypeToriiClient: FfiConverter { + override fun lower(value: ToriiClient): Long { + return value.uniffiCloneHandle() + } + + override fun lift(value: Long): ToriiClient { + return ToriiClient(UniffiWithHandle, value) + } + + override fun read(buf: ByteBuffer): ToriiClient { + return lift(buf.getLong()) + } + + override fun allocationSize(value: ToriiClient) = 8UL + + override fun write(value: ToriiClient, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} + + + +data class Achievement ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `entityId`: kotlin.String + , + val `hidden`: kotlin.Boolean + , + val `index`: kotlin.UInt + , + val `points`: kotlin.UInt + , + val `start`: kotlin.String + , + val `end`: kotlin.String + , + val `group`: kotlin.String + , + val `icon`: kotlin.String + , + val `title`: kotlin.String + , + val `description`: kotlin.String + , + val `tasks`: List + , + val `data`: kotlin.String? + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Achievement { + return Achievement( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeAchievementTask.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Achievement) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterBoolean.allocationSize(value.`hidden`) + + FfiConverterUInt.allocationSize(value.`index`) + + FfiConverterUInt.allocationSize(value.`points`) + + FfiConverterString.allocationSize(value.`start`) + + FfiConverterString.allocationSize(value.`end`) + + FfiConverterString.allocationSize(value.`group`) + + FfiConverterString.allocationSize(value.`icon`) + + FfiConverterString.allocationSize(value.`title`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterSequenceTypeAchievementTask.allocationSize(value.`tasks`) + + FfiConverterOptionalString.allocationSize(value.`data`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Achievement, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterBoolean.write(value.`hidden`, buf) + FfiConverterUInt.write(value.`index`, buf) + FfiConverterUInt.write(value.`points`, buf) + FfiConverterString.write(value.`start`, buf) + FfiConverterString.write(value.`end`, buf) + FfiConverterString.write(value.`group`, buf) + FfiConverterString.write(value.`icon`, buf) + FfiConverterString.write(value.`title`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterSequenceTypeAchievementTask.write(value.`tasks`, buf) + FfiConverterOptionalString.write(value.`data`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementProgression ( + val `id`: kotlin.String + , + val `achievementId`: kotlin.String + , + val `taskId`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `playerId`: FieldElement + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + , + val `completedAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementProgression: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementProgression { + return AchievementProgression( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementProgression) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`achievementId`) + + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`playerId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterOptionalULong.allocationSize(value.`completedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AchievementProgression, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`achievementId`, buf) + FfiConverterString.write(value.`taskId`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`playerId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterOptionalULong.write(value.`completedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `hidden`: kotlin.Boolean? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementQuery { + return AchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterOptionalBoolean.allocationSize(value.`hidden`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterOptionalBoolean.write(value.`hidden`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AchievementTask ( + val `taskId`: kotlin.String + , + val `description`: kotlin.String + , + val `total`: kotlin.UInt + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementTask: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementTask { + return AchievementTask( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementTask) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterUInt.allocationSize(value.`total`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: AchievementTask, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterUInt.write(value.`total`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ActionCount ( + val `actionName`: kotlin.String + , + val `count`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActionCount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActionCount { + return ActionCount( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: ActionCount) = ( + FfiConverterString.allocationSize(value.`actionName`) + + FfiConverterUInt.allocationSize(value.`count`) + ) + + override fun write(value: ActionCount, buf: ByteBuffer) { + FfiConverterString.write(value.`actionName`, buf) + FfiConverterUInt.write(value.`count`, buf) + } +} + + + +data class Activity ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `callerAddress`: FieldElement + , + val `sessionStart`: kotlin.ULong + , + val `sessionEnd`: kotlin.ULong + , + val `actionCount`: kotlin.UInt + , + val `actions`: List + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Activity { + return Activity( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterSequenceTypeActionCount.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Activity) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + + FfiConverterULong.allocationSize(value.`sessionStart`) + + FfiConverterULong.allocationSize(value.`sessionEnd`) + + FfiConverterUInt.allocationSize(value.`actionCount`) + + FfiConverterSequenceTypeActionCount.allocationSize(value.`actions`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Activity, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + FfiConverterULong.write(value.`sessionStart`, buf) + FfiConverterULong.write(value.`sessionEnd`, buf) + FfiConverterUInt.write(value.`actionCount`, buf) + FfiConverterSequenceTypeActionCount.write(value.`actions`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class ActivityQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `callerAddresses`: List + , + val `fromTime`: kotlin.ULong? + , + val `toTime`: kotlin.ULong? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivityQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActivityQuery { + return ActivityQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: ActivityQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterOptionalULong.allocationSize(value.`fromTime`) + + FfiConverterOptionalULong.allocationSize(value.`toTime`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: ActivityQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterOptionalULong.write(value.`fromTime`, buf) + FfiConverterOptionalULong.write(value.`toTime`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AggregationEntry ( + val `id`: kotlin.String + , + val `aggregatorId`: kotlin.String + , + val `entityId`: kotlin.String + , + val `value`: U256 + , + val `displayValue`: kotlin.String + , + val `position`: kotlin.ULong + , + val `modelId`: kotlin.String + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationEntry { + return AggregationEntry( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AggregationEntry) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`aggregatorId`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterTypeU256.allocationSize(value.`value`) + + FfiConverterString.allocationSize(value.`displayValue`) + + FfiConverterULong.allocationSize(value.`position`) + + FfiConverterString.allocationSize(value.`modelId`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AggregationEntry, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`aggregatorId`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterTypeU256.write(value.`value`, buf) + FfiConverterString.write(value.`displayValue`, buf) + FfiConverterULong.write(value.`position`, buf) + FfiConverterString.write(value.`modelId`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AggregationQuery ( + val `aggregatorIds`: List + , + val `entityIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationQuery { + return AggregationQuery( + FfiConverterSequenceString.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AggregationQuery) = ( + FfiConverterSequenceString.allocationSize(value.`aggregatorIds`) + + FfiConverterSequenceString.allocationSize(value.`entityIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AggregationQuery, buf: ByteBuffer) { + FfiConverterSequenceString.write(value.`aggregatorIds`, buf) + FfiConverterSequenceString.write(value.`entityIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AttributeFilter ( + val `traitName`: kotlin.String + , + val `traitValue`: kotlin.String + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAttributeFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AttributeFilter { + return AttributeFilter( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: AttributeFilter) = ( + FfiConverterString.allocationSize(value.`traitName`) + + FfiConverterString.allocationSize(value.`traitValue`) + ) + + override fun write(value: AttributeFilter, buf: ByteBuffer) { + FfiConverterString.write(value.`traitName`, buf) + FfiConverterString.write(value.`traitValue`, buf) + } +} + + + +data class CompositeClause ( + val `operator`: LogicalOperator + , + val `clauses`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeCompositeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CompositeClause { + return CompositeClause( + FfiConverterTypeLogicalOperator.read(buf), + FfiConverterSequenceTypeClause.read(buf), + ) + } + + override fun allocationSize(value: CompositeClause) = ( + FfiConverterTypeLogicalOperator.allocationSize(value.`operator`) + + FfiConverterSequenceTypeClause.allocationSize(value.`clauses`) + ) + + override fun write(value: CompositeClause, buf: ByteBuffer) { + FfiConverterTypeLogicalOperator.write(value.`operator`, buf) + FfiConverterSequenceTypeClause.write(value.`clauses`, buf) + } +} + + + +data class Contract ( + val `contractAddress`: FieldElement + , + val `contractType`: ContractType + , + val `head`: kotlin.ULong? + , + val `tps`: kotlin.ULong? + , + val `lastBlockTimestamp`: kotlin.ULong? + , + val `lastPendingBlockTx`: FieldElement? + , + val `updatedAt`: kotlin.ULong + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Contract { + return Contract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeContractType.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Contract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeContractType.allocationSize(value.`contractType`) + + FfiConverterOptionalULong.allocationSize(value.`head`) + + FfiConverterOptionalULong.allocationSize(value.`tps`) + + FfiConverterOptionalULong.allocationSize(value.`lastBlockTimestamp`) + + FfiConverterOptionalTypeFieldElement.allocationSize(value.`lastPendingBlockTx`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: Contract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeContractType.write(value.`contractType`, buf) + FfiConverterOptionalULong.write(value.`head`, buf) + FfiConverterOptionalULong.write(value.`tps`, buf) + FfiConverterOptionalULong.write(value.`lastBlockTimestamp`, buf) + FfiConverterOptionalTypeFieldElement.write(value.`lastPendingBlockTx`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ContractQuery { + return ContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + ) + } + + override fun allocationSize(value: ContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + ) + + override fun write(value: ContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + } +} + + + +data class Controller ( + val `address`: FieldElement + , + val `username`: kotlin.String + , + val `deployedAtTimestamp`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Controller { + return Controller( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Controller) = ( + FfiConverterTypeFieldElement.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`username`) + + FfiConverterULong.allocationSize(value.`deployedAtTimestamp`) + ) + + override fun write(value: Controller, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`address`, buf) + FfiConverterString.write(value.`username`, buf) + FfiConverterULong.write(value.`deployedAtTimestamp`, buf) + } +} + + + +data class ControllerQuery ( + val `pagination`: Pagination + , + val `contractAddresses`: List + , + val `usernames`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeControllerQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ControllerQuery { + return ControllerQuery( + FfiConverterTypePagination.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: ControllerQuery) = ( + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`usernames`) + ) + + override fun write(value: ControllerQuery, buf: ByteBuffer) { + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`usernames`, buf) + } +} + + + +data class Entity ( + val `worldAddress`: FieldElement + , + val `hashedKeys`: FieldElement + , + val `models`: List + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + , + val `executedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Entity { + return Entity( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeStruct.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Entity) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`hashedKeys`) + + FfiConverterSequenceTypeStruct.allocationSize(value.`models`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`executedAt`) + ) + + override fun write(value: Entity, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeFieldElement.write(value.`hashedKeys`, buf) + FfiConverterSequenceTypeStruct.write(value.`models`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + } +} + + + +data class EnumOption ( + val `name`: kotlin.String + , + val `ty`: Ty + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumOption: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumOption { + return EnumOption( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + ) + } + + override fun allocationSize(value: EnumOption) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + ) + + override fun write(value: EnumOption, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + } +} + + + +data class EnumType ( + val `name`: kotlin.String + , + val `option`: kotlin.UByte + , + val `options`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumType { + return EnumType( + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterSequenceTypeEnumOption.read(buf), + ) + } + + override fun allocationSize(value: EnumType) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterUByte.allocationSize(value.`option`) + + FfiConverterSequenceTypeEnumOption.allocationSize(value.`options`) + ) + + override fun write(value: EnumType, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterUByte.write(value.`option`, buf) + FfiConverterSequenceTypeEnumOption.write(value.`options`, buf) + } +} + + + +data class Event ( + val `keys`: List + , + val `data`: List + , + val `transactionHash`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Event { + return Event( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Event) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`data`) + + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + ) + + override fun write(value: Event, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`data`, buf) + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + } +} + + + +data class EventQuery ( + val `keys`: KeysClause? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEventQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EventQuery { + return EventQuery( + FfiConverterOptionalTypeKeysClause.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: EventQuery) = ( + FfiConverterOptionalTypeKeysClause.allocationSize(value.`keys`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: EventQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeKeysClause.write(value.`keys`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class FixedSizeArray ( + val `array`: List + , + val `size`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeFixedSizeArray: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FixedSizeArray { + return FixedSizeArray( + FfiConverterSequenceTypeTy.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: FixedSizeArray) = ( + FfiConverterSequenceTypeTy.allocationSize(value.`array`) + + FfiConverterUInt.allocationSize(value.`size`) + ) + + override fun write(value: FixedSizeArray, buf: ByteBuffer) { + FfiConverterSequenceTypeTy.write(value.`array`, buf) + FfiConverterUInt.write(value.`size`, buf) + } +} + + + +data class KeysClause ( + val `keys`: List + , + val `patternMatching`: PatternMatching + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause { + return KeysClause( + FfiConverterSequenceOptionalTypeFieldElement.read(buf), + FfiConverterTypePatternMatching.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: KeysClause) = ( + FfiConverterSequenceOptionalTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterTypePatternMatching.allocationSize(value.`patternMatching`) + + FfiConverterSequenceString.allocationSize(value.`models`) + ) + + override fun write(value: KeysClause, buf: ByteBuffer) { + FfiConverterSequenceOptionalTypeFieldElement.write(value.`keys`, buf) + FfiConverterTypePatternMatching.write(value.`patternMatching`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + } +} + + + +data class Member ( + val `name`: kotlin.String + , + val `ty`: Ty + , + val `key`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMember: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Member { + return Member( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Member) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + + FfiConverterBoolean.allocationSize(value.`key`) + ) + + override fun write(value: Member, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + FfiConverterBoolean.write(value.`key`, buf) + } +} + + + +data class MemberClause ( + val `model`: kotlin.String + , + val `member`: kotlin.String + , + val `operator`: ComparisonOperator + , + val `value`: MemberValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): MemberClause { + return MemberClause( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeComparisonOperator.read(buf), + FfiConverterTypeMemberValue.read(buf), + ) + } + + override fun allocationSize(value: MemberClause) = ( + FfiConverterString.allocationSize(value.`model`) + + FfiConverterString.allocationSize(value.`member`) + + FfiConverterTypeComparisonOperator.allocationSize(value.`operator`) + + FfiConverterTypeMemberValue.allocationSize(value.`value`) + ) + + override fun write(value: MemberClause, buf: ByteBuffer) { + FfiConverterString.write(value.`model`, buf) + FfiConverterString.write(value.`member`, buf) + FfiConverterTypeComparisonOperator.write(value.`operator`, buf) + FfiConverterTypeMemberValue.write(value.`value`, buf) + } +} + + + +data class Message ( + val `message`: kotlin.String + , + val `signature`: List + , + val `worldAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMessage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Message { + return Message( + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Message) = ( + FfiConverterString.allocationSize(value.`message`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + ) + + override fun write(value: Message, buf: ByteBuffer) { + FfiConverterString.write(value.`message`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + } +} + + + +data class Model ( + val `worldAddress`: FieldElement + , + val `schema`: Ty + , + val `namespace`: kotlin.String + , + val `name`: kotlin.String + , + val `selector`: FieldElement + , + val `packedSize`: kotlin.UInt + , + val `unpackedSize`: kotlin.UInt + , + val `classHash`: FieldElement + , + val `contractAddress`: FieldElement + , + val `layout`: kotlin.String + , + val `useLegacyStore`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeModel: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Model { + return Model( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Model) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeTy.allocationSize(value.`schema`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeFieldElement.allocationSize(value.`selector`) + + FfiConverterUInt.allocationSize(value.`packedSize`) + + FfiConverterUInt.allocationSize(value.`unpackedSize`) + + FfiConverterTypeFieldElement.allocationSize(value.`classHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`layout`) + + FfiConverterBoolean.allocationSize(value.`useLegacyStore`) + ) + + override fun write(value: Model, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeTy.write(value.`schema`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeFieldElement.write(value.`selector`, buf) + FfiConverterUInt.write(value.`packedSize`, buf) + FfiConverterUInt.write(value.`unpackedSize`, buf) + FfiConverterTypeFieldElement.write(value.`classHash`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`layout`, buf) + FfiConverterBoolean.write(value.`useLegacyStore`, buf) + } +} + + + +data class OrderBy ( + val `field`: kotlin.String + , + val `direction`: OrderDirection + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeOrderBy: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): OrderBy { + return OrderBy( + FfiConverterString.read(buf), + FfiConverterTypeOrderDirection.read(buf), + ) + } + + override fun allocationSize(value: OrderBy) = ( + FfiConverterString.allocationSize(value.`field`) + + FfiConverterTypeOrderDirection.allocationSize(value.`direction`) + ) + + override fun write(value: OrderBy, buf: ByteBuffer) { + FfiConverterString.write(value.`field`, buf) + FfiConverterTypeOrderDirection.write(value.`direction`, buf) + } +} + + + +data class PageAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAchievement { + return PageAchievement( + FfiConverterSequenceTypeAchievement.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAchievement) = ( + FfiConverterSequenceTypeAchievement.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypeAchievement.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageActivity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageActivity { + return PageActivity( + FfiConverterSequenceTypeActivity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageActivity) = ( + FfiConverterSequenceTypeActivity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageActivity, buf: ByteBuffer) { + FfiConverterSequenceTypeActivity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageAggregationEntry ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAggregationEntry { + return PageAggregationEntry( + FfiConverterSequenceTypeAggregationEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAggregationEntry) = ( + FfiConverterSequenceTypeAggregationEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAggregationEntry, buf: ByteBuffer) { + FfiConverterSequenceTypeAggregationEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageController ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageController { + return PageController( + FfiConverterSequenceTypeController.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageController) = ( + FfiConverterSequenceTypeController.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageController, buf: ByteBuffer) { + FfiConverterSequenceTypeController.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEntity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEntity { + return PageEntity( + FfiConverterSequenceTypeEntity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEntity) = ( + FfiConverterSequenceTypeEntity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEntity, buf: ByteBuffer) { + FfiConverterSequenceTypeEntity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEvent ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEvent { + return PageEvent( + FfiConverterSequenceTypeEvent.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEvent) = ( + FfiConverterSequenceTypeEvent.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEvent, buf: ByteBuffer) { + FfiConverterSequenceTypeEvent.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PagePlayerAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagePlayerAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PagePlayerAchievement { + return PagePlayerAchievement( + FfiConverterSequenceTypePlayerAchievementEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PagePlayerAchievement) = ( + FfiConverterSequenceTypePlayerAchievementEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PagePlayerAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypePlayerAchievementEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageToken ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageToken { + return PageToken( + FfiConverterSequenceTypeToken.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageToken) = ( + FfiConverterSequenceTypeToken.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageToken, buf: ByteBuffer) { + FfiConverterSequenceTypeToken.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenBalance ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenBalance { + return PageTokenBalance( + FfiConverterSequenceTypeTokenBalance.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenBalance) = ( + FfiConverterSequenceTypeTokenBalance.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenBalance, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenBalance.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenContract ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenContract { + return PageTokenContract( + FfiConverterSequenceTypeTokenContract.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenContract) = ( + FfiConverterSequenceTypeTokenContract.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenContract, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenContract.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenTransfer ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenTransfer { + return PageTokenTransfer( + FfiConverterSequenceTypeTokenTransfer.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenTransfer) = ( + FfiConverterSequenceTypeTokenTransfer.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenTransfer, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenTransfer.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTransaction ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTransaction { + return PageTransaction( + FfiConverterSequenceTypeTransaction.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTransaction) = ( + FfiConverterSequenceTypeTransaction.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTransaction, buf: ByteBuffer) { + FfiConverterSequenceTypeTransaction.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class Pagination ( + val `cursor`: kotlin.String? + , + val `limit`: kotlin.UInt? + , + val `direction`: PaginationDirection + , + val `orderBy`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagination: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Pagination { + return Pagination( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterTypePaginationDirection.read(buf), + FfiConverterSequenceTypeOrderBy.read(buf), + ) + } + + override fun allocationSize(value: Pagination) = ( + FfiConverterOptionalString.allocationSize(value.`cursor`) + + FfiConverterOptionalUInt.allocationSize(value.`limit`) + + FfiConverterTypePaginationDirection.allocationSize(value.`direction`) + + FfiConverterSequenceTypeOrderBy.allocationSize(value.`orderBy`) + ) + + override fun write(value: Pagination, buf: ByteBuffer) { + FfiConverterOptionalString.write(value.`cursor`, buf) + FfiConverterOptionalUInt.write(value.`limit`, buf) + FfiConverterTypePaginationDirection.write(value.`direction`, buf) + FfiConverterSequenceTypeOrderBy.write(value.`orderBy`, buf) + } +} + + + +data class PlayerAchievementEntry ( + val `playerAddress`: FieldElement + , + val `stats`: PlayerAchievementStats + , + val `achievements`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementEntry { + return PlayerAchievementEntry( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypePlayerAchievementStats.read(buf), + FfiConverterSequenceTypePlayerAchievementProgress.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementEntry) = ( + FfiConverterTypeFieldElement.allocationSize(value.`playerAddress`) + + FfiConverterTypePlayerAchievementStats.allocationSize(value.`stats`) + + FfiConverterSequenceTypePlayerAchievementProgress.allocationSize(value.`achievements`) + ) + + override fun write(value: PlayerAchievementEntry, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`playerAddress`, buf) + FfiConverterTypePlayerAchievementStats.write(value.`stats`, buf) + FfiConverterSequenceTypePlayerAchievementProgress.write(value.`achievements`, buf) + } +} + + + +data class PlayerAchievementProgress ( + val `achievement`: Achievement + , + val `taskProgress`: List + , + val `completed`: kotlin.Boolean + , + val `progressPercentage`: kotlin.Double + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementProgress { + return PlayerAchievementProgress( + FfiConverterTypeAchievement.read(buf), + FfiConverterSequenceTypeTaskProgress.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterDouble.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementProgress) = ( + FfiConverterTypeAchievement.allocationSize(value.`achievement`) + + FfiConverterSequenceTypeTaskProgress.allocationSize(value.`taskProgress`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterDouble.allocationSize(value.`progressPercentage`) + ) + + override fun write(value: PlayerAchievementProgress, buf: ByteBuffer) { + FfiConverterTypeAchievement.write(value.`achievement`, buf) + FfiConverterSequenceTypeTaskProgress.write(value.`taskProgress`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterDouble.write(value.`progressPercentage`, buf) + } +} + + + +data class PlayerAchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `playerAddresses`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementQuery { + return PlayerAchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`playerAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: PlayerAchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`playerAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class PlayerAchievementStats ( + val `totalPoints`: kotlin.UInt + , + val `completedAchievements`: kotlin.UInt + , + val `totalAchievements`: kotlin.UInt + , + val `completionPercentage`: kotlin.Double + , + val `lastAchievementAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementStats: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementStats { + return PlayerAchievementStats( + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementStats) = ( + FfiConverterUInt.allocationSize(value.`totalPoints`) + + FfiConverterUInt.allocationSize(value.`completedAchievements`) + + FfiConverterUInt.allocationSize(value.`totalAchievements`) + + FfiConverterDouble.allocationSize(value.`completionPercentage`) + + FfiConverterOptionalULong.allocationSize(value.`lastAchievementAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: PlayerAchievementStats, buf: ByteBuffer) { + FfiConverterUInt.write(value.`totalPoints`, buf) + FfiConverterUInt.write(value.`completedAchievements`, buf) + FfiConverterUInt.write(value.`totalAchievements`, buf) + FfiConverterDouble.write(value.`completionPercentage`, buf) + FfiConverterOptionalULong.write(value.`lastAchievementAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class Query ( + val `worldAddresses`: List + , + val `pagination`: Pagination + , + val `clause`: Clause? + , + val `noHashedKeys`: kotlin.Boolean + , + val `models`: List + , + val `historical`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Query { + return Query( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + FfiConverterOptionalTypeClause.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Query) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterOptionalTypeClause.allocationSize(value.`clause`) + + FfiConverterBoolean.allocationSize(value.`noHashedKeys`) + + FfiConverterSequenceString.allocationSize(value.`models`) + + FfiConverterBoolean.allocationSize(value.`historical`) + ) + + override fun write(value: Query, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterOptionalTypeClause.write(value.`clause`, buf) + FfiConverterBoolean.write(value.`noHashedKeys`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + FfiConverterBoolean.write(value.`historical`, buf) + } +} + + + +data class Signature ( + val `r`: FieldElement + , + val `s`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSignature: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Signature { + return Signature( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Signature) = ( + FfiConverterTypeFieldElement.allocationSize(value.`r`) + + FfiConverterTypeFieldElement.allocationSize(value.`s`) + ) + + override fun write(value: Signature, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`r`, buf) + FfiConverterTypeFieldElement.write(value.`s`, buf) + } +} + + + +data class SqlField ( + val `name`: kotlin.String + , + val `value`: SqlValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlField: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlField { + return SqlField( + FfiConverterString.read(buf), + FfiConverterTypeSqlValue.read(buf), + ) + } + + override fun allocationSize(value: SqlField) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeSqlValue.allocationSize(value.`value`) + ) + + override fun write(value: SqlField, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeSqlValue.write(value.`value`, buf) + } +} + + + +data class SqlRow ( + val `fields`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlRow: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlRow { + return SqlRow( + FfiConverterSequenceTypeSqlField.read(buf), + ) + } + + override fun allocationSize(value: SqlRow) = ( + FfiConverterSequenceTypeSqlField.allocationSize(value.`fields`) + ) + + override fun write(value: SqlRow, buf: ByteBuffer) { + FfiConverterSequenceTypeSqlField.write(value.`fields`, buf) + } +} + + + +data class Struct ( + val `name`: kotlin.String + , + val `children`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeStruct: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Struct { + return Struct( + FfiConverterString.read(buf), + FfiConverterSequenceTypeMember.read(buf), + ) + } + + override fun allocationSize(value: Struct) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterSequenceTypeMember.allocationSize(value.`children`) + ) + + override fun write(value: Struct, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterSequenceTypeMember.write(value.`children`, buf) + } +} + + + +data class TaskProgress ( + val `taskId`: kotlin.String + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTaskProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TaskProgress { + return TaskProgress( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: TaskProgress) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + ) + + override fun write(value: TaskProgress, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + } +} + + + +data class Token ( + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Token { + return Token( + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: Token) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: Token, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenBalance ( + val `balance`: U256 + , + val `accountAddress`: FieldElement + , + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalance { + return TokenBalance( + FfiConverterTypeU256.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenBalance) = ( + FfiConverterTypeU256.allocationSize(value.`balance`) + + FfiConverterTypeFieldElement.allocationSize(value.`accountAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + ) + + override fun write(value: TokenBalance, buf: ByteBuffer) { + FfiConverterTypeU256.write(value.`balance`, buf) + FfiConverterTypeFieldElement.write(value.`accountAddress`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + } +} + + + +data class TokenBalanceQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalanceQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalanceQuery { + return TokenBalanceQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenBalanceQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenBalanceQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenContract ( + val `contractAddress`: FieldElement + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `tokenMetadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContract { + return TokenContract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenContract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterString.allocationSize(value.`tokenMetadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: TokenContract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterString.write(value.`tokenMetadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContractQuery { + return TokenContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenQuery ( + val `contractAddresses`: List + , + val `tokenIds`: List + , + val `attributeFilters`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenQuery { + return TokenQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterSequenceTypeAttributeFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterSequenceTypeAttributeFilter.allocationSize(value.`attributeFilters`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterSequenceTypeAttributeFilter.write(value.`attributeFilters`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenTransfer ( + val `id`: kotlin.String + , + val `contractAddress`: FieldElement + , + val `fromAddress`: FieldElement + , + val `toAddress`: FieldElement + , + val `amount`: U256 + , + val `tokenId`: U256? + , + val `executedAt`: kotlin.ULong + , + val `eventId`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransfer { + return TokenTransfer( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterULong.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: TokenTransfer) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`fromAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`toAddress`) + + FfiConverterTypeU256.allocationSize(value.`amount`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterULong.allocationSize(value.`executedAt`) + + FfiConverterOptionalString.allocationSize(value.`eventId`) + ) + + override fun write(value: TokenTransfer, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeFieldElement.write(value.`fromAddress`, buf) + FfiConverterTypeFieldElement.write(value.`toAddress`, buf) + FfiConverterTypeU256.write(value.`amount`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + FfiConverterOptionalString.write(value.`eventId`, buf) + } +} + + + +data class TokenTransferQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransferQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransferQuery { + return TokenTransferQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenTransferQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenTransferQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class Transaction ( + val `transactionHash`: FieldElement + , + val `senderAddress`: FieldElement + , + val `calldata`: List + , + val `maxFee`: FieldElement + , + val `signature`: List + , + val `nonce`: FieldElement + , + val `blockNumber`: kotlin.ULong + , + val `transactionType`: kotlin.String + , + val `blockTimestamp`: kotlin.ULong + , + val `calls`: List + , + val `uniqueModels`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Transaction { + return Transaction( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterSequenceTypeTransactionCall.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Transaction) = ( + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`senderAddress`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeFieldElement.allocationSize(value.`maxFee`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`nonce`) + + FfiConverterULong.allocationSize(value.`blockNumber`) + + FfiConverterString.allocationSize(value.`transactionType`) + + FfiConverterULong.allocationSize(value.`blockTimestamp`) + + FfiConverterSequenceTypeTransactionCall.allocationSize(value.`calls`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`uniqueModels`) + ) + + override fun write(value: Transaction, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + FfiConverterTypeFieldElement.write(value.`senderAddress`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeFieldElement.write(value.`maxFee`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`nonce`, buf) + FfiConverterULong.write(value.`blockNumber`, buf) + FfiConverterString.write(value.`transactionType`, buf) + FfiConverterULong.write(value.`blockTimestamp`, buf) + FfiConverterSequenceTypeTransactionCall.write(value.`calls`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`uniqueModels`, buf) + } +} + + + +data class TransactionCall ( + val `contractAddress`: FieldElement + , + val `entrypoint`: kotlin.String + , + val `calldata`: List + , + val `callType`: CallType + , + val `callerAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionCall: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionCall { + return TransactionCall( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeCallType.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: TransactionCall) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`entrypoint`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeCallType.allocationSize(value.`callType`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + ) + + override fun write(value: TransactionCall, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`entrypoint`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeCallType.write(value.`callType`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + } +} + + + +data class TransactionFilter ( + val `transactionHashes`: List + , + val `callerAddresses`: List + , + val `contractAddresses`: List + , + val `entrypoints`: List + , + val `modelSelectors`: List + , + val `fromBlock`: kotlin.ULong? + , + val `toBlock`: kotlin.ULong? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter { + return TransactionFilter( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + ) + } + + override fun allocationSize(value: TransactionFilter) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`transactionHashes`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`entrypoints`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`modelSelectors`) + + FfiConverterOptionalULong.allocationSize(value.`fromBlock`) + + FfiConverterOptionalULong.allocationSize(value.`toBlock`) + ) + + override fun write(value: TransactionFilter, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`transactionHashes`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`entrypoints`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`modelSelectors`, buf) + FfiConverterOptionalULong.write(value.`fromBlock`, buf) + FfiConverterOptionalULong.write(value.`toBlock`, buf) + } +} + + + +data class TransactionQuery ( + val `filter`: TransactionFilter? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionQuery { + return TransactionQuery( + FfiConverterOptionalTypeTransactionFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TransactionQuery) = ( + FfiConverterOptionalTypeTransactionFilter.allocationSize(value.`filter`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TransactionQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeTransactionFilter.write(value.`filter`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class World ( + val `worldAddress`: FieldElement + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeWorld: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): World { + return World( + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeModel.read(buf), + ) + } + + override fun allocationSize(value: World) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterSequenceTypeModel.allocationSize(value.`models`) + ) + + override fun write(value: World, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterSequenceTypeModel.write(value.`models`, buf) + } +} + + + + +enum class CallType { + + EXECUTE, + EXECUTE_FROM_OUTSIDE; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeCallType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + CallType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: CallType) = 4UL + + override fun write(value: CallType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Clause { + + data class HashedKeys( + val `keys`: List) : Clause() + + { + + + companion object + } + + data class Keys( + val `clause`: KeysClause) : Clause() + + { + + + companion object + } + + data class Member( + val `clause`: MemberClause) : Clause() + + { + + + companion object + } + + data class Composite( + val `clause`: CompositeClause) : Clause() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeClause : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Clause { + return when(buf.getInt()) { + 1 -> Clause.HashedKeys( + FfiConverterSequenceTypeFieldElement.read(buf), + ) + 2 -> Clause.Keys( + FfiConverterTypeKeysClause.read(buf), + ) + 3 -> Clause.Member( + FfiConverterTypeMemberClause.read(buf), + ) + 4 -> Clause.Composite( + FfiConverterTypeCompositeClause.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Clause) = when(value) { + is Clause.HashedKeys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + ) + } + is Clause.Keys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeKeysClause.allocationSize(value.`clause`) + ) + } + is Clause.Member -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeMemberClause.allocationSize(value.`clause`) + ) + } + is Clause.Composite -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeCompositeClause.allocationSize(value.`clause`) + ) + } + } + + override fun write(value: Clause, buf: ByteBuffer) { + when(value) { + is Clause.HashedKeys -> { + buf.putInt(1) + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + Unit + } + is Clause.Keys -> { + buf.putInt(2) + FfiConverterTypeKeysClause.write(value.`clause`, buf) + Unit + } + is Clause.Member -> { + buf.putInt(3) + FfiConverterTypeMemberClause.write(value.`clause`, buf) + Unit + } + is Clause.Composite -> { + buf.putInt(4) + FfiConverterTypeCompositeClause.write(value.`clause`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class ComparisonOperator { + + EQ, + NEQ, + GT, + GTE, + LT, + LTE, + IN, + NOT_IN, + CONTAINS, + CONTAINS_ALL, + CONTAINS_ANY, + ARRAY_LENGTH_EQ, + ARRAY_LENGTH_GT, + ARRAY_LENGTH_LT; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeComparisonOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ComparisonOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ComparisonOperator) = 4UL + + override fun write(value: ComparisonOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class ContractType { + + WORLD, + ERC20, + ERC721, + ERC1155, + UDC, + OTHER; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeContractType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ContractType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ContractType) = 4UL + + override fun write(value: ContractType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + + +sealed class DojoException(message: String): kotlin.Exception(message) { + + class ClientException(message: String) : DojoException(message) + + class SerializationException(message: String) : DojoException(message) + + class NetworkException(message: String) : DojoException(message) + + class InvalidInput(message: String) : DojoException(message) + + class ConnectionException(message: String) : DojoException(message) + + class PublishException(message: String) : DojoException(message) + + class QueryException(message: String) : DojoException(message) + + class SubscriptionException(message: String) : DojoException(message) + + + companion object ErrorHandler : UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): DojoException = FfiConverterTypeDojoError.lift(error_buf) + } +} + +/** + * @suppress + */ +public object FfiConverterTypeDojoError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): DojoException { + + return when(buf.getInt()) { + 1 -> DojoException.ClientException(FfiConverterString.read(buf)) + 2 -> DojoException.SerializationException(FfiConverterString.read(buf)) + 3 -> DojoException.NetworkException(FfiConverterString.read(buf)) + 4 -> DojoException.InvalidInput(FfiConverterString.read(buf)) + 5 -> DojoException.ConnectionException(FfiConverterString.read(buf)) + 6 -> DojoException.PublishException(FfiConverterString.read(buf)) + 7 -> DojoException.QueryException(FfiConverterString.read(buf)) + 8 -> DojoException.SubscriptionException(FfiConverterString.read(buf)) + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") + } + + } + + override fun allocationSize(value: DojoException): ULong { + return 4UL + } + + override fun write(value: DojoException, buf: ByteBuffer) { + when(value) { + is DojoException.ClientException -> { + buf.putInt(1) + Unit + } + is DojoException.SerializationException -> { + buf.putInt(2) + Unit + } + is DojoException.NetworkException -> { + buf.putInt(3) + Unit + } + is DojoException.InvalidInput -> { + buf.putInt(4) + Unit + } + is DojoException.ConnectionException -> { + buf.putInt(5) + Unit + } + is DojoException.PublishException -> { + buf.putInt(6) + Unit + } + is DojoException.QueryException -> { + buf.putInt(7) + Unit + } + is DojoException.SubscriptionException -> { + buf.putInt(8) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } + +} + + + + +enum class LogicalOperator { + + AND, + OR; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeLogicalOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + LogicalOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: LogicalOperator) = 4UL + + override fun write(value: LogicalOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class MemberValue { + + data class Primitive( + val `value`: Primitive) : MemberValue() + + { + + + companion object + } + + data class String( + val `value`: kotlin.String) : MemberValue() + + { + + + companion object + } + + data class List( + val `values`: List) : MemberValue() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): MemberValue { + return when(buf.getInt()) { + 1 -> MemberValue.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> MemberValue.String( + FfiConverterString.read(buf), + ) + 3 -> MemberValue.List( + FfiConverterSequenceTypeMemberValue.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: MemberValue) = when(value) { + is MemberValue.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is MemberValue.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is MemberValue.List -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeMemberValue.allocationSize(value.`values`) + ) + } + } + + override fun write(value: MemberValue, buf: ByteBuffer) { + when(value) { + is MemberValue.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is MemberValue.String -> { + buf.putInt(2) + FfiConverterString.write(value.`value`, buf) + Unit + } + is MemberValue.List -> { + buf.putInt(3) + FfiConverterSequenceTypeMemberValue.write(value.`values`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class OrderDirection { + + ASC, + DESC; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeOrderDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + OrderDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: OrderDirection) = 4UL + + override fun write(value: OrderDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PaginationDirection { + + FORWARD, + BACKWARD; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePaginationDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PaginationDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PaginationDirection) = 4UL + + override fun write(value: PaginationDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PatternMatching { + + FIXED_LEN, + VARIABLE_LEN; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePatternMatching: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PatternMatching.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PatternMatching) = 4UL + + override fun write(value: PatternMatching, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Primitive { + + data class I8( + val `value`: kotlin.Byte) : Primitive() + + { + + + companion object + } + + data class I16( + val `value`: kotlin.Short) : Primitive() + + { + + + companion object + } + + data class I32( + val `value`: kotlin.Int) : Primitive() + + { + + + companion object + } + + data class I64( + val `value`: kotlin.Long) : Primitive() + + { + + + companion object + } + + data class I128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U8( + val `value`: kotlin.UByte) : Primitive() + + { + + + companion object + } + + data class U16( + val `value`: kotlin.UShort) : Primitive() + + { + + + companion object + } + + data class U32( + val `value`: kotlin.UInt) : Primitive() + + { + + + companion object + } + + data class U64( + val `value`: kotlin.ULong) : Primitive() + + { + + + companion object + } + + data class U128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U256( + val `value`: U256) : Primitive() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : Primitive() + + { + + + companion object + } + + data class Felt252( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ClassHash( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ContractAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class EthAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePrimitive : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Primitive { + return when(buf.getInt()) { + 1 -> Primitive.I8( + FfiConverterByte.read(buf), + ) + 2 -> Primitive.I16( + FfiConverterShort.read(buf), + ) + 3 -> Primitive.I32( + FfiConverterInt.read(buf), + ) + 4 -> Primitive.I64( + FfiConverterLong.read(buf), + ) + 5 -> Primitive.I128( + FfiConverterSequenceUByte.read(buf), + ) + 6 -> Primitive.U8( + FfiConverterUByte.read(buf), + ) + 7 -> Primitive.U16( + FfiConverterUShort.read(buf), + ) + 8 -> Primitive.U32( + FfiConverterUInt.read(buf), + ) + 9 -> Primitive.U64( + FfiConverterULong.read(buf), + ) + 10 -> Primitive.U128( + FfiConverterSequenceUByte.read(buf), + ) + 11 -> Primitive.U256( + FfiConverterTypeU256.read(buf), + ) + 12 -> Primitive.Bool( + FfiConverterBoolean.read(buf), + ) + 13 -> Primitive.Felt252( + FfiConverterTypeFieldElement.read(buf), + ) + 14 -> Primitive.ClassHash( + FfiConverterTypeFieldElement.read(buf), + ) + 15 -> Primitive.ContractAddress( + FfiConverterTypeFieldElement.read(buf), + ) + 16 -> Primitive.EthAddress( + FfiConverterTypeFieldElement.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Primitive) = when(value) { + is Primitive.I8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterByte.allocationSize(value.`value`) + ) + } + is Primitive.I16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterShort.allocationSize(value.`value`) + ) + } + is Primitive.I32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterInt.allocationSize(value.`value`) + ) + } + is Primitive.I64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is Primitive.I128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUByte.allocationSize(value.`value`) + ) + } + is Primitive.U16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUShort.allocationSize(value.`value`) + ) + } + is Primitive.U32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUInt.allocationSize(value.`value`) + ) + } + is Primitive.U64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is Primitive.U128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U256 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeU256.allocationSize(value.`value`) + ) + } + is Primitive.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is Primitive.Felt252 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ClassHash -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ContractAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.EthAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Primitive, buf: ByteBuffer) { + when(value) { + is Primitive.I8 -> { + buf.putInt(1) + FfiConverterByte.write(value.`value`, buf) + Unit + } + is Primitive.I16 -> { + buf.putInt(2) + FfiConverterShort.write(value.`value`, buf) + Unit + } + is Primitive.I32 -> { + buf.putInt(3) + FfiConverterInt.write(value.`value`, buf) + Unit + } + is Primitive.I64 -> { + buf.putInt(4) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is Primitive.I128 -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U8 -> { + buf.putInt(6) + FfiConverterUByte.write(value.`value`, buf) + Unit + } + is Primitive.U16 -> { + buf.putInt(7) + FfiConverterUShort.write(value.`value`, buf) + Unit + } + is Primitive.U32 -> { + buf.putInt(8) + FfiConverterUInt.write(value.`value`, buf) + Unit + } + is Primitive.U64 -> { + buf.putInt(9) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is Primitive.U128 -> { + buf.putInt(10) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U256 -> { + buf.putInt(11) + FfiConverterTypeU256.write(value.`value`, buf) + Unit + } + is Primitive.Bool -> { + buf.putInt(12) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is Primitive.Felt252 -> { + buf.putInt(13) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ClassHash -> { + buf.putInt(14) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ContractAddress -> { + buf.putInt(15) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.EthAddress -> { + buf.putInt(16) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class SqlValue { + + data class Text( + val `value`: kotlin.String) : SqlValue() + + { + + + companion object + } + + data class Integer( + val `value`: kotlin.Long) : SqlValue() + + { + + + companion object + } + + data class Real( + val `value`: kotlin.Double) : SqlValue() + + { + + + companion object + } + + data class Blob( + val `value`: List) : SqlValue() + + { + + + companion object + } + + object Null : SqlValue() + + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): SqlValue { + return when(buf.getInt()) { + 1 -> SqlValue.Text( + FfiConverterString.read(buf), + ) + 2 -> SqlValue.Integer( + FfiConverterLong.read(buf), + ) + 3 -> SqlValue.Real( + FfiConverterDouble.read(buf), + ) + 4 -> SqlValue.Blob( + FfiConverterSequenceUByte.read(buf), + ) + 5 -> SqlValue.Null + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: SqlValue) = when(value) { + is SqlValue.Text -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is SqlValue.Integer -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is SqlValue.Real -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterDouble.allocationSize(value.`value`) + ) + } + is SqlValue.Blob -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is SqlValue.Null -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + } + + override fun write(value: SqlValue, buf: ByteBuffer) { + when(value) { + is SqlValue.Text -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is SqlValue.Integer -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is SqlValue.Real -> { + buf.putInt(3) + FfiConverterDouble.write(value.`value`, buf) + Unit + } + is SqlValue.Blob -> { + buf.putInt(4) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is SqlValue.Null -> { + buf.putInt(5) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class Ty { + + data class Primitive( + val `value`: Primitive) : Ty() + + { + + + companion object + } + + data class Struct( + val `value`: Struct) : Ty() + + { + + + companion object + } + + data class Enum( + val `value`: EnumType) : Ty() + + { + + + companion object + } + + data class Tuple( + val `values`: List) : Ty() + + { + + + companion object + } + + data class Array( + val `values`: List) : Ty() + + { + + + companion object + } + + data class FixedSizeArray( + val `value`: FixedSizeArray) : Ty() + + { + + + companion object + } + + data class ByteArray( + val `value`: kotlin.String) : Ty() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTy : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Ty { + return when(buf.getInt()) { + 1 -> Ty.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> Ty.Struct( + FfiConverterTypeStruct.read(buf), + ) + 3 -> Ty.Enum( + FfiConverterTypeEnumType.read(buf), + ) + 4 -> Ty.Tuple( + FfiConverterSequenceTypeTy.read(buf), + ) + 5 -> Ty.Array( + FfiConverterSequenceTypeTy.read(buf), + ) + 6 -> Ty.FixedSizeArray( + FfiConverterTypeFixedSizeArray.read(buf), + ) + 7 -> Ty.ByteArray( + FfiConverterString.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Ty) = when(value) { + is Ty.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is Ty.Struct -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeStruct.allocationSize(value.`value`) + ) + } + is Ty.Enum -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeEnumType.allocationSize(value.`value`) + ) + } + is Ty.Tuple -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.Array -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.FixedSizeArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFixedSizeArray.allocationSize(value.`value`) + ) + } + is Ty.ByteArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Ty, buf: ByteBuffer) { + when(value) { + is Ty.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is Ty.Struct -> { + buf.putInt(2) + FfiConverterTypeStruct.write(value.`value`, buf) + Unit + } + is Ty.Enum -> { + buf.putInt(3) + FfiConverterTypeEnumType.write(value.`value`, buf) + Unit + } + is Ty.Tuple -> { + buf.putInt(4) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.Array -> { + buf.putInt(5) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.FixedSizeArray -> { + buf.putInt(6) + FfiConverterTypeFixedSizeArray.write(value.`value`, buf) + Unit + } + is Ty.ByteArray -> { + buf.putInt(7) + FfiConverterString.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class ValueType { + + data class String( + val `value`: kotlin.String) : ValueType() + + { + + + companion object + } + + data class Int( + val `value`: kotlin.Long) : ValueType() + + { + + + companion object + } + + data class UInt( + val `value`: kotlin.ULong) : ValueType() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : ValueType() + + { + + + companion object + } + + data class Bytes( + val `value`: List) : ValueType() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeValueType : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): ValueType { + return when(buf.getInt()) { + 1 -> ValueType.String( + FfiConverterString.read(buf), + ) + 2 -> ValueType.Int( + FfiConverterLong.read(buf), + ) + 3 -> ValueType.UInt( + FfiConverterULong.read(buf), + ) + 4 -> ValueType.Bool( + FfiConverterBoolean.read(buf), + ) + 5 -> ValueType.Bytes( + FfiConverterSequenceUByte.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: ValueType) = when(value) { + is ValueType.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is ValueType.Int -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is ValueType.UInt -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is ValueType.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is ValueType.Bytes -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + } + + override fun write(value: ValueType, buf: ByteBuffer) { + when(value) { + is ValueType.String -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is ValueType.Int -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is ValueType.UInt -> { + buf.putInt(3) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is ValueType.Bool -> { + buf.putInt(4) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is ValueType.Bytes -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + + +public interface EntityUpdateCallback { + + fun `onUpdate`(`entity`: Entity) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEntityUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEntity.lift(`entity`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEntityUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEntityUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEntityUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEntityUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface EventUpdateCallback { + + fun `onUpdate`(`event`: Event) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEventUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEvent.lift(`event`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEventUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEventUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEventUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEventUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenBalanceUpdateCallback { + + fun `onUpdate`(`balance`: TokenBalance) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenBalanceUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTokenBalance.lift(`balance`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenBalanceUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenBalanceUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenBalanceUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenUpdateCallback { + + fun `onUpdate`(`token`: Token) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeToken.lift(`token`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TransactionUpdateCallback { + + fun `onUpdate`(`transaction`: Transaction) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTransactionUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTransaction.lift(`transaction`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTransactionUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTransactionUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTransactionUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTransactionUpdateCallback: FfiConverterCallbackInterface() + + + + +/** + * @suppress + */ +public object FfiConverterOptionalUInt: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.UInt? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterUInt.read(buf) + } + + override fun allocationSize(value: kotlin.UInt?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterUInt.allocationSize(value) + } + } + + override fun write(value: kotlin.UInt?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterUInt.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalULong: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.ULong? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterULong.read(buf) + } + + override fun allocationSize(value: kotlin.ULong?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterULong.allocationSize(value) + } + } + + override fun write(value: kotlin.ULong?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterULong.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalBoolean: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.Boolean? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterBoolean.read(buf) + } + + override fun allocationSize(value: kotlin.Boolean?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterBoolean.allocationSize(value) + } + } + + override fun write(value: kotlin.Boolean?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterBoolean.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalString: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.String? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterString.read(buf) + } + + override fun allocationSize(value: kotlin.String?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterString.allocationSize(value) + } + } + + override fun write(value: kotlin.String?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterString.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeKeysClause.read(buf) + } + + override fun allocationSize(value: KeysClause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeKeysClause.allocationSize(value) + } + } + + override fun write(value: KeysClause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeKeysClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeTransactionFilter.read(buf) + } + + override fun allocationSize(value: TransactionFilter?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeTransactionFilter.allocationSize(value) + } + } + + override fun write(value: TransactionFilter?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeTransactionFilter.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Clause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeClause.read(buf) + } + + override fun allocationSize(value: Clause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeClause.allocationSize(value) + } + } + + override fun write(value: Clause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeFieldElement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FieldElement? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeFieldElement.read(buf) + } + + override fun allocationSize(value: FieldElement?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeFieldElement.allocationSize(value) + } + } + + override fun write(value: FieldElement?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeFieldElement.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeU256: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): U256? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeU256.read(buf) + } + + override fun allocationSize(value: U256?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeU256.allocationSize(value) + } + } + + override fun write(value: U256?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeU256.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceUByte: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterUByte.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterUByte.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterUByte.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceString: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterString.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterString.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievementTask: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievementTask.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievementTask.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievementTask.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActionCount: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActionCount.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActionCount.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActionCount.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActivity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActivity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActivity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActivity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAggregationEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAggregationEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAggregationEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAggregationEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAttributeFilter: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAttributeFilter.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAttributeFilter.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAttributeFilter.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeController: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeController.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeController.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeController.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEntity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEntity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEntity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEntity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEnumOption: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEnumOption.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEnumOption.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEnumOption.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEvent: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEvent.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEvent.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEvent.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeKeysClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeKeysClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeKeysClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeKeysClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMember: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMember.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMember.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMember.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMessage: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMessage.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMessage.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMessage.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeModel: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeModel.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeModel.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeModel.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeOrderBy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeOrderBy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeOrderBy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeOrderBy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlField: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlField.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlField.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlField.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlRow: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlRow.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlRow.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlRow.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeStruct: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeStruct.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeStruct.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeStruct.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTaskProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTaskProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTaskProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTaskProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeToken: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeToken.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeToken.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeToken.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenBalance: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenBalance.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenBalance.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenBalance.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenTransfer: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenTransfer.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenTransfer.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenTransfer.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransaction: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransaction.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransaction.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransaction.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransactionCall: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransactionCall.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransactionCall.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransactionCall.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeWorld: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeWorld.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeWorld.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeWorld.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContractType: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContractType.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContractType.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContractType.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMemberValue: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMemberValue.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMemberValue.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMemberValue.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceOptionalTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterOptionalTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterOptionalTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterOptionalTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeU256: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeU256.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeU256.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeU256.write(it, buf) + } + } +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias FieldElement = kotlin.String +public typealias FfiConverterTypeFieldElement = FfiConverterString + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias U256 = kotlin.String +public typealias FfiConverterTypeU256 = FfiConverterString + diff --git a/examples/kotlin/build-simple/jna-5.13.0.jar b/examples/kotlin/build-simple/jna-5.13.0.jar new file mode 100644 index 0000000..3d49c81 Binary files /dev/null and b/examples/kotlin/build-simple/jna-5.13.0.jar differ diff --git a/examples/kotlin/build-simple/libdojo_uniffi.dylib b/examples/kotlin/build-simple/libdojo_uniffi.dylib new file mode 100755 index 0000000..9f42b15 Binary files /dev/null and b/examples/kotlin/build-simple/libdojo_uniffi.dylib differ diff --git a/examples/kotlin/build/FetchEntities.kt b/examples/kotlin/build/FetchEntities.kt new file mode 100644 index 0000000..e7f1376 --- /dev/null +++ b/examples/kotlin/build/FetchEntities.kt @@ -0,0 +1,95 @@ +/** + * Example: Fetch entities from a Torii server + * + * This example demonstrates how to use the Dojo Kotlin bindings to: + * 1. Connect to a Torii server + * 2. Query entities with pagination + * 3. Display entity data + */ + +package com.dojoengine.examples + +import com.dojoengine.dojo.* + +fun fetchEntities(toriiUrl: String, worldAddress: String) { + println("Connecting to Torii at $toriiUrl...") + + // Create a client with default configuration (4MB max message size) + val client = ToriiClient(toriiUrl) + + println("✓ Connected successfully!") + + // Create a query to fetch entities + val query = Query( + worldAddresses = emptyList(), + pagination = Pagination( + cursor = null, // Start from beginning + limit = 10u, // Fetch 10 entities + direction = PaginationDirection.FORWARD, + orderBy = emptyList() // No specific ordering + ), + clause = null, // No filtering clause + noHashedKeys = false, + models = emptyList(), // Empty means all models + historical = false + ) + + println("\nFetching entities...") + val page = client.entities(query) + + println("\n✓ Retrieved ${page.items.size} entities") + + if (page.nextCursor != null) { + val cursorPreview = page.nextCursor.take(20) + println("Next cursor available: $cursorPreview...") + } else { + println("No more pages available") + } + + // Display entity information + page.items.forEachIndexed { i, entity -> + println("\n${"=".repeat(60)}") + println("Entity ${i + 1}:") + println(" World Address: ${entity.worldAddress}") + println(" Hashed Keys: ${entity.hashedKeys}") + println(" Created At: ${entity.createdAt}") + println(" Updated At: ${entity.updatedAt}") + println(" Executed At: ${entity.executedAt}") + println(" Models: ${entity.models.size} model(s)") + + // Display model information + entity.models.forEachIndexed { j, model -> + println("\n Model ${j + 1}: ${model.name}") + println(" Children: ${model.children.size} field(s)") + + // Show first 3 fields + model.children.take(3).forEach { child -> + println(" - ${child.name} (key=${child.key})") + } + + if (model.children.size > 3) { + println(" ... and ${model.children.size - 3} more") + } + } + } + + println("\n${"=".repeat(60)}\n") +} + +fun main(args: Array) { + val toriiUrl = args.getOrNull(0) ?: "http://localhost:8080" + val worldAddress = args.getOrNull(1) ?: "0x0" + + println("Dojo Kotlin Example: Fetch Entities") + println("====================================\n") + + try { + fetchEntities(toriiUrl, worldAddress) + } catch (e: Exception) { + println("\n❌ Error: ${e.message}") + println("\nUsage: kotlin FetchEntities.kt [torii_url] [world_address]") + println("Example: kotlin FetchEntities.kt http://localhost:8080 0x1234...") + System.exit(1) + } +} + diff --git a/examples/kotlin/build/com/dojoengine/dojo/dojo.kt b/examples/kotlin/build/com/dojoengine/dojo/dojo.kt new file mode 100644 index 0000000..360551d --- /dev/null +++ b/examples/kotlin/build/com/dojoengine/dojo/dojo.kt @@ -0,0 +1,8423 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +@file:Suppress("NAME_SHADOWING") + +package com.dojoengine.dojo + +// Common helper code. +// +// Ideally this would live in a separate .kt file where it can be unittested etc +// in isolation, and perhaps even published as a re-useable package. +// +// However, it's important that the details of how this helper code works (e.g. the +// way that different builtin types are passed across the FFI) exactly match what's +// expected by the Rust code on the other side of the interface. In practice right +// now that means coming from the exact some version of `uniffi` that was used to +// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin +// helpers directly inline like we're doing here. + +import com.sun.jna.Library +import com.sun.jna.IntegerType +import com.sun.jna.Native +import com.sun.jna.Pointer +import com.sun.jna.Structure +import com.sun.jna.Callback +import com.sun.jna.ptr.* +import java.nio.ByteBuffer +import java.nio.ByteOrder +import java.nio.CharBuffer +import java.nio.charset.CodingErrorAction +import java.util.concurrent.atomic.AtomicLong +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicBoolean + +// This is a helper for safely working with byte buffers returned from the Rust code. +// A rust-owned buffer is represented by its capacity, its current length, and a +// pointer to the underlying data. + +/** + * @suppress + */ +@Structure.FieldOrder("capacity", "len", "data") +open class RustBuffer : Structure() { + // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values. + // When dealing with these fields, make sure to call `toULong()`. + @JvmField var capacity: Long = 0 + @JvmField var len: Long = 0 + @JvmField var data: Pointer? = null + + class ByValue: RustBuffer(), Structure.ByValue + class ByReference: RustBuffer(), Structure.ByReference + + internal fun setValue(other: RustBuffer) { + capacity = other.capacity + len = other.len + data = other.data + } + + companion object { + internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status -> + // Note: need to convert the size to a `Long` value to make this work with JVM. + UniffiLib.ffi_dojo_uniffi_rustbuffer_alloc(size.toLong(), status) + }.also { + if(it.data == null) { + throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") + } + } + + internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue { + var buf = RustBuffer.ByValue() + buf.capacity = capacity.toLong() + buf.len = len.toLong() + buf.data = data + return buf + } + + internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status -> + UniffiLib.ffi_dojo_uniffi_rustbuffer_free(buf, status) + } + } + + @Suppress("TooGenericExceptionThrown") + fun asByteBuffer() = + this.data?.getByteBuffer(0, this.len.toLong())?.also { + it.order(ByteOrder.BIG_ENDIAN) + } +} + +// This is a helper for safely passing byte references into the rust code. +// It's not actually used at the moment, because there aren't many things that you +// can take a direct pointer to in the JVM, and if we're going to copy something +// then we might as well copy it into a `RustBuffer`. But it's here for API +// completeness. + +@Structure.FieldOrder("len", "data") +internal open class ForeignBytes : Structure() { + @JvmField var len: Int = 0 + @JvmField var data: Pointer? = null + + class ByValue : ForeignBytes(), Structure.ByValue +} +/** + * The FfiConverter interface handles converter types to and from the FFI + * + * All implementing objects should be public to support external types. When a + * type is external we need to import it's FfiConverter. + * + * @suppress + */ +public interface FfiConverter { + // Convert an FFI type to a Kotlin type + fun lift(value: FfiType): KotlinType + + // Convert an Kotlin type to an FFI type + fun lower(value: KotlinType): FfiType + + // Read a Kotlin type from a `ByteBuffer` + fun read(buf: ByteBuffer): KotlinType + + // Calculate bytes to allocate when creating a `RustBuffer` + // + // This must return at least as many bytes as the write() function will + // write. It can return more bytes than needed, for example when writing + // Strings we can't know the exact bytes needed until we the UTF-8 + // encoding, so we pessimistically allocate the largest size possible (3 + // bytes per codepoint). Allocating extra bytes is not really a big deal + // because the `RustBuffer` is short-lived. + fun allocationSize(value: KotlinType): ULong + + // Write a Kotlin type to a `ByteBuffer` + fun write(value: KotlinType, buf: ByteBuffer) + + // Lower a value into a `RustBuffer` + // + // This method lowers a value into a `RustBuffer` rather than the normal + // FfiType. It's used by the callback interface code. Callback interface + // returns are always serialized into a `RustBuffer` regardless of their + // normal FFI type. + fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue { + val rbuf = RustBuffer.alloc(allocationSize(value)) + try { + val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also { + it.order(ByteOrder.BIG_ENDIAN) + } + write(value, bbuf) + rbuf.writeField("len", bbuf.position().toLong()) + return rbuf + } catch (e: Throwable) { + RustBuffer.free(rbuf) + throw e + } + } + + // Lift a value from a `RustBuffer`. + // + // This here mostly because of the symmetry with `lowerIntoRustBuffer()`. + // It's currently only used by the `FfiConverterRustBuffer` class below. + fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType { + val byteBuf = rbuf.asByteBuffer()!! + try { + val item = read(byteBuf) + if (byteBuf.hasRemaining()) { + throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!") + } + return item + } finally { + RustBuffer.free(rbuf) + } + } +} + +/** + * FfiConverter that uses `RustBuffer` as the FfiType + * + * @suppress + */ +public interface FfiConverterRustBuffer: FfiConverter { + override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value) + override fun lower(value: KotlinType) = lowerIntoRustBuffer(value) +} +// A handful of classes and functions to support the generated data structures. +// This would be a good candidate for isolating in its own ffi-support lib. + +internal const val UNIFFI_CALL_SUCCESS = 0.toByte() +internal const val UNIFFI_CALL_ERROR = 1.toByte() +internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte() + +@Structure.FieldOrder("code", "error_buf") +internal open class UniffiRustCallStatus : Structure() { + @JvmField var code: Byte = 0 + @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue() + + class ByValue: UniffiRustCallStatus(), Structure.ByValue + + fun isSuccess(): Boolean { + return code == UNIFFI_CALL_SUCCESS + } + + fun isError(): Boolean { + return code == UNIFFI_CALL_ERROR + } + + fun isPanic(): Boolean { + return code == UNIFFI_CALL_UNEXPECTED_ERROR + } + + companion object { + fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue { + val callStatus = UniffiRustCallStatus.ByValue() + callStatus.code = code + callStatus.error_buf = errorBuf + return callStatus + } + } +} + +class InternalException(message: String) : kotlin.Exception(message) + +/** + * Each top-level error class has a companion object that can lift the error from the call status's rust buffer + * + * @suppress + */ +interface UniffiRustCallStatusErrorHandler { + fun lift(error_buf: RustBuffer.ByValue): E; +} + +// Helpers for calling Rust +// In practice we usually need to be synchronized to call this safely, so it doesn't +// synchronize itself + +// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err +private inline fun uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler, callback: (UniffiRustCallStatus) -> U): U { + var status = UniffiRustCallStatus() + val return_value = callback(status) + uniffiCheckCallStatus(errorHandler, status) + return return_value +} + +// Check UniffiRustCallStatus and throw an error if the call wasn't successful +private fun uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler, status: UniffiRustCallStatus) { + if (status.isSuccess()) { + return + } else if (status.isError()) { + throw errorHandler.lift(status.error_buf) + } else if (status.isPanic()) { + // when the rust code sees a panic, it tries to construct a rustbuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if (status.error_buf.len > 0) { + throw InternalException(FfiConverterString.lift(status.error_buf)) + } else { + throw InternalException("Rust panic") + } + } else { + throw InternalException("Unknown rust call status: $status.code") + } +} + +/** + * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR + * + * @suppress + */ +object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): InternalException { + RustBuffer.free(error_buf) + return InternalException("Unexpected CALL_ERROR") + } +} + +// Call a rust function that returns a plain value +private inline fun uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U { + return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback) +} + +internal inline fun uniffiTraitInterfaceCall( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } +} + +internal inline fun uniffiTraitInterfaceCallWithError( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, + lowerError: (E) -> RustBuffer.ByValue +) { + try { + writeReturn(makeCall()) + } catch(e: kotlin.Exception) { + if (e is E) { + callStatus.code = UNIFFI_CALL_ERROR + callStatus.error_buf = lowerError(e) + } else { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } + } +} +// Initial value and increment amount for handles. +// These ensure that Kotlin-generated handles always have the lowest bit set +private const val UNIFFI_HANDLEMAP_INITIAL = 1.toLong() +private const val UNIFFI_HANDLEMAP_DELTA = 2.toLong() + +// Map handles to objects +// +// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code. +internal class UniffiHandleMap { + private val map = ConcurrentHashMap() + // Start + private val counter = java.util.concurrent.atomic.AtomicLong(UNIFFI_HANDLEMAP_INITIAL) + + val size: Int + get() = map.size + + // Insert a new object into the handle map and get a handle for it + fun insert(obj: T): Long { + val handle = counter.getAndAdd(UNIFFI_HANDLEMAP_DELTA) + map.put(handle, obj) + return handle + } + + // Clone a handle, creating a new one + fun clone(handle: Long): Long { + val obj = map.get(handle) ?: throw InternalException("UniffiHandleMap.clone: Invalid handle") + return insert(obj) + } + + // Get an object from the handle map + fun get(handle: Long): T { + return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle") + } + + // Remove an entry from the handlemap and get the Kotlin object back + fun remove(handle: Long): T { + return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle") + } +} + +// Contains loading, initialization code, +// and the FFI Function declarations in a com.sun.jna.Library. +@Synchronized +private fun findLibraryName(componentName: String): String { + val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride") + if (libOverride != null) { + return libOverride + } + return "dojo_uniffi" +} + +// Define FFI callback types +internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback { + fun callback(`data`: Long,`pollResult`: Byte,) +} +internal interface UniffiForeignFutureDroppedCallback : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceClone : com.sun.jna.Callback { + fun callback(`handle`: Long,) + : Long +} +@Structure.FieldOrder("handle", "free") +internal open class UniffiForeignFutureDroppedCallbackStruct( + @JvmField internal var `handle`: Long = 0.toLong(), + @JvmField internal var `free`: UniffiForeignFutureDroppedCallback? = null, +) : Structure() { + class UniffiByValue( + `handle`: Long = 0.toLong(), + `free`: UniffiForeignFutureDroppedCallback? = null, + ): UniffiForeignFutureDroppedCallbackStruct(`handle`,`free`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureDroppedCallbackStruct) { + `handle` = other.`handle` + `free` = other.`free` + } + +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI8( + @JvmField internal var `returnValue`: Byte = 0.toByte(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Byte = 0.toByte(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI8(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI8) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI8.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI16( + @JvmField internal var `returnValue`: Short = 0.toShort(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Short = 0.toShort(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI16(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI16) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI16.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI32( + @JvmField internal var `returnValue`: Int = 0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Int = 0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultU64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultU64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultU64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultI64( + @JvmField internal var `returnValue`: Long = 0.toLong(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Long = 0.toLong(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultI64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultI64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF32( + @JvmField internal var `returnValue`: Float = 0.0f, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Float = 0.0f, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF32(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF32) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF32.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultF64( + @JvmField internal var `returnValue`: Double = 0.0, + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: Double = 0.0, + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultF64(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultF64) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF64.UniffiByValue,) +} +@Structure.FieldOrder("returnValue", "callStatus") +internal open class UniffiForeignFutureResultRustBuffer( + @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultRustBuffer) { + `returnValue` = other.`returnValue` + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultRustBuffer.UniffiByValue,) +} +@Structure.FieldOrder("callStatus") +internal open class UniffiForeignFutureResultVoid( + @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), +) : Structure() { + class UniffiByValue( + `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), + ): UniffiForeignFutureResultVoid(`callStatus`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFutureResultVoid) { + `callStatus` = other.`callStatus` + } + +} +internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultVoid.UniffiByValue,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEntityUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceEventUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTokenUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEntityUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEntityUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEntityUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceEventUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceEventUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEventUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTokenUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTokenUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTokenUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} +@Structure.FieldOrder("uniffiFree", "uniffiClone", "onUpdate", "onError") +internal open class UniffiVTableCallbackInterfaceTransactionUpdateCallback( + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, + @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null, + @JvmField internal var `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + @JvmField internal var `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, +) : Structure() { + class UniffiByValue( + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + `uniffiClone`: UniffiCallbackInterfaceClone? = null, + `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0? = null, + `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1? = null, + ): UniffiVTableCallbackInterfaceTransactionUpdateCallback(`uniffiFree`,`uniffiClone`,`onUpdate`,`onError`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTransactionUpdateCallback) { + `uniffiFree` = other.`uniffiFree` + `uniffiClone` = other.`uniffiClone` + `onUpdate` = other.`onUpdate` + `onError` = other.`onError` + } + +} + +// A JNA Library to expose the extern-C FFI definitions. +// This is an implementation detail which will be called internally by the public API. + +// For large crates we prevent `MethodTooLargeException` (see #2340) +// N.B. the name of the extension is very misleading, since it is +// rather `InterfaceTooLargeException`, caused by too many methods +// in the interface for large crates. +// +// By splitting the otherwise huge interface into two parts +// * UniffiLib (this) +// * IntegrityCheckingUniffiLib +// And all checksum methods are put into `IntegrityCheckingUniffiLib` +// we allow for ~2x as many methods in the UniffiLib interface. +// +// Note: above all written when we used JNA's `loadIndirect` etc. +// We now use JNA's "direct mapping" - unclear if same considerations apply exactly. +internal object IntegrityCheckingUniffiLib { + init { + Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCheckContractApiVersion(this) + uniffiCheckApiChecksums(this) + } + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_activities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_controllers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_entities( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_sql( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_tokens( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_transactions( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_toriiclient_worlds( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new( + ): Short + external fun uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update( + ): Short + external fun uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error( + ): Short + external fun ffi_dojo_uniffi_uniffi_contract_version( + ): Int + + +} + +internal object UniffiLib { + + // The Cleaner for the whole library + internal val CLEANER: UniffiCleaner by lazy { + UniffiCleaner.create() + } + + + init { + Native.register(UniffiLib::class.java, findLibraryName(componentName = "dojo")) + uniffiCallbackInterfaceEntityUpdateCallback.register(this) + uniffiCallbackInterfaceEventUpdateCallback.register(this) + uniffiCallbackInterfaceTokenBalanceUpdateCallback.register(this) + uniffiCallbackInterfaceTokenUpdateCallback.register(this) + uniffiCallbackInterfaceTransactionUpdateCallback.register(this) + + } + external fun uniffi_dojo_uniffi_fn_clone_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_free_toriiclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new(`toriiUrl`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config(`toriiUrl`: RustBuffer.ByValue,`maxMessageSize`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_activities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_aggregations(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription(`ptr`: Long,`subscriptionId`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun uniffi_dojo_uniffi_fn_method_toriiclient_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_controllers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_entities(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_event_messages(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message(`ptr`: Long,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch(`ptr`: Long,`messages`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_sql(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates(`ptr`: Long,`clause`: RustBuffer.ByValue,`worldAddresses`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates(`ptr`: Long,`keys`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`accountAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates(`ptr`: Long,`contractAddresses`: RustBuffer.ByValue,`tokenIds`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates(`ptr`: Long,`filter`: RustBuffer.ByValue,`callback`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_balances(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_tokens(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_transactions(`ptr`: Long,`query`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_method_toriiclient_worlds(`ptr`: Long,`worldAddresses`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEntityUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(`vtable`: UniffiVTableCallbackInterfaceEventUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTokenUpdateCallback, +): Unit +external fun uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(`vtable`: UniffiVTableCallbackInterfaceTransactionUpdateCallback, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Unit +external fun ffi_dojo_uniffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i8(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Byte +external fun ffi_dojo_uniffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i16(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Short +external fun ffi_dojo_uniffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Int +external fun ffi_dojo_uniffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_u64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_i64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Long +external fun ffi_dojo_uniffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f32(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Float +external fun ffi_dojo_uniffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_f64(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Double +external fun ffi_dojo_uniffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_rust_buffer(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +external fun ffi_dojo_uniffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_cancel_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_free_void(`handle`: Long, +): Unit +external fun ffi_dojo_uniffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, +): Unit + + +} + +private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) { + // Get the bindings contract version from our ComponentInterface + val bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + val scaffolding_contract_version = lib.ffi_dojo_uniffi_uniffi_contract_version() + if (bindings_contract_version != scaffolding_contract_version) { + throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project") + } +} +@Suppress("UNUSED_PARAMETER") +private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_achievements() != 45327.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_activities() != 43349.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_aggregations() != 12858.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_cancel_subscription() != 31182.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_contracts() != 1861.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_controllers() != 55573.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_entities() != 50647.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_event_messages() != 35425.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_player_achievements() != 61773.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message() != 30179.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch() != 2146.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_sql() != 38286.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_starknet_events() != 44694.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_entity_updates() != 17350.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_event_updates() != 63983.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_balance_updates() != 26741.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_token_updates() != 54836.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_subscribe_transaction_updates() != 10040.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_balances() != 1716.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_contracts() != 49563.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_token_transfers() != 10363.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_tokens() != 10630.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_transactions() != 46460.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_toriiclient_worlds() != 23254.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new() != 18057.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_constructor_toriiclient_new_with_config() != 42232.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_update() != 15850.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_entityupdatecallback_on_error() != 340.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_update() != 13627.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_eventupdatecallback_on_error() != 61050.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_update() != 10763.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenbalanceupdatecallback_on_error() != 46610.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_update() != 40037.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_tokenupdatecallback_on_error() != 14408.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_update() != 11896.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_dojo_uniffi_checksum_method_transactionupdatecallback_on_error() != 18113.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +/** + * @suppress + */ +public fun uniffiEnsureInitialized() { + IntegrityCheckingUniffiLib + // UniffiLib() initialized as objects are used, but we still need to explicitly + // reference it so initialization across crates works as expected. + UniffiLib +} + +// Async support + +// Public interface members begin here. + + +// Interface implemented by anything that can contain an object reference. +// +// Such types expose a `destroy()` method that must be called to cleanly +// dispose of the contained objects. Failure to call this method may result +// in memory leaks. +// +// The easiest way to ensure this method is called is to use the `.use` +// helper method to execute a block and destroy the object at the end. +interface Disposable { + fun destroy() + companion object { + fun destroy(vararg args: Any?) { + for (arg in args) { + when (arg) { + is Disposable -> arg.destroy() + is ArrayList<*> -> { + for (idx in arg.indices) { + val element = arg[idx] + if (element is Disposable) { + element.destroy() + } + } + } + is Map<*, *> -> { + for (element in arg.values) { + if (element is Disposable) { + element.destroy() + } + } + } + is Iterable<*> -> { + for (element in arg) { + if (element is Disposable) { + element.destroy() + } + } + } + } + } + } + } +} + +/** + * @suppress + */ +inline fun T.use(block: (T) -> R) = + try { + block(this) + } finally { + try { + // N.B. our implementation is on the nullable type `Disposable?`. + this?.destroy() + } catch (e: Throwable) { + // swallow + } + } + +/** + * Placeholder object used to signal that we're constructing an interface with a FFI handle. + * + * This is the first argument for interface constructors that input a raw handle. It exists is that + * so we can avoid signature conflicts when an interface has a regular constructor than inputs a + * Long. + * + * @suppress + * */ +object UniffiWithHandle + +/** + * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly. + * + * @suppress + * */ +object NoHandle// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +internal const val IDX_CALLBACK_FREE = 0 +// Callback return codes +internal const val UNIFFI_CALLBACK_SUCCESS = 0 +internal const val UNIFFI_CALLBACK_ERROR = 1 +internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 + +/** + * @suppress + */ +public abstract class FfiConverterCallbackInterface: FfiConverter { + internal val handleMap = UniffiHandleMap() + + internal fun drop(handle: Long) { + handleMap.remove(handle) + } + + override fun lift(value: Long): CallbackInterface { + return handleMap.get(value) + } + + override fun read(buf: ByteBuffer) = lift(buf.getLong()) + + override fun lower(value: CallbackInterface) = handleMap.insert(value) + + override fun allocationSize(value: CallbackInterface) = 8UL + + override fun write(value: CallbackInterface, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} +/** + * The cleaner interface for Object finalization code to run. + * This is the entry point to any implementation that we're using. + * + * The cleaner registers objects and returns cleanables, so now we are + * defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the + * different implmentations available at compile time. + * + * @suppress + */ +interface UniffiCleaner { + interface Cleanable { + fun clean() + } + + fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable + + companion object +} + +// The fallback Jna cleaner, which is available for both Android, and the JVM. +private class UniffiJnaCleaner : UniffiCleaner { + private val cleaner = com.sun.jna.internal.Cleaner.getCleaner() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + UniffiJnaCleanable(cleaner.register(value, cleanUpTask)) +} + +private class UniffiJnaCleanable( + private val cleanable: com.sun.jna.internal.Cleaner.Cleanable, +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + + +// We decide at uniffi binding generation time whether we were +// using Android or not. +// There are further runtime checks to chose the correct implementation +// of the cleaner. +private fun UniffiCleaner.Companion.create(): UniffiCleaner = + try { + // For safety's sake: if the library hasn't been run in android_cleaner = true + // mode, but is being run on Android, then we still need to think about + // Android API versions. + // So we check if java.lang.ref.Cleaner is there, and use that… + java.lang.Class.forName("java.lang.ref.Cleaner") + JavaLangRefCleaner() + } catch (e: ClassNotFoundException) { + // … otherwise, fallback to the JNA cleaner. + UniffiJnaCleaner() + } + +private class JavaLangRefCleaner : UniffiCleaner { + val cleaner = java.lang.ref.Cleaner.create() + + override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable = + JavaLangRefCleanable(cleaner.register(value, cleanUpTask)) +} + +private class JavaLangRefCleanable( + val cleanable: java.lang.ref.Cleaner.Cleanable +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + +/** + * @suppress + */ +public object FfiConverterUByte: FfiConverter { + override fun lift(value: Byte): UByte { + return value.toUByte() + } + + override fun read(buf: ByteBuffer): UByte { + return lift(buf.get()) + } + + override fun lower(value: UByte): Byte { + return value.toByte() + } + + override fun allocationSize(value: UByte) = 1UL + + override fun write(value: UByte, buf: ByteBuffer) { + buf.put(value.toByte()) + } +} + +/** + * @suppress + */ +public object FfiConverterByte: FfiConverter { + override fun lift(value: Byte): Byte { + return value + } + + override fun read(buf: ByteBuffer): Byte { + return buf.get() + } + + override fun lower(value: Byte): Byte { + return value + } + + override fun allocationSize(value: Byte) = 1UL + + override fun write(value: Byte, buf: ByteBuffer) { + buf.put(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUShort: FfiConverter { + override fun lift(value: Short): UShort { + return value.toUShort() + } + + override fun read(buf: ByteBuffer): UShort { + return lift(buf.getShort()) + } + + override fun lower(value: UShort): Short { + return value.toShort() + } + + override fun allocationSize(value: UShort) = 2UL + + override fun write(value: UShort, buf: ByteBuffer) { + buf.putShort(value.toShort()) + } +} + +/** + * @suppress + */ +public object FfiConverterShort: FfiConverter { + override fun lift(value: Short): Short { + return value + } + + override fun read(buf: ByteBuffer): Short { + return buf.getShort() + } + + override fun lower(value: Short): Short { + return value + } + + override fun allocationSize(value: Short) = 2UL + + override fun write(value: Short, buf: ByteBuffer) { + buf.putShort(value) + } +} + +/** + * @suppress + */ +public object FfiConverterUInt: FfiConverter { + override fun lift(value: Int): UInt { + return value.toUInt() + } + + override fun read(buf: ByteBuffer): UInt { + return lift(buf.getInt()) + } + + override fun lower(value: UInt): Int { + return value.toInt() + } + + override fun allocationSize(value: UInt) = 4UL + + override fun write(value: UInt, buf: ByteBuffer) { + buf.putInt(value.toInt()) + } +} + +/** + * @suppress + */ +public object FfiConverterInt: FfiConverter { + override fun lift(value: Int): Int { + return value + } + + override fun read(buf: ByteBuffer): Int { + return buf.getInt() + } + + override fun lower(value: Int): Int { + return value + } + + override fun allocationSize(value: Int) = 4UL + + override fun write(value: Int, buf: ByteBuffer) { + buf.putInt(value) + } +} + +/** + * @suppress + */ +public object FfiConverterULong: FfiConverter { + override fun lift(value: Long): ULong { + return value.toULong() + } + + override fun read(buf: ByteBuffer): ULong { + return lift(buf.getLong()) + } + + override fun lower(value: ULong): Long { + return value.toLong() + } + + override fun allocationSize(value: ULong) = 8UL + + override fun write(value: ULong, buf: ByteBuffer) { + buf.putLong(value.toLong()) + } +} + +/** + * @suppress + */ +public object FfiConverterLong: FfiConverter { + override fun lift(value: Long): Long { + return value + } + + override fun read(buf: ByteBuffer): Long { + return buf.getLong() + } + + override fun lower(value: Long): Long { + return value + } + + override fun allocationSize(value: Long) = 8UL + + override fun write(value: Long, buf: ByteBuffer) { + buf.putLong(value) + } +} + +/** + * @suppress + */ +public object FfiConverterDouble: FfiConverter { + override fun lift(value: Double): Double { + return value + } + + override fun read(buf: ByteBuffer): Double { + return buf.getDouble() + } + + override fun lower(value: Double): Double { + return value + } + + override fun allocationSize(value: Double) = 8UL + + override fun write(value: Double, buf: ByteBuffer) { + buf.putDouble(value) + } +} + +/** + * @suppress + */ +public object FfiConverterBoolean: FfiConverter { + override fun lift(value: Byte): Boolean { + return value.toInt() != 0 + } + + override fun read(buf: ByteBuffer): Boolean { + return lift(buf.get()) + } + + override fun lower(value: Boolean): Byte { + return if (value) 1.toByte() else 0.toByte() + } + + override fun allocationSize(value: Boolean) = 1UL + + override fun write(value: Boolean, buf: ByteBuffer) { + buf.put(lower(value)) + } +} + +/** + * @suppress + */ +public object FfiConverterString: FfiConverter { + // Note: we don't inherit from FfiConverterRustBuffer, because we use a + // special encoding when lowering/lifting. We can use `RustBuffer.len` to + // store our length and avoid writing it out to the buffer. + override fun lift(value: RustBuffer.ByValue): String { + try { + val byteArr = ByteArray(value.len.toInt()) + value.asByteBuffer()!!.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } finally { + RustBuffer.free(value) + } + } + + override fun read(buf: ByteBuffer): String { + val len = buf.getInt() + val byteArr = ByteArray(len) + buf.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } + + fun toUtf8(value: String): ByteBuffer { + // Make sure we don't have invalid UTF-16, check for lone surrogates. + return Charsets.UTF_8.newEncoder().run { + onMalformedInput(CodingErrorAction.REPORT) + encode(CharBuffer.wrap(value)) + } + } + + override fun lower(value: String): RustBuffer.ByValue { + val byteBuf = toUtf8(value) + // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us + // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`. + val rbuf = RustBuffer.alloc(byteBuf.limit().toULong()) + rbuf.asByteBuffer()!!.put(byteBuf) + return rbuf + } + + // We aren't sure exactly how many bytes our string will be once it's UTF-8 + // encoded. Allocate 3 bytes per UTF-16 code unit which will always be + // enough. + override fun allocationSize(value: String): ULong { + val sizeForLength = 4UL + val sizeForString = value.length.toULong() * 3UL + return sizeForLength + sizeForString + } + + override fun write(value: String, buf: ByteBuffer) { + val byteBuf = toUtf8(value) + buf.putInt(byteBuf.limit()) + buf.put(byteBuf) + } +} + + +// This template implements a class for working with a Rust struct via a handle +// to the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque handle to the underlying Rust struct. +// Method calls need to read this handle from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its handle should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the handle, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the handle, but is interrupted +// before it can pass the handle over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read handle value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +// +public interface ToriiClientInterface { + + fun `achievements`(`query`: AchievementQuery): PageAchievement + + fun `activities`(`query`: ActivityQuery): PageActivity + + fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry + + fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + + fun `contracts`(`query`: ContractQuery): List + + fun `controllers`(`query`: ControllerQuery): PageController + + fun `entities`(`query`: Query): PageEntity + + fun `eventMessages`(`query`: Query): PageEntity + + fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement + + fun `publishMessage`(`message`: Message): kotlin.String + + fun `publishMessageBatch`(`messages`: List): List + + fun `sql`(`query`: kotlin.String): List + + fun `starknetEvents`(`query`: EventQuery): PageEvent + + fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong + + fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong + + fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong + + fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong + + fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong + + fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance + + fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract + + fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer + + fun `tokens`(`query`: TokenQuery): PageToken + + fun `transactions`(`query`: TransactionQuery): PageTransaction + + fun `worlds`(`worldAddresses`: List): List + + companion object +} + +open class ToriiClient: Disposable, AutoCloseable, ToriiClientInterface +{ + + @Suppress("UNUSED_PARAMETER") + /** + * @suppress + */ + constructor(withHandle: UniffiWithHandle, handle: Long) { + this.handle = handle + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + + /** + * @suppress + * + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noHandle: NoHandle) { + this.handle = 0 + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) + } + constructor(`toriiUrl`: kotlin.String) : + this(UniffiWithHandle, + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new( + + FfiConverterString.lower(`toriiUrl`),_status) +} + ) + + protected val handle: Long + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithHandle(block: (handle: Long) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the handle being freed concurrently. + try { + return block(this.uniffiCloneHandle()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val handle: Long) : Runnable { + override fun run() { + if (handle == 0.toLong()) { + // Fake object created with `NoHandle`, don't try to free. + return; + } + uniffiRustCall { status -> + UniffiLib.uniffi_dojo_uniffi_fn_free_toriiclient(handle, status) + } + } + } + + /** + * @suppress + */ + fun uniffiCloneHandle(): Long { + if (handle == 0.toLong()) { + throw InternalException("uniffiCloneHandle() called on NoHandle object"); + } + return uniffiRustCall() { status -> + UniffiLib.uniffi_dojo_uniffi_fn_clone_toriiclient(handle, status) + } + } + + + @Throws(DojoException::class)override fun `achievements`(`query`: AchievementQuery): PageAchievement { + return FfiConverterTypePageAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_achievements( + it, + FfiConverterTypeAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `activities`(`query`: ActivityQuery): PageActivity { + return FfiConverterTypePageActivity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_activities( + it, + FfiConverterTypeActivityQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `aggregations`(`query`: AggregationQuery): PageAggregationEntry { + return FfiConverterTypePageAggregationEntry.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_aggregations( + it, + FfiConverterTypeAggregationQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `cancelSubscription`(`subscriptionId`: kotlin.ULong) + = + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_cancel_subscription( + it, + FfiConverterULong.lower(`subscriptionId`),_status) +} + } + + + + + @Throws(DojoException::class)override fun `contracts`(`query`: ContractQuery): List { + return FfiConverterSequenceTypeContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_contracts( + it, + FfiConverterTypeContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `controllers`(`query`: ControllerQuery): PageController { + return FfiConverterTypePageController.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_controllers( + it, + FfiConverterTypeControllerQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `entities`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_entities( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `eventMessages`(`query`: Query): PageEntity { + return FfiConverterTypePageEntity.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_event_messages( + it, + FfiConverterTypeQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `playerAchievements`(`query`: PlayerAchievementQuery): PagePlayerAchievement { + return FfiConverterTypePagePlayerAchievement.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_player_achievements( + it, + FfiConverterTypePlayerAchievementQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessage`(`message`: Message): kotlin.String { + return FfiConverterString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message( + it, + FfiConverterTypeMessage.lower(`message`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `publishMessageBatch`(`messages`: List): List { + return FfiConverterSequenceString.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch( + it, + FfiConverterSequenceTypeMessage.lower(`messages`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `sql`(`query`: kotlin.String): List { + return FfiConverterSequenceTypeSqlRow.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_sql( + it, + FfiConverterString.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `starknetEvents`(`query`: EventQuery): PageEvent { + return FfiConverterTypePageEvent.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_starknet_events( + it, + FfiConverterTypeEventQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEntityUpdates`(`clause`: Clause?, `worldAddresses`: List, `callback`: EntityUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_entity_updates( + it, + FfiConverterOptionalTypeClause.lower(`clause`),FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),FfiConverterTypeEntityUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeEventUpdates`(`keys`: List, `callback`: EventUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_event_updates( + it, + FfiConverterSequenceTypeKeysClause.lower(`keys`),FfiConverterTypeEventUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenBalanceUpdates`(`contractAddresses`: List, `accountAddresses`: List, `tokenIds`: List, `callback`: TokenBalanceUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_balance_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeFieldElement.lower(`accountAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenBalanceUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTokenUpdates`(`contractAddresses`: List, `tokenIds`: List, `callback`: TokenUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_token_updates( + it, + FfiConverterSequenceTypeFieldElement.lower(`contractAddresses`),FfiConverterSequenceTypeU256.lower(`tokenIds`),FfiConverterTypeTokenUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `subscribeTransactionUpdates`(`filter`: TransactionFilter?, `callback`: TransactionUpdateCallback): kotlin.ULong { + return FfiConverterULong.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_subscribe_transaction_updates( + it, + FfiConverterOptionalTypeTransactionFilter.lower(`filter`),FfiConverterTypeTransactionUpdateCallback.lower(`callback`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenBalances`(`query`: TokenBalanceQuery): PageTokenBalance { + return FfiConverterTypePageTokenBalance.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_balances( + it, + FfiConverterTypeTokenBalanceQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenContracts`(`query`: TokenContractQuery): PageTokenContract { + return FfiConverterTypePageTokenContract.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_contracts( + it, + FfiConverterTypeTokenContractQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokenTransfers`(`query`: TokenTransferQuery): PageTokenTransfer { + return FfiConverterTypePageTokenTransfer.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_token_transfers( + it, + FfiConverterTypeTokenTransferQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `tokens`(`query`: TokenQuery): PageToken { + return FfiConverterTypePageToken.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_tokens( + it, + FfiConverterTypeTokenQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `transactions`(`query`: TransactionQuery): PageTransaction { + return FfiConverterTypePageTransaction.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_transactions( + it, + FfiConverterTypeTransactionQuery.lower(`query`),_status) +} + } + ) + } + + + + @Throws(DojoException::class)override fun `worlds`(`worldAddresses`: List): List { + return FfiConverterSequenceTypeWorld.lift( + callWithHandle { + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_method_toriiclient_worlds( + it, + FfiConverterSequenceTypeFieldElement.lower(`worldAddresses`),_status) +} + } + ) + } + + + + + + + + + companion object { + + @Throws(DojoException::class) fun `newWithConfig`(`toriiUrl`: kotlin.String, `maxMessageSize`: kotlin.ULong): ToriiClient { + return FfiConverterTypeToriiClient.lift( + uniffiRustCallWithError(DojoException) { _status -> + UniffiLib.uniffi_dojo_uniffi_fn_constructor_toriiclient_new_with_config( + + FfiConverterString.lower(`toriiUrl`),FfiConverterULong.lower(`maxMessageSize`),_status) +} + ) + } + + + + } + +} + + +/** + * @suppress + */ +public object FfiConverterTypeToriiClient: FfiConverter { + override fun lower(value: ToriiClient): Long { + return value.uniffiCloneHandle() + } + + override fun lift(value: Long): ToriiClient { + return ToriiClient(UniffiWithHandle, value) + } + + override fun read(buf: ByteBuffer): ToriiClient { + return lift(buf.getLong()) + } + + override fun allocationSize(value: ToriiClient) = 8UL + + override fun write(value: ToriiClient, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} + + + +data class Achievement ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `entityId`: kotlin.String + , + val `hidden`: kotlin.Boolean + , + val `index`: kotlin.UInt + , + val `points`: kotlin.UInt + , + val `start`: kotlin.String + , + val `end`: kotlin.String + , + val `group`: kotlin.String + , + val `icon`: kotlin.String + , + val `title`: kotlin.String + , + val `description`: kotlin.String + , + val `tasks`: List + , + val `data`: kotlin.String? + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Achievement { + return Achievement( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeAchievementTask.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Achievement) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterBoolean.allocationSize(value.`hidden`) + + FfiConverterUInt.allocationSize(value.`index`) + + FfiConverterUInt.allocationSize(value.`points`) + + FfiConverterString.allocationSize(value.`start`) + + FfiConverterString.allocationSize(value.`end`) + + FfiConverterString.allocationSize(value.`group`) + + FfiConverterString.allocationSize(value.`icon`) + + FfiConverterString.allocationSize(value.`title`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterSequenceTypeAchievementTask.allocationSize(value.`tasks`) + + FfiConverterOptionalString.allocationSize(value.`data`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Achievement, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterBoolean.write(value.`hidden`, buf) + FfiConverterUInt.write(value.`index`, buf) + FfiConverterUInt.write(value.`points`, buf) + FfiConverterString.write(value.`start`, buf) + FfiConverterString.write(value.`end`, buf) + FfiConverterString.write(value.`group`, buf) + FfiConverterString.write(value.`icon`, buf) + FfiConverterString.write(value.`title`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterSequenceTypeAchievementTask.write(value.`tasks`, buf) + FfiConverterOptionalString.write(value.`data`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementProgression ( + val `id`: kotlin.String + , + val `achievementId`: kotlin.String + , + val `taskId`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `playerId`: FieldElement + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + , + val `completedAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementProgression: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementProgression { + return AchievementProgression( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementProgression) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`achievementId`) + + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`playerId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterOptionalULong.allocationSize(value.`completedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AchievementProgression, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`achievementId`, buf) + FfiConverterString.write(value.`taskId`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`playerId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterOptionalULong.write(value.`completedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `hidden`: kotlin.Boolean? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementQuery { + return AchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterOptionalBoolean.allocationSize(value.`hidden`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterOptionalBoolean.write(value.`hidden`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AchievementTask ( + val `taskId`: kotlin.String + , + val `description`: kotlin.String + , + val `total`: kotlin.UInt + , + val `totalCompletions`: kotlin.UInt + , + val `completionRate`: kotlin.Double + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAchievementTask: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AchievementTask { + return AchievementTask( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AchievementTask) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterString.allocationSize(value.`description`) + + FfiConverterUInt.allocationSize(value.`total`) + + FfiConverterUInt.allocationSize(value.`totalCompletions`) + + FfiConverterDouble.allocationSize(value.`completionRate`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: AchievementTask, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterString.write(value.`description`, buf) + FfiConverterUInt.write(value.`total`, buf) + FfiConverterUInt.write(value.`totalCompletions`, buf) + FfiConverterDouble.write(value.`completionRate`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ActionCount ( + val `actionName`: kotlin.String + , + val `count`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActionCount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActionCount { + return ActionCount( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: ActionCount) = ( + FfiConverterString.allocationSize(value.`actionName`) + + FfiConverterUInt.allocationSize(value.`count`) + ) + + override fun write(value: ActionCount, buf: ByteBuffer) { + FfiConverterString.write(value.`actionName`, buf) + FfiConverterUInt.write(value.`count`, buf) + } +} + + + +data class Activity ( + val `id`: kotlin.String + , + val `worldAddress`: FieldElement + , + val `namespace`: kotlin.String + , + val `callerAddress`: FieldElement + , + val `sessionStart`: kotlin.ULong + , + val `sessionEnd`: kotlin.ULong + , + val `actionCount`: kotlin.UInt + , + val `actions`: List + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Activity { + return Activity( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterSequenceTypeActionCount.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Activity) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + + FfiConverterULong.allocationSize(value.`sessionStart`) + + FfiConverterULong.allocationSize(value.`sessionEnd`) + + FfiConverterUInt.allocationSize(value.`actionCount`) + + FfiConverterSequenceTypeActionCount.allocationSize(value.`actions`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: Activity, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + FfiConverterULong.write(value.`sessionStart`, buf) + FfiConverterULong.write(value.`sessionEnd`, buf) + FfiConverterUInt.write(value.`actionCount`, buf) + FfiConverterSequenceTypeActionCount.write(value.`actions`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class ActivityQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `callerAddresses`: List + , + val `fromTime`: kotlin.ULong? + , + val `toTime`: kotlin.ULong? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeActivityQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActivityQuery { + return ActivityQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: ActivityQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterOptionalULong.allocationSize(value.`fromTime`) + + FfiConverterOptionalULong.allocationSize(value.`toTime`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: ActivityQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterOptionalULong.write(value.`fromTime`, buf) + FfiConverterOptionalULong.write(value.`toTime`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AggregationEntry ( + val `id`: kotlin.String + , + val `aggregatorId`: kotlin.String + , + val `entityId`: kotlin.String + , + val `value`: U256 + , + val `displayValue`: kotlin.String + , + val `position`: kotlin.ULong + , + val `modelId`: kotlin.String + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationEntry { + return AggregationEntry( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: AggregationEntry) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterString.allocationSize(value.`aggregatorId`) + + FfiConverterString.allocationSize(value.`entityId`) + + FfiConverterTypeU256.allocationSize(value.`value`) + + FfiConverterString.allocationSize(value.`displayValue`) + + FfiConverterULong.allocationSize(value.`position`) + + FfiConverterString.allocationSize(value.`modelId`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: AggregationEntry, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterString.write(value.`aggregatorId`, buf) + FfiConverterString.write(value.`entityId`, buf) + FfiConverterTypeU256.write(value.`value`, buf) + FfiConverterString.write(value.`displayValue`, buf) + FfiConverterULong.write(value.`position`, buf) + FfiConverterString.write(value.`modelId`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class AggregationQuery ( + val `aggregatorIds`: List + , + val `entityIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAggregationQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AggregationQuery { + return AggregationQuery( + FfiConverterSequenceString.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: AggregationQuery) = ( + FfiConverterSequenceString.allocationSize(value.`aggregatorIds`) + + FfiConverterSequenceString.allocationSize(value.`entityIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: AggregationQuery, buf: ByteBuffer) { + FfiConverterSequenceString.write(value.`aggregatorIds`, buf) + FfiConverterSequenceString.write(value.`entityIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class AttributeFilter ( + val `traitName`: kotlin.String + , + val `traitValue`: kotlin.String + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeAttributeFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AttributeFilter { + return AttributeFilter( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: AttributeFilter) = ( + FfiConverterString.allocationSize(value.`traitName`) + + FfiConverterString.allocationSize(value.`traitValue`) + ) + + override fun write(value: AttributeFilter, buf: ByteBuffer) { + FfiConverterString.write(value.`traitName`, buf) + FfiConverterString.write(value.`traitValue`, buf) + } +} + + + +data class CompositeClause ( + val `operator`: LogicalOperator + , + val `clauses`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeCompositeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CompositeClause { + return CompositeClause( + FfiConverterTypeLogicalOperator.read(buf), + FfiConverterSequenceTypeClause.read(buf), + ) + } + + override fun allocationSize(value: CompositeClause) = ( + FfiConverterTypeLogicalOperator.allocationSize(value.`operator`) + + FfiConverterSequenceTypeClause.allocationSize(value.`clauses`) + ) + + override fun write(value: CompositeClause, buf: ByteBuffer) { + FfiConverterTypeLogicalOperator.write(value.`operator`, buf) + FfiConverterSequenceTypeClause.write(value.`clauses`, buf) + } +} + + + +data class Contract ( + val `contractAddress`: FieldElement + , + val `contractType`: ContractType + , + val `head`: kotlin.ULong? + , + val `tps`: kotlin.ULong? + , + val `lastBlockTimestamp`: kotlin.ULong? + , + val `lastPendingBlockTx`: FieldElement? + , + val `updatedAt`: kotlin.ULong + , + val `createdAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Contract { + return Contract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeContractType.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Contract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeContractType.allocationSize(value.`contractType`) + + FfiConverterOptionalULong.allocationSize(value.`head`) + + FfiConverterOptionalULong.allocationSize(value.`tps`) + + FfiConverterOptionalULong.allocationSize(value.`lastBlockTimestamp`) + + FfiConverterOptionalTypeFieldElement.allocationSize(value.`lastPendingBlockTx`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + ) + + override fun write(value: Contract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeContractType.write(value.`contractType`, buf) + FfiConverterOptionalULong.write(value.`head`, buf) + FfiConverterOptionalULong.write(value.`tps`, buf) + FfiConverterOptionalULong.write(value.`lastBlockTimestamp`, buf) + FfiConverterOptionalTypeFieldElement.write(value.`lastPendingBlockTx`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + } +} + + + +data class ContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ContractQuery { + return ContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + ) + } + + override fun allocationSize(value: ContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + ) + + override fun write(value: ContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + } +} + + + +data class Controller ( + val `address`: FieldElement + , + val `username`: kotlin.String + , + val `deployedAtTimestamp`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Controller { + return Controller( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Controller) = ( + FfiConverterTypeFieldElement.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`username`) + + FfiConverterULong.allocationSize(value.`deployedAtTimestamp`) + ) + + override fun write(value: Controller, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`address`, buf) + FfiConverterString.write(value.`username`, buf) + FfiConverterULong.write(value.`deployedAtTimestamp`, buf) + } +} + + + +data class ControllerQuery ( + val `pagination`: Pagination + , + val `contractAddresses`: List + , + val `usernames`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeControllerQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ControllerQuery { + return ControllerQuery( + FfiConverterTypePagination.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: ControllerQuery) = ( + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`usernames`) + ) + + override fun write(value: ControllerQuery, buf: ByteBuffer) { + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`usernames`, buf) + } +} + + + +data class Entity ( + val `worldAddress`: FieldElement + , + val `hashedKeys`: FieldElement + , + val `models`: List + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + , + val `executedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Entity { + return Entity( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeStruct.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: Entity) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`hashedKeys`) + + FfiConverterSequenceTypeStruct.allocationSize(value.`models`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + + FfiConverterULong.allocationSize(value.`executedAt`) + ) + + override fun write(value: Entity, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeFieldElement.write(value.`hashedKeys`, buf) + FfiConverterSequenceTypeStruct.write(value.`models`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + } +} + + + +data class EnumOption ( + val `name`: kotlin.String + , + val `ty`: Ty + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumOption: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumOption { + return EnumOption( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + ) + } + + override fun allocationSize(value: EnumOption) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + ) + + override fun write(value: EnumOption, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + } +} + + + +data class EnumType ( + val `name`: kotlin.String + , + val `option`: kotlin.UByte + , + val `options`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEnumType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EnumType { + return EnumType( + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterSequenceTypeEnumOption.read(buf), + ) + } + + override fun allocationSize(value: EnumType) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterUByte.allocationSize(value.`option`) + + FfiConverterSequenceTypeEnumOption.allocationSize(value.`options`) + ) + + override fun write(value: EnumType, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterUByte.write(value.`option`, buf) + FfiConverterSequenceTypeEnumOption.write(value.`options`, buf) + } +} + + + +data class Event ( + val `keys`: List + , + val `data`: List + , + val `transactionHash`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Event { + return Event( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Event) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`data`) + + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + ) + + override fun write(value: Event, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`data`, buf) + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + } +} + + + +data class EventQuery ( + val `keys`: KeysClause? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeEventQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): EventQuery { + return EventQuery( + FfiConverterOptionalTypeKeysClause.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: EventQuery) = ( + FfiConverterOptionalTypeKeysClause.allocationSize(value.`keys`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: EventQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeKeysClause.write(value.`keys`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class FixedSizeArray ( + val `array`: List + , + val `size`: kotlin.UInt + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeFixedSizeArray: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FixedSizeArray { + return FixedSizeArray( + FfiConverterSequenceTypeTy.read(buf), + FfiConverterUInt.read(buf), + ) + } + + override fun allocationSize(value: FixedSizeArray) = ( + FfiConverterSequenceTypeTy.allocationSize(value.`array`) + + FfiConverterUInt.allocationSize(value.`size`) + ) + + override fun write(value: FixedSizeArray, buf: ByteBuffer) { + FfiConverterSequenceTypeTy.write(value.`array`, buf) + FfiConverterUInt.write(value.`size`, buf) + } +} + + + +data class KeysClause ( + val `keys`: List + , + val `patternMatching`: PatternMatching + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause { + return KeysClause( + FfiConverterSequenceOptionalTypeFieldElement.read(buf), + FfiConverterTypePatternMatching.read(buf), + FfiConverterSequenceString.read(buf), + ) + } + + override fun allocationSize(value: KeysClause) = ( + FfiConverterSequenceOptionalTypeFieldElement.allocationSize(value.`keys`) + + FfiConverterTypePatternMatching.allocationSize(value.`patternMatching`) + + FfiConverterSequenceString.allocationSize(value.`models`) + ) + + override fun write(value: KeysClause, buf: ByteBuffer) { + FfiConverterSequenceOptionalTypeFieldElement.write(value.`keys`, buf) + FfiConverterTypePatternMatching.write(value.`patternMatching`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + } +} + + + +data class Member ( + val `name`: kotlin.String + , + val `ty`: Ty + , + val `key`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMember: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Member { + return Member( + FfiConverterString.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Member) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeTy.allocationSize(value.`ty`) + + FfiConverterBoolean.allocationSize(value.`key`) + ) + + override fun write(value: Member, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeTy.write(value.`ty`, buf) + FfiConverterBoolean.write(value.`key`, buf) + } +} + + + +data class MemberClause ( + val `model`: kotlin.String + , + val `member`: kotlin.String + , + val `operator`: ComparisonOperator + , + val `value`: MemberValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): MemberClause { + return MemberClause( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeComparisonOperator.read(buf), + FfiConverterTypeMemberValue.read(buf), + ) + } + + override fun allocationSize(value: MemberClause) = ( + FfiConverterString.allocationSize(value.`model`) + + FfiConverterString.allocationSize(value.`member`) + + FfiConverterTypeComparisonOperator.allocationSize(value.`operator`) + + FfiConverterTypeMemberValue.allocationSize(value.`value`) + ) + + override fun write(value: MemberClause, buf: ByteBuffer) { + FfiConverterString.write(value.`model`, buf) + FfiConverterString.write(value.`member`, buf) + FfiConverterTypeComparisonOperator.write(value.`operator`, buf) + FfiConverterTypeMemberValue.write(value.`value`, buf) + } +} + + + +data class Message ( + val `message`: kotlin.String + , + val `signature`: List + , + val `worldAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMessage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Message { + return Message( + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Message) = ( + FfiConverterString.allocationSize(value.`message`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + ) + + override fun write(value: Message, buf: ByteBuffer) { + FfiConverterString.write(value.`message`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + } +} + + + +data class Model ( + val `worldAddress`: FieldElement + , + val `schema`: Ty + , + val `namespace`: kotlin.String + , + val `name`: kotlin.String + , + val `selector`: FieldElement + , + val `packedSize`: kotlin.UInt + , + val `unpackedSize`: kotlin.UInt + , + val `classHash`: FieldElement + , + val `contractAddress`: FieldElement + , + val `layout`: kotlin.String + , + val `useLegacyStore`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeModel: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Model { + return Model( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeTy.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Model) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterTypeTy.allocationSize(value.`schema`) + + FfiConverterString.allocationSize(value.`namespace`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeFieldElement.allocationSize(value.`selector`) + + FfiConverterUInt.allocationSize(value.`packedSize`) + + FfiConverterUInt.allocationSize(value.`unpackedSize`) + + FfiConverterTypeFieldElement.allocationSize(value.`classHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`layout`) + + FfiConverterBoolean.allocationSize(value.`useLegacyStore`) + ) + + override fun write(value: Model, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterTypeTy.write(value.`schema`, buf) + FfiConverterString.write(value.`namespace`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeFieldElement.write(value.`selector`, buf) + FfiConverterUInt.write(value.`packedSize`, buf) + FfiConverterUInt.write(value.`unpackedSize`, buf) + FfiConverterTypeFieldElement.write(value.`classHash`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`layout`, buf) + FfiConverterBoolean.write(value.`useLegacyStore`, buf) + } +} + + + +data class OrderBy ( + val `field`: kotlin.String + , + val `direction`: OrderDirection + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeOrderBy: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): OrderBy { + return OrderBy( + FfiConverterString.read(buf), + FfiConverterTypeOrderDirection.read(buf), + ) + } + + override fun allocationSize(value: OrderBy) = ( + FfiConverterString.allocationSize(value.`field`) + + FfiConverterTypeOrderDirection.allocationSize(value.`direction`) + ) + + override fun write(value: OrderBy, buf: ByteBuffer) { + FfiConverterString.write(value.`field`, buf) + FfiConverterTypeOrderDirection.write(value.`direction`, buf) + } +} + + + +data class PageAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAchievement { + return PageAchievement( + FfiConverterSequenceTypeAchievement.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAchievement) = ( + FfiConverterSequenceTypeAchievement.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypeAchievement.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageActivity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageActivity { + return PageActivity( + FfiConverterSequenceTypeActivity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageActivity) = ( + FfiConverterSequenceTypeActivity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageActivity, buf: ByteBuffer) { + FfiConverterSequenceTypeActivity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageAggregationEntry ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageAggregationEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageAggregationEntry { + return PageAggregationEntry( + FfiConverterSequenceTypeAggregationEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageAggregationEntry) = ( + FfiConverterSequenceTypeAggregationEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageAggregationEntry, buf: ByteBuffer) { + FfiConverterSequenceTypeAggregationEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageController ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageController: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageController { + return PageController( + FfiConverterSequenceTypeController.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageController) = ( + FfiConverterSequenceTypeController.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageController, buf: ByteBuffer) { + FfiConverterSequenceTypeController.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEntity ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEntity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEntity { + return PageEntity( + FfiConverterSequenceTypeEntity.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEntity) = ( + FfiConverterSequenceTypeEntity.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEntity, buf: ByteBuffer) { + FfiConverterSequenceTypeEntity.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageEvent ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageEvent { + return PageEvent( + FfiConverterSequenceTypeEvent.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageEvent) = ( + FfiConverterSequenceTypeEvent.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageEvent, buf: ByteBuffer) { + FfiConverterSequenceTypeEvent.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PagePlayerAchievement ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagePlayerAchievement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PagePlayerAchievement { + return PagePlayerAchievement( + FfiConverterSequenceTypePlayerAchievementEntry.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PagePlayerAchievement) = ( + FfiConverterSequenceTypePlayerAchievementEntry.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PagePlayerAchievement, buf: ByteBuffer) { + FfiConverterSequenceTypePlayerAchievementEntry.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageToken ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageToken { + return PageToken( + FfiConverterSequenceTypeToken.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageToken) = ( + FfiConverterSequenceTypeToken.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageToken, buf: ByteBuffer) { + FfiConverterSequenceTypeToken.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenBalance ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenBalance { + return PageTokenBalance( + FfiConverterSequenceTypeTokenBalance.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenBalance) = ( + FfiConverterSequenceTypeTokenBalance.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenBalance, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenBalance.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenContract ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenContract { + return PageTokenContract( + FfiConverterSequenceTypeTokenContract.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenContract) = ( + FfiConverterSequenceTypeTokenContract.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenContract, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenContract.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTokenTransfer ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTokenTransfer { + return PageTokenTransfer( + FfiConverterSequenceTypeTokenTransfer.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTokenTransfer) = ( + FfiConverterSequenceTypeTokenTransfer.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTokenTransfer, buf: ByteBuffer) { + FfiConverterSequenceTypeTokenTransfer.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class PageTransaction ( + val `items`: List + , + val `nextCursor`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePageTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PageTransaction { + return PageTransaction( + FfiConverterSequenceTypeTransaction.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: PageTransaction) = ( + FfiConverterSequenceTypeTransaction.allocationSize(value.`items`) + + FfiConverterOptionalString.allocationSize(value.`nextCursor`) + ) + + override fun write(value: PageTransaction, buf: ByteBuffer) { + FfiConverterSequenceTypeTransaction.write(value.`items`, buf) + FfiConverterOptionalString.write(value.`nextCursor`, buf) + } +} + + + +data class Pagination ( + val `cursor`: kotlin.String? + , + val `limit`: kotlin.UInt? + , + val `direction`: PaginationDirection + , + val `orderBy`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePagination: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Pagination { + return Pagination( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterTypePaginationDirection.read(buf), + FfiConverterSequenceTypeOrderBy.read(buf), + ) + } + + override fun allocationSize(value: Pagination) = ( + FfiConverterOptionalString.allocationSize(value.`cursor`) + + FfiConverterOptionalUInt.allocationSize(value.`limit`) + + FfiConverterTypePaginationDirection.allocationSize(value.`direction`) + + FfiConverterSequenceTypeOrderBy.allocationSize(value.`orderBy`) + ) + + override fun write(value: Pagination, buf: ByteBuffer) { + FfiConverterOptionalString.write(value.`cursor`, buf) + FfiConverterOptionalUInt.write(value.`limit`, buf) + FfiConverterTypePaginationDirection.write(value.`direction`, buf) + FfiConverterSequenceTypeOrderBy.write(value.`orderBy`, buf) + } +} + + + +data class PlayerAchievementEntry ( + val `playerAddress`: FieldElement + , + val `stats`: PlayerAchievementStats + , + val `achievements`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementEntry: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementEntry { + return PlayerAchievementEntry( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypePlayerAchievementStats.read(buf), + FfiConverterSequenceTypePlayerAchievementProgress.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementEntry) = ( + FfiConverterTypeFieldElement.allocationSize(value.`playerAddress`) + + FfiConverterTypePlayerAchievementStats.allocationSize(value.`stats`) + + FfiConverterSequenceTypePlayerAchievementProgress.allocationSize(value.`achievements`) + ) + + override fun write(value: PlayerAchievementEntry, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`playerAddress`, buf) + FfiConverterTypePlayerAchievementStats.write(value.`stats`, buf) + FfiConverterSequenceTypePlayerAchievementProgress.write(value.`achievements`, buf) + } +} + + + +data class PlayerAchievementProgress ( + val `achievement`: Achievement + , + val `taskProgress`: List + , + val `completed`: kotlin.Boolean + , + val `progressPercentage`: kotlin.Double + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementProgress { + return PlayerAchievementProgress( + FfiConverterTypeAchievement.read(buf), + FfiConverterSequenceTypeTaskProgress.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterDouble.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementProgress) = ( + FfiConverterTypeAchievement.allocationSize(value.`achievement`) + + FfiConverterSequenceTypeTaskProgress.allocationSize(value.`taskProgress`) + + FfiConverterBoolean.allocationSize(value.`completed`) + + FfiConverterDouble.allocationSize(value.`progressPercentage`) + ) + + override fun write(value: PlayerAchievementProgress, buf: ByteBuffer) { + FfiConverterTypeAchievement.write(value.`achievement`, buf) + FfiConverterSequenceTypeTaskProgress.write(value.`taskProgress`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + FfiConverterDouble.write(value.`progressPercentage`, buf) + } +} + + + +data class PlayerAchievementQuery ( + val `worldAddresses`: List + , + val `namespaces`: List + , + val `playerAddresses`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementQuery { + return PlayerAchievementQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterSequenceString.allocationSize(value.`namespaces`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`playerAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: PlayerAchievementQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterSequenceString.write(value.`namespaces`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`playerAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class PlayerAchievementStats ( + val `totalPoints`: kotlin.UInt + , + val `completedAchievements`: kotlin.UInt + , + val `totalAchievements`: kotlin.UInt + , + val `completionPercentage`: kotlin.Double + , + val `lastAchievementAt`: kotlin.ULong? + , + val `createdAt`: kotlin.ULong + , + val `updatedAt`: kotlin.ULong + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePlayerAchievementStats: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PlayerAchievementStats { + return PlayerAchievementStats( + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterDouble.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: PlayerAchievementStats) = ( + FfiConverterUInt.allocationSize(value.`totalPoints`) + + FfiConverterUInt.allocationSize(value.`completedAchievements`) + + FfiConverterUInt.allocationSize(value.`totalAchievements`) + + FfiConverterDouble.allocationSize(value.`completionPercentage`) + + FfiConverterOptionalULong.allocationSize(value.`lastAchievementAt`) + + FfiConverterULong.allocationSize(value.`createdAt`) + + FfiConverterULong.allocationSize(value.`updatedAt`) + ) + + override fun write(value: PlayerAchievementStats, buf: ByteBuffer) { + FfiConverterUInt.write(value.`totalPoints`, buf) + FfiConverterUInt.write(value.`completedAchievements`, buf) + FfiConverterUInt.write(value.`totalAchievements`, buf) + FfiConverterDouble.write(value.`completionPercentage`, buf) + FfiConverterOptionalULong.write(value.`lastAchievementAt`, buf) + FfiConverterULong.write(value.`createdAt`, buf) + FfiConverterULong.write(value.`updatedAt`, buf) + } +} + + + +data class Query ( + val `worldAddresses`: List + , + val `pagination`: Pagination + , + val `clause`: Clause? + , + val `noHashedKeys`: kotlin.Boolean + , + val `models`: List + , + val `historical`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Query { + return Query( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypePagination.read(buf), + FfiConverterOptionalTypeClause.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: Query) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`worldAddresses`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + + FfiConverterOptionalTypeClause.allocationSize(value.`clause`) + + FfiConverterBoolean.allocationSize(value.`noHashedKeys`) + + FfiConverterSequenceString.allocationSize(value.`models`) + + FfiConverterBoolean.allocationSize(value.`historical`) + ) + + override fun write(value: Query, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`worldAddresses`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + FfiConverterOptionalTypeClause.write(value.`clause`, buf) + FfiConverterBoolean.write(value.`noHashedKeys`, buf) + FfiConverterSequenceString.write(value.`models`, buf) + FfiConverterBoolean.write(value.`historical`, buf) + } +} + + + +data class Signature ( + val `r`: FieldElement + , + val `s`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSignature: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Signature { + return Signature( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Signature) = ( + FfiConverterTypeFieldElement.allocationSize(value.`r`) + + FfiConverterTypeFieldElement.allocationSize(value.`s`) + ) + + override fun write(value: Signature, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`r`, buf) + FfiConverterTypeFieldElement.write(value.`s`, buf) + } +} + + + +data class SqlField ( + val `name`: kotlin.String + , + val `value`: SqlValue + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlField: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlField { + return SqlField( + FfiConverterString.read(buf), + FfiConverterTypeSqlValue.read(buf), + ) + } + + override fun allocationSize(value: SqlField) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterTypeSqlValue.allocationSize(value.`value`) + ) + + override fun write(value: SqlField, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterTypeSqlValue.write(value.`value`, buf) + } +} + + + +data class SqlRow ( + val `fields`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlRow: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SqlRow { + return SqlRow( + FfiConverterSequenceTypeSqlField.read(buf), + ) + } + + override fun allocationSize(value: SqlRow) = ( + FfiConverterSequenceTypeSqlField.allocationSize(value.`fields`) + ) + + override fun write(value: SqlRow, buf: ByteBuffer) { + FfiConverterSequenceTypeSqlField.write(value.`fields`, buf) + } +} + + + +data class Struct ( + val `name`: kotlin.String + , + val `children`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeStruct: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Struct { + return Struct( + FfiConverterString.read(buf), + FfiConverterSequenceTypeMember.read(buf), + ) + } + + override fun allocationSize(value: Struct) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterSequenceTypeMember.allocationSize(value.`children`) + ) + + override fun write(value: Struct, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterSequenceTypeMember.write(value.`children`, buf) + } +} + + + +data class TaskProgress ( + val `taskId`: kotlin.String + , + val `count`: kotlin.UInt + , + val `completed`: kotlin.Boolean + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTaskProgress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TaskProgress { + return TaskProgress( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterBoolean.read(buf), + ) + } + + override fun allocationSize(value: TaskProgress) = ( + FfiConverterString.allocationSize(value.`taskId`) + + FfiConverterUInt.allocationSize(value.`count`) + + FfiConverterBoolean.allocationSize(value.`completed`) + ) + + override fun write(value: TaskProgress, buf: ByteBuffer) { + FfiConverterString.write(value.`taskId`, buf) + FfiConverterUInt.write(value.`count`, buf) + FfiConverterBoolean.write(value.`completed`, buf) + } +} + + + +data class Token ( + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeToken: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Token { + return Token( + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: Token) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: Token, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenBalance ( + val `balance`: U256 + , + val `accountAddress`: FieldElement + , + val `contractAddress`: FieldElement + , + val `tokenId`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalance: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalance { + return TokenBalance( + FfiConverterTypeU256.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenBalance) = ( + FfiConverterTypeU256.allocationSize(value.`balance`) + + FfiConverterTypeFieldElement.allocationSize(value.`accountAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + ) + + override fun write(value: TokenBalance, buf: ByteBuffer) { + FfiConverterTypeU256.write(value.`balance`, buf) + FfiConverterTypeFieldElement.write(value.`accountAddress`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + } +} + + + +data class TokenBalanceQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenBalanceQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenBalanceQuery { + return TokenBalanceQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenBalanceQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenBalanceQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenContract ( + val `contractAddress`: FieldElement + , + val `name`: kotlin.String + , + val `symbol`: kotlin.String + , + val `decimals`: kotlin.UByte + , + val `metadata`: kotlin.String + , + val `tokenMetadata`: kotlin.String + , + val `totalSupply`: U256? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContract: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContract { + return TokenContract( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUByte.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeU256.read(buf), + ) + } + + override fun allocationSize(value: TokenContract) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`symbol`) + + FfiConverterUByte.allocationSize(value.`decimals`) + + FfiConverterString.allocationSize(value.`metadata`) + + FfiConverterString.allocationSize(value.`tokenMetadata`) + + FfiConverterOptionalTypeU256.allocationSize(value.`totalSupply`) + ) + + override fun write(value: TokenContract, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`symbol`, buf) + FfiConverterUByte.write(value.`decimals`, buf) + FfiConverterString.write(value.`metadata`, buf) + FfiConverterString.write(value.`tokenMetadata`, buf) + FfiConverterOptionalTypeU256.write(value.`totalSupply`, buf) + } +} + + + +data class TokenContractQuery ( + val `contractAddresses`: List + , + val `contractTypes`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenContractQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenContractQuery { + return TokenContractQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeContractType.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenContractQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeContractType.allocationSize(value.`contractTypes`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenContractQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeContractType.write(value.`contractTypes`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenQuery ( + val `contractAddresses`: List + , + val `tokenIds`: List + , + val `attributeFilters`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenQuery { + return TokenQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterSequenceTypeAttributeFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterSequenceTypeAttributeFilter.allocationSize(value.`attributeFilters`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterSequenceTypeAttributeFilter.write(value.`attributeFilters`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class TokenTransfer ( + val `id`: kotlin.String + , + val `contractAddress`: FieldElement + , + val `fromAddress`: FieldElement + , + val `toAddress`: FieldElement + , + val `amount`: U256 + , + val `tokenId`: U256? + , + val `executedAt`: kotlin.ULong + , + val `eventId`: kotlin.String? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransfer: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransfer { + return TokenTransfer( + FfiConverterString.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeU256.read(buf), + FfiConverterOptionalTypeU256.read(buf), + FfiConverterULong.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: TokenTransfer) = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`fromAddress`) + + FfiConverterTypeFieldElement.allocationSize(value.`toAddress`) + + FfiConverterTypeU256.allocationSize(value.`amount`) + + FfiConverterOptionalTypeU256.allocationSize(value.`tokenId`) + + FfiConverterULong.allocationSize(value.`executedAt`) + + FfiConverterOptionalString.allocationSize(value.`eventId`) + ) + + override fun write(value: TokenTransfer, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterTypeFieldElement.write(value.`fromAddress`, buf) + FfiConverterTypeFieldElement.write(value.`toAddress`, buf) + FfiConverterTypeU256.write(value.`amount`, buf) + FfiConverterOptionalTypeU256.write(value.`tokenId`, buf) + FfiConverterULong.write(value.`executedAt`, buf) + FfiConverterOptionalString.write(value.`eventId`, buf) + } +} + + + +data class TokenTransferQuery ( + val `contractAddresses`: List + , + val `accountAddresses`: List + , + val `tokenIds`: List + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTokenTransferQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TokenTransferQuery { + return TokenTransferQuery( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeU256.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TokenTransferQuery) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`accountAddresses`) + + FfiConverterSequenceTypeU256.allocationSize(value.`tokenIds`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TokenTransferQuery, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`accountAddresses`, buf) + FfiConverterSequenceTypeU256.write(value.`tokenIds`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class Transaction ( + val `transactionHash`: FieldElement + , + val `senderAddress`: FieldElement + , + val `calldata`: List + , + val `maxFee`: FieldElement + , + val `signature`: List + , + val `nonce`: FieldElement + , + val `blockNumber`: kotlin.ULong + , + val `transactionType`: kotlin.String + , + val `blockTimestamp`: kotlin.ULong + , + val `calls`: List + , + val `uniqueModels`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransaction: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Transaction { + return Transaction( + FfiConverterTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeFieldElement.read(buf), + FfiConverterULong.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), + FfiConverterSequenceTypeTransactionCall.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: Transaction) = ( + FfiConverterTypeFieldElement.allocationSize(value.`transactionHash`) + + FfiConverterTypeFieldElement.allocationSize(value.`senderAddress`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeFieldElement.allocationSize(value.`maxFee`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`signature`) + + FfiConverterTypeFieldElement.allocationSize(value.`nonce`) + + FfiConverterULong.allocationSize(value.`blockNumber`) + + FfiConverterString.allocationSize(value.`transactionType`) + + FfiConverterULong.allocationSize(value.`blockTimestamp`) + + FfiConverterSequenceTypeTransactionCall.allocationSize(value.`calls`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`uniqueModels`) + ) + + override fun write(value: Transaction, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`transactionHash`, buf) + FfiConverterTypeFieldElement.write(value.`senderAddress`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeFieldElement.write(value.`maxFee`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`signature`, buf) + FfiConverterTypeFieldElement.write(value.`nonce`, buf) + FfiConverterULong.write(value.`blockNumber`, buf) + FfiConverterString.write(value.`transactionType`, buf) + FfiConverterULong.write(value.`blockTimestamp`, buf) + FfiConverterSequenceTypeTransactionCall.write(value.`calls`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`uniqueModels`, buf) + } +} + + + +data class TransactionCall ( + val `contractAddress`: FieldElement + , + val `entrypoint`: kotlin.String + , + val `calldata`: List + , + val `callType`: CallType + , + val `callerAddress`: FieldElement + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionCall: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionCall { + return TransactionCall( + FfiConverterTypeFieldElement.read(buf), + FfiConverterString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterTypeCallType.read(buf), + FfiConverterTypeFieldElement.read(buf), + ) + } + + override fun allocationSize(value: TransactionCall) = ( + FfiConverterTypeFieldElement.allocationSize(value.`contractAddress`) + + FfiConverterString.allocationSize(value.`entrypoint`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`calldata`) + + FfiConverterTypeCallType.allocationSize(value.`callType`) + + FfiConverterTypeFieldElement.allocationSize(value.`callerAddress`) + ) + + override fun write(value: TransactionCall, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`contractAddress`, buf) + FfiConverterString.write(value.`entrypoint`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`calldata`, buf) + FfiConverterTypeCallType.write(value.`callType`, buf) + FfiConverterTypeFieldElement.write(value.`callerAddress`, buf) + } +} + + + +data class TransactionFilter ( + val `transactionHashes`: List + , + val `callerAddresses`: List + , + val `contractAddresses`: List + , + val `entrypoints`: List + , + val `modelSelectors`: List + , + val `fromBlock`: kotlin.ULong? + , + val `toBlock`: kotlin.ULong? + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter { + return TransactionFilter( + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterSequenceTypeFieldElement.read(buf), + FfiConverterOptionalULong.read(buf), + FfiConverterOptionalULong.read(buf), + ) + } + + override fun allocationSize(value: TransactionFilter) = ( + FfiConverterSequenceTypeFieldElement.allocationSize(value.`transactionHashes`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`callerAddresses`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`contractAddresses`) + + FfiConverterSequenceString.allocationSize(value.`entrypoints`) + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`modelSelectors`) + + FfiConverterOptionalULong.allocationSize(value.`fromBlock`) + + FfiConverterOptionalULong.allocationSize(value.`toBlock`) + ) + + override fun write(value: TransactionFilter, buf: ByteBuffer) { + FfiConverterSequenceTypeFieldElement.write(value.`transactionHashes`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`callerAddresses`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`contractAddresses`, buf) + FfiConverterSequenceString.write(value.`entrypoints`, buf) + FfiConverterSequenceTypeFieldElement.write(value.`modelSelectors`, buf) + FfiConverterOptionalULong.write(value.`fromBlock`, buf) + FfiConverterOptionalULong.write(value.`toBlock`, buf) + } +} + + + +data class TransactionQuery ( + val `filter`: TransactionFilter? + , + val `pagination`: Pagination + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTransactionQuery: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionQuery { + return TransactionQuery( + FfiConverterOptionalTypeTransactionFilter.read(buf), + FfiConverterTypePagination.read(buf), + ) + } + + override fun allocationSize(value: TransactionQuery) = ( + FfiConverterOptionalTypeTransactionFilter.allocationSize(value.`filter`) + + FfiConverterTypePagination.allocationSize(value.`pagination`) + ) + + override fun write(value: TransactionQuery, buf: ByteBuffer) { + FfiConverterOptionalTypeTransactionFilter.write(value.`filter`, buf) + FfiConverterTypePagination.write(value.`pagination`, buf) + } +} + + + +data class World ( + val `worldAddress`: FieldElement + , + val `models`: List + +){ + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeWorld: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): World { + return World( + FfiConverterTypeFieldElement.read(buf), + FfiConverterSequenceTypeModel.read(buf), + ) + } + + override fun allocationSize(value: World) = ( + FfiConverterTypeFieldElement.allocationSize(value.`worldAddress`) + + FfiConverterSequenceTypeModel.allocationSize(value.`models`) + ) + + override fun write(value: World, buf: ByteBuffer) { + FfiConverterTypeFieldElement.write(value.`worldAddress`, buf) + FfiConverterSequenceTypeModel.write(value.`models`, buf) + } +} + + + + +enum class CallType { + + EXECUTE, + EXECUTE_FROM_OUTSIDE; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeCallType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + CallType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: CallType) = 4UL + + override fun write(value: CallType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Clause { + + data class HashedKeys( + val `keys`: List) : Clause() + + { + + + companion object + } + + data class Keys( + val `clause`: KeysClause) : Clause() + + { + + + companion object + } + + data class Member( + val `clause`: MemberClause) : Clause() + + { + + + companion object + } + + data class Composite( + val `clause`: CompositeClause) : Clause() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeClause : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Clause { + return when(buf.getInt()) { + 1 -> Clause.HashedKeys( + FfiConverterSequenceTypeFieldElement.read(buf), + ) + 2 -> Clause.Keys( + FfiConverterTypeKeysClause.read(buf), + ) + 3 -> Clause.Member( + FfiConverterTypeMemberClause.read(buf), + ) + 4 -> Clause.Composite( + FfiConverterTypeCompositeClause.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Clause) = when(value) { + is Clause.HashedKeys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeFieldElement.allocationSize(value.`keys`) + ) + } + is Clause.Keys -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeKeysClause.allocationSize(value.`clause`) + ) + } + is Clause.Member -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeMemberClause.allocationSize(value.`clause`) + ) + } + is Clause.Composite -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeCompositeClause.allocationSize(value.`clause`) + ) + } + } + + override fun write(value: Clause, buf: ByteBuffer) { + when(value) { + is Clause.HashedKeys -> { + buf.putInt(1) + FfiConverterSequenceTypeFieldElement.write(value.`keys`, buf) + Unit + } + is Clause.Keys -> { + buf.putInt(2) + FfiConverterTypeKeysClause.write(value.`clause`, buf) + Unit + } + is Clause.Member -> { + buf.putInt(3) + FfiConverterTypeMemberClause.write(value.`clause`, buf) + Unit + } + is Clause.Composite -> { + buf.putInt(4) + FfiConverterTypeCompositeClause.write(value.`clause`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class ComparisonOperator { + + EQ, + NEQ, + GT, + GTE, + LT, + LTE, + IN, + NOT_IN, + CONTAINS, + CONTAINS_ALL, + CONTAINS_ANY, + ARRAY_LENGTH_EQ, + ARRAY_LENGTH_GT, + ARRAY_LENGTH_LT; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeComparisonOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ComparisonOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ComparisonOperator) = 4UL + + override fun write(value: ComparisonOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class ContractType { + + WORLD, + ERC20, + ERC721, + ERC1155, + UDC, + OTHER; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeContractType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ContractType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ContractType) = 4UL + + override fun write(value: ContractType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + + +sealed class DojoException(message: String): kotlin.Exception(message) { + + class ClientException(message: String) : DojoException(message) + + class SerializationException(message: String) : DojoException(message) + + class NetworkException(message: String) : DojoException(message) + + class InvalidInput(message: String) : DojoException(message) + + class ConnectionException(message: String) : DojoException(message) + + class PublishException(message: String) : DojoException(message) + + class QueryException(message: String) : DojoException(message) + + class SubscriptionException(message: String) : DojoException(message) + + + companion object ErrorHandler : UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): DojoException = FfiConverterTypeDojoError.lift(error_buf) + } +} + +/** + * @suppress + */ +public object FfiConverterTypeDojoError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): DojoException { + + return when(buf.getInt()) { + 1 -> DojoException.ClientException(FfiConverterString.read(buf)) + 2 -> DojoException.SerializationException(FfiConverterString.read(buf)) + 3 -> DojoException.NetworkException(FfiConverterString.read(buf)) + 4 -> DojoException.InvalidInput(FfiConverterString.read(buf)) + 5 -> DojoException.ConnectionException(FfiConverterString.read(buf)) + 6 -> DojoException.PublishException(FfiConverterString.read(buf)) + 7 -> DojoException.QueryException(FfiConverterString.read(buf)) + 8 -> DojoException.SubscriptionException(FfiConverterString.read(buf)) + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") + } + + } + + override fun allocationSize(value: DojoException): ULong { + return 4UL + } + + override fun write(value: DojoException, buf: ByteBuffer) { + when(value) { + is DojoException.ClientException -> { + buf.putInt(1) + Unit + } + is DojoException.SerializationException -> { + buf.putInt(2) + Unit + } + is DojoException.NetworkException -> { + buf.putInt(3) + Unit + } + is DojoException.InvalidInput -> { + buf.putInt(4) + Unit + } + is DojoException.ConnectionException -> { + buf.putInt(5) + Unit + } + is DojoException.PublishException -> { + buf.putInt(6) + Unit + } + is DojoException.QueryException -> { + buf.putInt(7) + Unit + } + is DojoException.SubscriptionException -> { + buf.putInt(8) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } + +} + + + + +enum class LogicalOperator { + + AND, + OR; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeLogicalOperator: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + LogicalOperator.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: LogicalOperator) = 4UL + + override fun write(value: LogicalOperator, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class MemberValue { + + data class Primitive( + val `value`: Primitive) : MemberValue() + + { + + + companion object + } + + data class String( + val `value`: kotlin.String) : MemberValue() + + { + + + companion object + } + + data class List( + val `values`: List) : MemberValue() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeMemberValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): MemberValue { + return when(buf.getInt()) { + 1 -> MemberValue.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> MemberValue.String( + FfiConverterString.read(buf), + ) + 3 -> MemberValue.List( + FfiConverterSequenceTypeMemberValue.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: MemberValue) = when(value) { + is MemberValue.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is MemberValue.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is MemberValue.List -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeMemberValue.allocationSize(value.`values`) + ) + } + } + + override fun write(value: MemberValue, buf: ByteBuffer) { + when(value) { + is MemberValue.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is MemberValue.String -> { + buf.putInt(2) + FfiConverterString.write(value.`value`, buf) + Unit + } + is MemberValue.List -> { + buf.putInt(3) + FfiConverterSequenceTypeMemberValue.write(value.`values`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class OrderDirection { + + ASC, + DESC; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeOrderDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + OrderDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: OrderDirection) = 4UL + + override fun write(value: OrderDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PaginationDirection { + + FORWARD, + BACKWARD; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePaginationDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PaginationDirection.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PaginationDirection) = 4UL + + override fun write(value: PaginationDirection, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class PatternMatching { + + FIXED_LEN, + VARIABLE_LEN; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypePatternMatching: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + PatternMatching.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: PatternMatching) = 4UL + + override fun write(value: PatternMatching, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +sealed class Primitive { + + data class I8( + val `value`: kotlin.Byte) : Primitive() + + { + + + companion object + } + + data class I16( + val `value`: kotlin.Short) : Primitive() + + { + + + companion object + } + + data class I32( + val `value`: kotlin.Int) : Primitive() + + { + + + companion object + } + + data class I64( + val `value`: kotlin.Long) : Primitive() + + { + + + companion object + } + + data class I128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U8( + val `value`: kotlin.UByte) : Primitive() + + { + + + companion object + } + + data class U16( + val `value`: kotlin.UShort) : Primitive() + + { + + + companion object + } + + data class U32( + val `value`: kotlin.UInt) : Primitive() + + { + + + companion object + } + + data class U64( + val `value`: kotlin.ULong) : Primitive() + + { + + + companion object + } + + data class U128( + val `value`: List) : Primitive() + + { + + + companion object + } + + data class U256( + val `value`: U256) : Primitive() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : Primitive() + + { + + + companion object + } + + data class Felt252( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ClassHash( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class ContractAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + data class EthAddress( + val `value`: FieldElement) : Primitive() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypePrimitive : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Primitive { + return when(buf.getInt()) { + 1 -> Primitive.I8( + FfiConverterByte.read(buf), + ) + 2 -> Primitive.I16( + FfiConverterShort.read(buf), + ) + 3 -> Primitive.I32( + FfiConverterInt.read(buf), + ) + 4 -> Primitive.I64( + FfiConverterLong.read(buf), + ) + 5 -> Primitive.I128( + FfiConverterSequenceUByte.read(buf), + ) + 6 -> Primitive.U8( + FfiConverterUByte.read(buf), + ) + 7 -> Primitive.U16( + FfiConverterUShort.read(buf), + ) + 8 -> Primitive.U32( + FfiConverterUInt.read(buf), + ) + 9 -> Primitive.U64( + FfiConverterULong.read(buf), + ) + 10 -> Primitive.U128( + FfiConverterSequenceUByte.read(buf), + ) + 11 -> Primitive.U256( + FfiConverterTypeU256.read(buf), + ) + 12 -> Primitive.Bool( + FfiConverterBoolean.read(buf), + ) + 13 -> Primitive.Felt252( + FfiConverterTypeFieldElement.read(buf), + ) + 14 -> Primitive.ClassHash( + FfiConverterTypeFieldElement.read(buf), + ) + 15 -> Primitive.ContractAddress( + FfiConverterTypeFieldElement.read(buf), + ) + 16 -> Primitive.EthAddress( + FfiConverterTypeFieldElement.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Primitive) = when(value) { + is Primitive.I8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterByte.allocationSize(value.`value`) + ) + } + is Primitive.I16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterShort.allocationSize(value.`value`) + ) + } + is Primitive.I32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterInt.allocationSize(value.`value`) + ) + } + is Primitive.I64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is Primitive.I128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U8 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUByte.allocationSize(value.`value`) + ) + } + is Primitive.U16 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUShort.allocationSize(value.`value`) + ) + } + is Primitive.U32 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterUInt.allocationSize(value.`value`) + ) + } + is Primitive.U64 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is Primitive.U128 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is Primitive.U256 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeU256.allocationSize(value.`value`) + ) + } + is Primitive.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is Primitive.Felt252 -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ClassHash -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.ContractAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + is Primitive.EthAddress -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFieldElement.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Primitive, buf: ByteBuffer) { + when(value) { + is Primitive.I8 -> { + buf.putInt(1) + FfiConverterByte.write(value.`value`, buf) + Unit + } + is Primitive.I16 -> { + buf.putInt(2) + FfiConverterShort.write(value.`value`, buf) + Unit + } + is Primitive.I32 -> { + buf.putInt(3) + FfiConverterInt.write(value.`value`, buf) + Unit + } + is Primitive.I64 -> { + buf.putInt(4) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is Primitive.I128 -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U8 -> { + buf.putInt(6) + FfiConverterUByte.write(value.`value`, buf) + Unit + } + is Primitive.U16 -> { + buf.putInt(7) + FfiConverterUShort.write(value.`value`, buf) + Unit + } + is Primitive.U32 -> { + buf.putInt(8) + FfiConverterUInt.write(value.`value`, buf) + Unit + } + is Primitive.U64 -> { + buf.putInt(9) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is Primitive.U128 -> { + buf.putInt(10) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is Primitive.U256 -> { + buf.putInt(11) + FfiConverterTypeU256.write(value.`value`, buf) + Unit + } + is Primitive.Bool -> { + buf.putInt(12) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is Primitive.Felt252 -> { + buf.putInt(13) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ClassHash -> { + buf.putInt(14) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.ContractAddress -> { + buf.putInt(15) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + is Primitive.EthAddress -> { + buf.putInt(16) + FfiConverterTypeFieldElement.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class SqlValue { + + data class Text( + val `value`: kotlin.String) : SqlValue() + + { + + + companion object + } + + data class Integer( + val `value`: kotlin.Long) : SqlValue() + + { + + + companion object + } + + data class Real( + val `value`: kotlin.Double) : SqlValue() + + { + + + companion object + } + + data class Blob( + val `value`: List) : SqlValue() + + { + + + companion object + } + + object Null : SqlValue() + + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeSqlValue : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): SqlValue { + return when(buf.getInt()) { + 1 -> SqlValue.Text( + FfiConverterString.read(buf), + ) + 2 -> SqlValue.Integer( + FfiConverterLong.read(buf), + ) + 3 -> SqlValue.Real( + FfiConverterDouble.read(buf), + ) + 4 -> SqlValue.Blob( + FfiConverterSequenceUByte.read(buf), + ) + 5 -> SqlValue.Null + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: SqlValue) = when(value) { + is SqlValue.Text -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is SqlValue.Integer -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is SqlValue.Real -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterDouble.allocationSize(value.`value`) + ) + } + is SqlValue.Blob -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + is SqlValue.Null -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + } + + override fun write(value: SqlValue, buf: ByteBuffer) { + when(value) { + is SqlValue.Text -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is SqlValue.Integer -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is SqlValue.Real -> { + buf.putInt(3) + FfiConverterDouble.write(value.`value`, buf) + Unit + } + is SqlValue.Blob -> { + buf.putInt(4) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + is SqlValue.Null -> { + buf.putInt(5) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class Ty { + + data class Primitive( + val `value`: Primitive) : Ty() + + { + + + companion object + } + + data class Struct( + val `value`: Struct) : Ty() + + { + + + companion object + } + + data class Enum( + val `value`: EnumType) : Ty() + + { + + + companion object + } + + data class Tuple( + val `values`: List) : Ty() + + { + + + companion object + } + + data class Array( + val `values`: List) : Ty() + + { + + + companion object + } + + data class FixedSizeArray( + val `value`: FixedSizeArray) : Ty() + + { + + + companion object + } + + data class ByteArray( + val `value`: kotlin.String) : Ty() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeTy : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): Ty { + return when(buf.getInt()) { + 1 -> Ty.Primitive( + FfiConverterTypePrimitive.read(buf), + ) + 2 -> Ty.Struct( + FfiConverterTypeStruct.read(buf), + ) + 3 -> Ty.Enum( + FfiConverterTypeEnumType.read(buf), + ) + 4 -> Ty.Tuple( + FfiConverterSequenceTypeTy.read(buf), + ) + 5 -> Ty.Array( + FfiConverterSequenceTypeTy.read(buf), + ) + 6 -> Ty.FixedSizeArray( + FfiConverterTypeFixedSizeArray.read(buf), + ) + 7 -> Ty.ByteArray( + FfiConverterString.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: Ty) = when(value) { + is Ty.Primitive -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypePrimitive.allocationSize(value.`value`) + ) + } + is Ty.Struct -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeStruct.allocationSize(value.`value`) + ) + } + is Ty.Enum -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeEnumType.allocationSize(value.`value`) + ) + } + is Ty.Tuple -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.Array -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceTypeTy.allocationSize(value.`values`) + ) + } + is Ty.FixedSizeArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeFixedSizeArray.allocationSize(value.`value`) + ) + } + is Ty.ByteArray -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + } + + override fun write(value: Ty, buf: ByteBuffer) { + when(value) { + is Ty.Primitive -> { + buf.putInt(1) + FfiConverterTypePrimitive.write(value.`value`, buf) + Unit + } + is Ty.Struct -> { + buf.putInt(2) + FfiConverterTypeStruct.write(value.`value`, buf) + Unit + } + is Ty.Enum -> { + buf.putInt(3) + FfiConverterTypeEnumType.write(value.`value`, buf) + Unit + } + is Ty.Tuple -> { + buf.putInt(4) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.Array -> { + buf.putInt(5) + FfiConverterSequenceTypeTy.write(value.`values`, buf) + Unit + } + is Ty.FixedSizeArray -> { + buf.putInt(6) + FfiConverterTypeFixedSizeArray.write(value.`value`, buf) + Unit + } + is Ty.ByteArray -> { + buf.putInt(7) + FfiConverterString.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class ValueType { + + data class String( + val `value`: kotlin.String) : ValueType() + + { + + + companion object + } + + data class Int( + val `value`: kotlin.Long) : ValueType() + + { + + + companion object + } + + data class UInt( + val `value`: kotlin.ULong) : ValueType() + + { + + + companion object + } + + data class Bool( + val `value`: kotlin.Boolean) : ValueType() + + { + + + companion object + } + + data class Bytes( + val `value`: List) : ValueType() + + { + + + companion object + } + + + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeValueType : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): ValueType { + return when(buf.getInt()) { + 1 -> ValueType.String( + FfiConverterString.read(buf), + ) + 2 -> ValueType.Int( + FfiConverterLong.read(buf), + ) + 3 -> ValueType.UInt( + FfiConverterULong.read(buf), + ) + 4 -> ValueType.Bool( + FfiConverterBoolean.read(buf), + ) + 5 -> ValueType.Bytes( + FfiConverterSequenceUByte.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: ValueType) = when(value) { + is ValueType.String -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterString.allocationSize(value.`value`) + ) + } + is ValueType.Int -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`value`) + ) + } + is ValueType.UInt -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterULong.allocationSize(value.`value`) + ) + } + is ValueType.Bool -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterBoolean.allocationSize(value.`value`) + ) + } + is ValueType.Bytes -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterSequenceUByte.allocationSize(value.`value`) + ) + } + } + + override fun write(value: ValueType, buf: ByteBuffer) { + when(value) { + is ValueType.String -> { + buf.putInt(1) + FfiConverterString.write(value.`value`, buf) + Unit + } + is ValueType.Int -> { + buf.putInt(2) + FfiConverterLong.write(value.`value`, buf) + Unit + } + is ValueType.UInt -> { + buf.putInt(3) + FfiConverterULong.write(value.`value`, buf) + Unit + } + is ValueType.Bool -> { + buf.putInt(4) + FfiConverterBoolean.write(value.`value`, buf) + Unit + } + is ValueType.Bytes -> { + buf.putInt(5) + FfiConverterSequenceUByte.write(value.`value`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + + +public interface EntityUpdateCallback { + + fun `onUpdate`(`entity`: Entity) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEntityUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEntityUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`entity`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEntity.lift(`entity`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEntityUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEntityUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEntityUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEntityUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEntityUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_entityupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEntityUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface EventUpdateCallback { + + fun `onUpdate`(`event`: Event) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceEventUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceEventUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeEvent.lift(`event`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceEventUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeEventUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeEventUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeEventUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceEventUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_eventupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeEventUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenBalanceUpdateCallback { + + fun `onUpdate`(`balance`: TokenBalance) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenBalanceUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`balance`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTokenBalance.lift(`balance`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenBalanceUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenBalanceUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenBalanceUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenBalanceUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenBalanceUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenbalanceupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenBalanceUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TokenUpdateCallback { + + fun `onUpdate`(`token`: Token) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTokenUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTokenUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`token`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeToken.lift(`token`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTokenUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTokenUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTokenUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTokenUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTokenUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_tokenupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTokenUpdateCallback: FfiConverterCallbackInterface() + + + + + +public interface TransactionUpdateCallback { + + fun `onUpdate`(`transaction`: Transaction) + + fun `onError`(`error`: kotlin.String) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTransactionUpdateCallback { + internal object `onUpdate`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod0 { + override fun callback(`uniffiHandle`: Long,`transaction`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypeTransaction.lift(`transaction`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onError`: UniffiCallbackInterfaceTransactionUpdateCallbackMethod1 { + override fun callback(`uniffiHandle`: Long,`error`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypeTransactionUpdateCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onError`( + FfiConverterString.lift(`error`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTransactionUpdateCallback.handleMap.remove(handle) + } + } + + internal object uniffiClone: UniffiCallbackInterfaceClone { + override fun callback(handle: Long): Long { + return FfiConverterTypeTransactionUpdateCallback.handleMap.clone(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfaceTransactionUpdateCallback.UniffiByValue( + uniffiFree, + uniffiClone, + `onUpdate`, + `onError`, + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_dojo_uniffi_fn_init_callback_vtable_transactionupdatecallback(vtable) + } +} + +/** + * The ffiConverter which transforms the Callbacks in to handles to pass to Rust. + * + * @suppress + */ +public object FfiConverterTypeTransactionUpdateCallback: FfiConverterCallbackInterface() + + + + +/** + * @suppress + */ +public object FfiConverterOptionalUInt: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.UInt? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterUInt.read(buf) + } + + override fun allocationSize(value: kotlin.UInt?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterUInt.allocationSize(value) + } + } + + override fun write(value: kotlin.UInt?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterUInt.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalULong: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.ULong? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterULong.read(buf) + } + + override fun allocationSize(value: kotlin.ULong?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterULong.allocationSize(value) + } + } + + override fun write(value: kotlin.ULong?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterULong.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalBoolean: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.Boolean? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterBoolean.read(buf) + } + + override fun allocationSize(value: kotlin.Boolean?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterBoolean.allocationSize(value) + } + } + + override fun write(value: kotlin.Boolean?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterBoolean.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalString: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.String? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterString.read(buf) + } + + override fun allocationSize(value: kotlin.String?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterString.allocationSize(value) + } + } + + override fun write(value: kotlin.String?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterString.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeKeysClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): KeysClause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeKeysClause.read(buf) + } + + override fun allocationSize(value: KeysClause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeKeysClause.allocationSize(value) + } + } + + override fun write(value: KeysClause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeKeysClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeTransactionFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionFilter? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeTransactionFilter.read(buf) + } + + override fun allocationSize(value: TransactionFilter?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeTransactionFilter.allocationSize(value) + } + } + + override fun write(value: TransactionFilter?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeTransactionFilter.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeClause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Clause? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeClause.read(buf) + } + + override fun allocationSize(value: Clause?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeClause.allocationSize(value) + } + } + + override fun write(value: Clause?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeClause.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeFieldElement: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FieldElement? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeFieldElement.read(buf) + } + + override fun allocationSize(value: FieldElement?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeFieldElement.allocationSize(value) + } + } + + override fun write(value: FieldElement?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeFieldElement.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterOptionalTypeU256: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): U256? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeU256.read(buf) + } + + override fun allocationSize(value: U256?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeU256.allocationSize(value) + } + } + + override fun write(value: U256?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeU256.write(value, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceUByte: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterUByte.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterUByte.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterUByte.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceString: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterString.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterString.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAchievementTask: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAchievementTask.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAchievementTask.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAchievementTask.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActionCount: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActionCount.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActionCount.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActionCount.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeActivity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeActivity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeActivity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeActivity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAggregationEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAggregationEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAggregationEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAggregationEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeAttributeFilter: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAttributeFilter.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeAttributeFilter.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAttributeFilter.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeController: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeController.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeController.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeController.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEntity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEntity.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEntity.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEntity.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEnumOption: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEnumOption.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEnumOption.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEnumOption.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeEvent: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeEvent.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeEvent.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeEvent.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeKeysClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeKeysClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeKeysClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeKeysClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMember: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMember.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMember.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMember.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMessage: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMessage.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMessage.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMessage.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeModel: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeModel.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeModel.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeModel.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeOrderBy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeOrderBy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeOrderBy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeOrderBy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementEntry: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementEntry.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementEntry.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementEntry.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypePlayerAchievementProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypePlayerAchievementProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypePlayerAchievementProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypePlayerAchievementProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlField: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlField.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlField.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlField.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeSqlRow: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeSqlRow.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeSqlRow.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeSqlRow.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeStruct: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeStruct.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeStruct.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeStruct.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTaskProgress: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTaskProgress.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTaskProgress.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTaskProgress.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeToken: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeToken.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeToken.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeToken.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenBalance: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenBalance.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenBalance.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenBalance.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenContract: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenContract.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenContract.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenContract.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTokenTransfer: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTokenTransfer.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTokenTransfer.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTokenTransfer.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransaction: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransaction.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransaction.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransaction.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTransactionCall: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTransactionCall.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTransactionCall.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTransactionCall.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeWorld: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeWorld.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeWorld.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeWorld.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeClause: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeClause.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeClause.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeClause.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeContractType: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeContractType.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeContractType.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeContractType.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeMemberValue: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeMemberValue.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeMemberValue.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeMemberValue.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeTy: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeTy.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeTy.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeTy.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceOptionalTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterOptionalTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterOptionalTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterOptionalTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeFieldElement: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeFieldElement.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeFieldElement.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeFieldElement.write(it, buf) + } + } +} + + + + +/** + * @suppress + */ +public object FfiConverterSequenceTypeU256: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeU256.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeU256.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeU256.write(it, buf) + } + } +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias FieldElement = kotlin.String +public typealias FfiConverterTypeFieldElement = FfiConverterString + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias U256 = kotlin.String +public typealias FfiConverterTypeU256 = FfiConverterString + diff --git a/examples/kotlin/build/jna-5.13.0.jar b/examples/kotlin/build/jna-5.13.0.jar new file mode 100644 index 0000000..3d49c81 Binary files /dev/null and b/examples/kotlin/build/jna-5.13.0.jar differ diff --git a/examples/kotlin/build/libdojo_uniffi.dylib b/examples/kotlin/build/libdojo_uniffi.dylib new file mode 100755 index 0000000..9f42b15 Binary files /dev/null and b/examples/kotlin/build/libdojo_uniffi.dylib differ diff --git a/examples/kotlin/run_fetch_entities.sh b/examples/kotlin/run_fetch_entities.sh new file mode 100755 index 0000000..7ac98cf --- /dev/null +++ b/examples/kotlin/run_fetch_entities.sh @@ -0,0 +1,115 @@ +#!/bin/bash + +# Script to compile and run the Kotlin fetch_entities example +# Usage: ./run_fetch_entities.sh [torii_url] [world_address] + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Default values +TORII_URL="${1:-http://localhost:8080}" +WORLD_ADDRESS="${2:-0x0}" + +echo "Running Kotlin example..." +echo "Torii URL: $TORII_URL" +echo "World Address: $WORLD_ADDRESS" +echo + +# Get the repository root (3 levels up from this script) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" + +# Paths +BINDINGS_DIR="$REPO_ROOT/bindings/kotlin" +LIB_PATH="$REPO_ROOT/target/release/libdojo_uniffi.dylib" +EXAMPLE_FILE="$SCRIPT_DIR/FetchEntities.kt" + +# Check if library exists +if [ ! -f "$LIB_PATH" ]; then + echo -e "${RED}Error: Library not found at $LIB_PATH${NC}" + echo "Please build the library first with:" + echo " cargo build --release -p dojo-uniffi" + exit 1 +fi + +# Check if Kotlin bindings exist +if [ ! -d "$BINDINGS_DIR" ]; then + echo -e "${RED}Error: Kotlin bindings not found at $BINDINGS_DIR${NC}" + echo "Please generate the bindings first with:" + echo " ./target/release/uniffi-bindgen-kotlin" + exit 1 +fi + +# Check if kotlinc is installed +if ! command -v kotlinc &> /dev/null; then + echo -e "${RED}Error: kotlinc not found${NC}" + echo "Please install Kotlin:" + echo " macOS: brew install kotlin" + echo " Linux: See https://kotlinlang.org/docs/command-line.html" + exit 1 +fi + +# Create temporary build directory +BUILD_DIR="$SCRIPT_DIR/build" +mkdir -p "$BUILD_DIR" + +# Download JNA if not present +JNA_VERSION="5.13.0" +JNA_JAR="$BUILD_DIR/jna-$JNA_VERSION.jar" + +if [ ! -f "$JNA_JAR" ]; then + echo "Downloading JNA library..." + curl -L -o "$JNA_JAR" "https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar" + if [ $? -ne 0 ]; then + echo -e "${RED}Failed to download JNA library${NC}" + exit 1 + fi +fi + +# Copy the Kotlin bindings +echo "Copying Kotlin bindings..." +cp -r "$BINDINGS_DIR"/* "$BUILD_DIR/" + +# Copy the example file +cp "$EXAMPLE_FILE" "$BUILD_DIR/" + +# Copy the library +echo "Copying native library..." +cp "$LIB_PATH" "$BUILD_DIR/" + +# Compile the Kotlin code +echo "Compiling Kotlin code..." +cd "$BUILD_DIR" + +# Find all Kotlin files +KOTLIN_FILES=$(find . -name "*.kt") + +# Compile with JNA on classpath +kotlinc $KOTLIN_FILES -include-runtime -cp "$JNA_JAR" -d FetchEntities.jar + +if [ $? -ne 0 ]; then + echo -e "${RED}Compilation failed${NC}" + exit 1 +fi + +echo -e "${GREEN}✓ Compilation successful${NC}" +echo + +# Set library path for macOS +export DYLD_LIBRARY_PATH="$BUILD_DIR:$DYLD_LIBRARY_PATH" + +# Run the example +echo "Running example..." +echo +java -Djava.library.path="$BUILD_DIR" -cp "$JNA_JAR:FetchEntities.jar" com.dojoengine.examples.FetchEntitiesKt "$TORII_URL" "$WORLD_ADDRESS" + +# Cleanup on success +cd "$SCRIPT_DIR" +# Uncomment to keep build artifacts for inspection: +# echo "Build artifacts kept in: $BUILD_DIR" + diff --git a/examples/kotlin/run_simple_test.sh b/examples/kotlin/run_simple_test.sh new file mode 100755 index 0000000..df50879 --- /dev/null +++ b/examples/kotlin/run_simple_test.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +# Script to run the simple Kotlin test +# Usage: ./run_simple_test.sh [torii_url] + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Default values +TORII_URL="${1:-http://localhost:8080}" + +echo "Running Kotlin simple test..." +echo "Torii URL: $TORII_URL" +echo + +# Get the repository root +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" + +# Paths +BINDINGS_DIR="$REPO_ROOT/bindings/kotlin" +LIB_PATH="$REPO_ROOT/target/release/libdojo_uniffi.dylib" +TEST_FILE="$SCRIPT_DIR/SimpleTest.kt" + +# Check if library exists +if [ ! -f "$LIB_PATH" ]; then + echo -e "${RED}Error: Library not found at $LIB_PATH${NC}" + echo "Please build the library first with:" + echo " cargo build --release -p dojo-uniffi" + exit 1 +fi + +# Check if kotlinc is installed +if ! command -v kotlinc &> /dev/null; then + echo -e "${RED}Error: kotlinc not found${NC}" + echo "Please install Kotlin:" + echo " macOS: brew install kotlin" + exit 1 +fi + +# Create temporary build directory +BUILD_DIR="$SCRIPT_DIR/build-simple" +mkdir -p "$BUILD_DIR" + +# Download JNA if not present +JNA_VERSION="5.13.0" +JNA_JAR="$BUILD_DIR/jna-$JNA_VERSION.jar" + +if [ ! -f "$JNA_JAR" ]; then + echo "Downloading JNA library..." + curl -L -o "$JNA_JAR" "https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar" + if [ $? -ne 0 ]; then + echo -e "${RED}Failed to download JNA library${NC}" + exit 1 + fi +fi + +# Copy just the core Kotlin binding file (avoid complex types) +echo "Copying Kotlin bindings..." +cp "$BINDINGS_DIR/com/dojoengine/dojo/dojo.kt" "$BUILD_DIR/" 2>/dev/null || { + mkdir -p "$BUILD_DIR/com/dojoengine/dojo" + cp "$BINDINGS_DIR/com/dojoengine/dojo/dojo.kt" "$BUILD_DIR/com/dojoengine/dojo/" +} + +# Copy the test file +cp "$TEST_FILE" "$BUILD_DIR/" + +# Copy the library +echo "Copying native library..." +cp "$LIB_PATH" "$BUILD_DIR/" + +# Compile just the simple test +echo "Compiling Kotlin code..." +cd "$BUILD_DIR" + +# Try to compile +kotlinc SimpleTest.kt -include-runtime -cp "$JNA_JAR" -d SimpleTest.jar 2>&1 | head -20 + +if [ ${PIPESTATUS[0]} -ne 0 ]; then + echo -e "${RED}Compilation failed${NC}" + echo "" + echo "Note: The Kotlin bindings have limitations with complex recursive types." + echo "This is a known issue with UniFFI's Kotlin generator." + echo "" + echo "For full functionality, please use:" + echo " - Swift bindings (examples/swift/)" + echo " - Python bindings (examples/python/)" + echo "" + exit 1 +fi + +echo -e "${GREEN}✓ Compilation successful${NC}" +echo + +# Set library path +export DYLD_LIBRARY_PATH="$BUILD_DIR:$DYLD_LIBRARY_PATH" + +# Run the test +echo "Running test..." +echo +java -Djava.library.path="$BUILD_DIR" -cp "$JNA_JAR:SimpleTest.jar" com.dojoengine.examples.SimpleTestKt "$TORII_URL" + +cd "$SCRIPT_DIR" + diff --git a/examples/python/README.md b/examples/python/README.md new file mode 100644 index 0000000..59e0c55 --- /dev/null +++ b/examples/python/README.md @@ -0,0 +1,117 @@ +# Dojo Python Examples + +Examples demonstrating how to use the Dojo Python bindings to interact with Torii servers. + +## Prerequisites + +1. Build the Dojo library: + ```bash + cd ../.. + cargo build --release + ``` + +2. Generate Python bindings: + ```bash + cargo run --bin uniffi-bindgen-python --release -- \ + target/release/libdojo_c.dylib bindings/python + ``` + +3. Make sure you have a Torii server running (default: `http://localhost:8080`) + +## Examples + +### 1. Fetch Entities (`fetch_entities.py`) + +Queries and displays entities from a Torii server. + +**Usage:** +```bash +python3 fetch_entities.py [torii_url] [world_address] +``` + +**Example:** +```bash +python3 fetch_entities.py http://localhost:8080 0x1234... +``` + +**What it does:** +- Connects to a Torii server +- Fetches the first 10 entities +- Displays entity metadata and model information +- Shows pagination cursor for fetching more + +### 2. Subscribe to Entities (`subscribe_entities.py`) + +Subscribes to real-time entity updates using callbacks. + +**Usage:** +```bash +python3 subscribe_entities.py [torii_url] [world_address] +``` + +**Example:** +```bash +python3 subscribe_entities.py http://localhost:8080 0x1234... +``` + +**What it does:** +- Connects to a Torii server +- Subscribes to entity updates +- Prints updates in real-time as they occur +- Press Ctrl+C to unsubscribe and exit + +## Available Client Methods + +The `ToriiClient` provides many methods for interacting with Dojo: + +### Queries +- `entities(query)` - Query entities +- `event_messages(query)` - Query event messages +- `worlds(world_addresses)` - Get world metadata +- `controllers(query)` - Query controllers +- `contracts(query)` - Query contracts +- `tokens(query)` - Query tokens +- `token_balances(query)` - Query token balances +- `token_contracts(query)` - Query token contracts +- `token_transfers(query)` - Query token transfers +- `transactions(query)` - Query transactions +- `aggregations(query)` - Query aggregations (leaderboards, stats) +- `activities(query)` - Query activities (user sessions) +- `achievements(query)` - Query achievements +- `player_achievements(query)` - Query player achievement progress +- `starknet_events(query)` - Query raw Starknet events +- `sql(query)` - Execute SQL query + +### Publishing +- `publish_message(message)` - Publish an offchain message +- `publish_message_batch(messages)` - Publish multiple messages + +### Subscriptions +- `subscribe_entity_updates(clause, world_addresses, callback)` - Subscribe to entity updates +- `subscribe_token_balance_updates(contract_addresses, account_addresses, token_ids, callback)` - Subscribe to token balance changes +- `subscribe_token_updates(contract_addresses, token_ids, callback)` - Subscribe to token metadata updates +- `subscribe_transaction_updates(filter, callback)` - Subscribe to transaction updates +- `subscribe_event_updates(keys, callback)` - Subscribe to Starknet event updates +- `cancel_subscription(subscription_id)` - Cancel a subscription + +## Type Aliases + +For convenience: +- `FieldElement` = `str` (hex string like "0x1234...") +- `U256` = `str` (hex string like "0xabcd...") + +All methods are async and should be called with `await`. + +## Error Handling + +All errors are raised as `DojoError` exceptions with specific types: +- `DojoError.ClientError` +- `DojoError.ConnectionError` +- `DojoError.QueryError` +- `DojoError.SubscriptionError` +- etc. + +## More Examples + +Check the main README for Swift and Kotlin examples. + diff --git a/examples/python/fetch_entities.py b/examples/python/fetch_entities.py new file mode 100644 index 0000000..f34fd57 --- /dev/null +++ b/examples/python/fetch_entities.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +""" +Example: Fetch entities from a Torii server + +This example demonstrates how to use the Dojo Python bindings to: +1. Connect to a Torii server +2. Query entities with pagination +3. Display entity data +""" + +import sys +import shutil +from pathlib import Path +import asyncio + +# Setup paths +repo_root = Path(__file__).parent.parent.parent +bindings_path = repo_root / "bindings" / "python" +lib_source = repo_root / "target" / "release" / "libdojo_uniffi.dylib" +lib_dest = bindings_path / "libdojo_uniffi.dylib" + +# Copy library to bindings directory if it doesn't exist or is outdated +if not lib_dest.exists() or lib_source.stat().st_mtime > lib_dest.stat().st_mtime: + print(f"Copying library from {lib_source} to {lib_dest}...") + shutil.copy2(lib_source, lib_dest) + print("✓ Library copied") + +# Add the bindings directory to the path +sys.path.insert(0, str(bindings_path)) + +from dojo import ( + ToriiClient, + Query, + Pagination, + PaginationDirection, + OrderBy, + OrderDirection, +) + + +async def fetch_entities(torii_url: str, world_address: str): + """Fetch entities from a Torii server""" + + print(f"Connecting to Torii at {torii_url}...") + + # Create a client (using constructor without config for default 4MB max message size) + # If you need custom config, use: ToriiClient.new_with_config(torii_url, max_message_size) + client = await ToriiClient.new_with_config(torii_url, 4 * 1024 * 1024) + + print("✓ Connected successfully!") + + # Create a query to fetch entities + query = Query( + world_addresses=[], + pagination=Pagination( + cursor=None, # Start from beginning + limit=10, # Fetch 10 entities + direction=PaginationDirection.FORWARD, + order_by=[ + + ] + ), + clause=None, # No filtering clause + no_hashed_keys=False, + models=[], # Empty means all models + historical=False + ) + + print("\nFetching entities...") + page = await client.entities(query) + + print(f"\n✓ Retrieved {len(page.items)} entities") + + if page.next_cursor: + print(f"Next cursor available: {page.next_cursor[:20]}...") + else: + print("No more pages available") + + # Display entity information + for i, entity in enumerate(page.items, 1): + print(f"\n{'='*60}") + print(f"Entity {i}:") + print(f" World Address: {entity.world_address}") + print(f" Hashed Keys: {entity.hashed_keys}") + print(f" Created At: {entity.created_at}") + print(f" Updated At: {entity.updated_at}") + print(f" Executed At: {entity.executed_at}") + print(f" Models: {len(entity.models)} model(s)") + + # Display model information + for j, model in enumerate(entity.models, 1): + print(f"\n Model {j}: {model.name}") + print(f" Children: {len(model.children)} field(s)") + for child in model.children[:3]: # Show first 3 fields + print(f" - {child.name} (key={child.key})") + if len(model.children) > 3: + print(f" ... and {len(model.children) - 3} more") + + print(f"\n{'='*60}\n") + + +async def main(): + # Default Torii URL (adjust as needed) + torii_url = "http://localhost:8080" + + # Example world address (adjust to your actual world address) + world_address = "0x0" + + # Check for command line arguments + if len(sys.argv) > 1: + torii_url = sys.argv[1] + if len(sys.argv) > 2: + world_address = sys.argv[2] + + print("Dojo Python Example: Fetch Entities") + print("====================================\n") + + try: + await fetch_entities(torii_url, world_address) + except Exception as e: + print(f"\n❌ Error: {e}") + print(f"\nUsage: {sys.argv[0]} [torii_url] [world_address]") + print(f"Example: {sys.argv[0]} http://localhost:8080 0x1234...") + sys.exit(1) + + +if __name__ == "__main__": + asyncio.run(main()) + diff --git a/examples/python/subscribe_entities.py b/examples/python/subscribe_entities.py new file mode 100644 index 0000000..9930149 --- /dev/null +++ b/examples/python/subscribe_entities.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 +""" +Example: Subscribe to entity updates from a Torii server + +This example demonstrates real-time entity subscriptions using callbacks. +""" + +import asyncio +import sys +import shutil +from pathlib import Path + +# Setup paths +repo_root = Path(__file__).parent.parent.parent +bindings_path = repo_root / "bindings" / "python" +lib_source = repo_root / "target" / "release" / "libdojo_uniffi.dylib" +lib_dest = bindings_path / "libdojo_uniffi.dylib" + +# Copy library to bindings directory if it doesn't exist or is outdated +if not lib_dest.exists() or lib_source.stat().st_mtime > lib_dest.stat().st_mtime: + print(f"Copying library from {lib_source} to {lib_dest}...") + shutil.copy2(lib_source, lib_dest) + print("✓ Library copied") + +# Add the bindings directory to the path +sys.path.insert(0, str(bindings_path)) + +from dojo import ( + ToriiClient, + EntityUpdateCallback, +) + + +class MyEntityCallback: + """Custom callback handler for entity updates""" + + def __init__(self): + self.update_count = 0 + + def on_update(self, entity): + """Called when an entity is updated""" + self.update_count += 1 + print(f"\n📦 Entity Update #{self.update_count}") + print(f" World: {entity.world_address}") + print(f" Keys: {entity.hashed_keys}") + print(f" Models: {len(entity.models)}") + print(f" Updated: {entity.updated_at}") + + def on_error(self, error): + """Called when an error occurs""" + print(f"\n❌ Subscription Error: {error}") + + +async def subscribe_to_entities(torii_url: str, world_address: str): + """Subscribe to entity updates""" + + print(f"Connecting to Torii at {torii_url}...") + + # Create client + client = await ToriiClient.new_with_config(torii_url, 4 * 1024 * 1024) + + print("✓ Connected successfully!") + + # Create callback handler + callback = MyEntityCallback() + + print("\nSubscribing to entity updates...") + print("Press Ctrl+C to stop\n") + + # Subscribe to entity updates + # clause=None means subscribe to all entities + # world_addresses=[world_address] filters by world + subscription_id = await client.subscribe_entity_updates( + clause=None, + world_addresses=[world_address], + callback=callback + ) + + print(f"✓ Subscribed with ID: {subscription_id}") + print("Waiting for updates...\n") + + try: + # Keep the script running to receive updates + while True: + await asyncio.sleep(1) + except KeyboardInterrupt: + print("\n\nUnsubscribing...") + client.cancel_subscription(subscription_id) + print(f"✓ Unsubscribed. Total updates received: {callback.update_count}") + + +async def main(): + torii_url = "http://localhost:8080" + world_address = "0x0" + + if len(sys.argv) > 1: + torii_url = sys.argv[1] + if len(sys.argv) > 2: + world_address = sys.argv[2] + + print("Dojo Python Example: Subscribe to Entities") + print("==========================================\n") + + try: + await subscribe_to_entities(torii_url, world_address) + except Exception as e: + print(f"\n❌ Error: {e}") + print(f"\nUsage: {sys.argv[0]} [torii_url] [world_address]") + sys.exit(1) + + +if __name__ == "__main__": + asyncio.run(main()) + diff --git a/examples/swift/README.md b/examples/swift/README.md new file mode 100644 index 0000000..998af96 --- /dev/null +++ b/examples/swift/README.md @@ -0,0 +1,248 @@ +# Swift Examples for Dojo Client + +This directory contains Swift examples demonstrating how to use the Dojo Swift bindings to interact with a Torii server. + +## Prerequisites + +- Swift 5.9+ (with async/await support) +- macOS (for the `.dylib` library) +- A running Torii server + +## Building the Bindings + +Before running the examples, you need to build the Rust library and generate the Swift bindings: + +```bash +# From the repository root +cd /Users/nasr/Documents/development.nosync/dojo.c + +# Build the Rust library in release mode +cargo build --release + +# Generate Swift bindings +cargo run --bin uniffi-bindgen-swift --release -- target/release/libdojo_c.dylib bindings/swift +``` + +This will generate: +- `bindings/swift/DojoEngine.swift` - The Swift interface +- `bindings/swift/DojoEngineFFI.h` - The C header file +- `bindings/swift/DojoEngineFFI.modulemap` - The module map + +## Running the Examples + +### Fetch Entities Example + +This example connects to a Torii server and fetches entities with pagination. + +**Basic usage:** +```bash +./run_fetch_entities.sh +``` + +**With custom Torii URL:** +```bash +./run_fetch_entities.sh http://localhost:8080 +``` + +**With custom Torii URL and world address:** +```bash +./run_fetch_entities.sh http://localhost:8080 0x1234567890abcdef +``` + +### Manual Execution + +If you prefer to run the Swift script manually, you need to specify the library paths: + +```bash +swift \ + -I bindings/swift \ + -L target/release \ + -ldojo_c \ + examples/swift/fetch_entities.swift \ + http://localhost:8080 \ + 0x0 +``` + +**Note:** You may need to import the generated Swift module. The easiest way is to use the provided shell script `run_fetch_entities.sh`. + +## Examples Overview + +### 1. fetch_entities.swift + +Demonstrates basic entity querying: +- Connect to a Torii server +- Create a query with pagination +- Fetch entities +- Display entity and model information + +Key features: +- Async/await syntax +- Error handling +- Pagination support +- Model traversal + +## Swift API Overview + +### ToriiClient + +The main client interface: + +```swift +// Create a client with default config (4MB max message size) +let client = try await ToriiClient(toriiUrl: "http://localhost:8080") + +// Create a client with custom max message size +let client = try await ToriiClient.newWithConfig( + toriiUrl: "http://localhost:8080", + maxMessageSize: 8 * 1024 * 1024 // 8MB +) +``` + +### Query Types + +```swift +// Create a query for entities +let query = Query( + worldAddresses: [], // Empty = all worlds + pagination: Pagination( + cursor: nil, // Start from beginning + limit: 10, // Number of items + direction: .forward, // Direction + orderBy: [ + OrderBy( + field: "created_at", + direction: .desc + ) + ] + ), + clause: nil, // Filtering clause + noHashedKeys: false, + models: [], // Empty = all models + historical: false +) + +// Fetch entities +let page = try await client.entities(query: query) +``` + +### Pagination + +```swift +struct Pagination { + let cursor: String? + let limit: UInt32 + let direction: PaginationDirection + let orderBy: [OrderBy] +} + +enum PaginationDirection { + case forward + case backward +} + +struct OrderBy { + let field: String + let direction: OrderDirection +} + +enum OrderDirection { + case asc + case desc +} +``` + +### Entity Structure + +```swift +struct Entity { + let worldAddress: String + let hashedKeys: String + let createdAt: String + let updatedAt: String + let executedAt: String + let models: [Model] +} + +struct Model { + let name: String + let children: [Member] + let layout: Vec? + let useLegacyStore: Bool +} +``` + +## Error Handling + +All async methods can throw `DojoError`: + +```swift +do { + let page = try await client.entities(query: query) + // Process results +} catch DojoError.ConnectionError { + print("Failed to connect to Torii server") +} catch DojoError.QueryError { + print("Query failed") +} catch { + print("Unexpected error: \(error)") +} +``` + +## Troubleshooting + +### Library Not Found + +If you get an error about the library not being found: + +``` +error: unable to load dynamic library 'libdojo_c.dylib' +``` + +**Solution:** Make sure you've built the library and you're running from the correct directory: +```bash +cargo build --release +./examples/swift/run_fetch_entities.sh +``` + +### Module Not Found + +If Swift can't find the DojoEngine module: + +``` +error: no such module 'DojoEngine' +``` + +**Solution:** Generate the Swift bindings: +```bash +cargo run --bin uniffi-bindgen-swift --release -- target/release/libdojo_c.dylib bindings/swift +``` + +### Connection Errors + +If you get connection errors: + +**Solution:** Ensure your Torii server is running: +```bash +# Check if Torii is running +curl http://localhost:8080 + +# Or start your Torii server +torii --world 0x... --rpc https://... +``` + +## Next Steps + +After trying these examples, you can explore: + +1. **Subscriptions**: Real-time updates for entities, tokens, and events +2. **Custom Queries**: Advanced filtering with clauses +3. **Token Operations**: Query tokens, balances, and transfers +4. **Transactions**: Query and monitor transactions +5. **SQL Queries**: Direct SQL queries against the Torii database + +## Additional Resources + +- [Dojo Documentation](https://book.dojoengine.org/) +- [Torii Documentation](https://book.dojoengine.org/toolchain/torii/) +- [Swift Async/Await Guide](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html) + diff --git a/examples/swift/fetch_entities.swift b/examples/swift/fetch_entities.swift new file mode 100644 index 0000000..b5b27b2 --- /dev/null +++ b/examples/swift/fetch_entities.swift @@ -0,0 +1,95 @@ +/** + * Example: Fetch entities from a Torii server + * + * This example demonstrates how to use the Dojo Swift bindings to: + * 1. Connect to a Torii server + * 2. Query entities with pagination + * 3. Display entity data + */ + +import Foundation + +func fetchEntities(toriiUrl: String, worldAddress: String) throws { + print("Connecting to Torii at \(toriiUrl)...") + + // Create a client with default configuration (4MB max message size) + let client = try ToriiClient(toriiUrl: toriiUrl) + + print("✓ Connected successfully!") + + // Create a query to fetch entities + let query = Query( + worldAddresses: [], + pagination: Pagination( + cursor: nil, // Start from beginning + limit: 10, // Fetch 10 entities + direction: .forward, // Forward pagination + orderBy: [] // No specific ordering + ), + clause: nil, // No filtering clause + noHashedKeys: false, + models: [], // Empty means all models + historical: false + ) + + print("\nFetching entities...") + let page = try client.entities(query: query) + + print("\n✓ Retrieved \(page.items.count) entities") + + if let nextCursor = page.nextCursor { + let cursorPreview = String(nextCursor.prefix(20)) + print("Next cursor available: \(cursorPreview)...") + } else { + print("No more pages available") + } + + // Display entity information + for (i, entity) in page.items.enumerated() { + print("\n" + String(repeating: "=", count: 60)) + print("Entity \(i + 1):") + print(" World Address: \(entity.worldAddress)") + print(" Hashed Keys: \(entity.hashedKeys)") + print(" Created At: \(entity.createdAt)") + print(" Updated At: \(entity.updatedAt)") + print(" Executed At: \(entity.executedAt)") + print(" Models: \(entity.models.count) model(s)") + + // Display model information + for (j, model) in entity.models.enumerated() { + print("\n Model \(j + 1): \(model.name)") + print(" Children: \(model.children.count) field(s)") + + // Show first 3 fields + for child in model.children.prefix(3) { + print(" - \(child.name) (key=\(child.key))") + } + + if model.children.count > 3 { + print(" ... and \(model.children.count - 3) more") + } + } + } + + print("\n" + String(repeating: "=", count: 60) + "\n") +} + +// Parse command line arguments +let arguments = CommandLine.arguments +let toriiUrl = arguments.count > 1 ? arguments[1] : "http://localhost:8080" +let worldAddress = arguments.count > 2 ? arguments[2] : "0x0" + +print("Dojo Swift Example: Fetch Entities") +print("====================================\n") + +// Run the function +do { + try fetchEntities(toriiUrl: toriiUrl, worldAddress: worldAddress) + exit(0) +} catch { + print("\n❌ Error: \(error)") + print("\nUsage: swift fetch_entities.swift [torii_url] [world_address]") + print("Example: swift fetch_entities.swift http://localhost:8080 0x1234...") + exit(1) +} + diff --git a/examples/swift/run_fetch_entities.sh b/examples/swift/run_fetch_entities.sh new file mode 100755 index 0000000..c00678b --- /dev/null +++ b/examples/swift/run_fetch_entities.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -e + +# Get the repository root (2 levels up from this script) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" + +cd "$REPO_ROOT" + +# Check if library exists +if [ ! -f "target/release/libdojo_uniffi.dylib" ]; then + echo "Error: Library not found. Please build it first:" + echo " cargo build --release" + exit 1 +fi + +# Check if Swift bindings exist +if [ ! -f "bindings/swift/DojoEngine.swift" ]; then + echo "Error: Swift bindings not found. Please generate them first:" + echo " cargo run --bin uniffi-bindgen-swift --release -- target/release/libdojo_uniffi.dylib bindings/swift --swift-sources --headers --modulemap" + exit 1 +fi + +if [ ! -f "bindings/swift/DojoEngineFFI.h" ]; then + echo "Error: Swift binding headers not found. Regenerating..." + cargo run --bin uniffi-bindgen-swift --release -- target/release/libdojo_uniffi.dylib bindings/swift --swift-sources --headers --modulemap +fi + +# Parse arguments +TORII_URL="${1:-http://localhost:8080}" +WORLD_ADDRESS="${2:-0x0}" + +# Create a temporary directory for compilation +TEMP_DIR=$(mktemp -d) +trap "rm -rf $TEMP_DIR" EXIT + +# Copy all necessary files +cp "bindings/swift/DojoEngine.swift" "$TEMP_DIR/" +cp "bindings/swift/DojoEngineFFI.h" "$TEMP_DIR/" +cp "bindings/swift/dojo_uniffi.modulemap" "$TEMP_DIR/module.modulemap" +cp "examples/swift/fetch_entities.swift" "$TEMP_DIR/" + +# Create a combined Swift file +cat > "$TEMP_DIR/main.swift" << 'EOF' +// Combined Swift bindings and example +EOF + +cat "bindings/swift/DojoEngine.swift" >> "$TEMP_DIR/main.swift" + +cat >> "$TEMP_DIR/main.swift" << 'EOF' + +// Example code below +EOF + +# Add the example code (skip the first 10 lines which are comments and import) +tail -n +10 "examples/swift/fetch_entities.swift" >> "$TEMP_DIR/main.swift" + +echo "Running Swift example..." +echo "Torii URL: $TORII_URL" +echo "World Address: $WORLD_ADDRESS" +echo "" + +# Compile with proper module import and bridging header +cd "$TEMP_DIR" +swiftc -o fetch_entities \ + -import-objc-header DojoEngineFFI.h \ + -I . \ + -L "$REPO_ROOT/target/release" \ + -ldojo_uniffi \ + -Xlinker -rpath -Xlinker "$REPO_ROOT/target/release" \ + main.swift + +# Run the compiled program +DYLD_LIBRARY_PATH="$REPO_ROOT/target/release" \ + ./fetch_entities "$TORII_URL" "$WORLD_ADDRESS" + diff --git a/scripts/example.sh b/scripts/example.sh index 6f7111f..d105ba7 100755 --- a/scripts/example.sh +++ b/scripts/example.sh @@ -16,14 +16,14 @@ done # Build the Rust library in release mode if requested if [ $REBUILD -eq 1 ]; then echo "Building Rust library in release mode..." - cargo build --release -p c + cargo build --release -p dojo-c fi # Check if the dylib/so was built successfully if [[ "$OSTYPE" == "darwin"* ]]; then - LIB_PATH="./target/release/libc.dylib" + LIB_PATH="./target/release/libdojo_c.dylib" else - LIB_PATH="./target/release/libc.so" + LIB_PATH="./target/release/libdojo_c.so" fi if [ ! -f "$LIB_PATH" ]; then diff --git a/src/bin/uniffi-bindgen-kotlin.rs b/src/bin/uniffi-bindgen-kotlin.rs new file mode 100644 index 0000000..f9a2f4d --- /dev/null +++ b/src/bin/uniffi-bindgen-kotlin.rs @@ -0,0 +1,55 @@ +use std::env; +use std::process; +use uniffi_bindgen::bindings::KotlinBindingGenerator; +use uniffi_bindgen::library_mode::generate_bindings; +use camino::Utf8PathBuf; + +fn main() { + let args: Vec = env::args().collect(); + + if args.len() < 3 { + eprintln!("UniFFI Kotlin Binding Generator"); + eprintln!(); + eprintln!("Usage: {} ", args[0]); + eprintln!(); + eprintln!("Example:"); + eprintln!(" {} target/release/libdojo_c.dylib bindings/kotlin", args[0]); + eprintln!(); + process::exit(1); + } + + let library_path = Utf8PathBuf::from(&args[1]); + let out_dir = Utf8PathBuf::from(&args[2]); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release"); + process::exit(1); + } + + println!("Generating Kotlin bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + // Use library mode with Kotlin binding generator + let config_supplier = uniffi_bindgen::EmptyCrateConfigSupplier; + + match generate_bindings( + &library_path, + None, // crate_name (auto-detect) + &KotlinBindingGenerator, + &config_supplier, + None, // config_file_override + &out_dir, + false, // try_format_code + ) { + Ok(_) => { + println!("✓ Kotlin bindings generated successfully in {}", out_dir); + } + Err(e) => { + eprintln!("Error generating bindings: {}", e); + process::exit(1); + } + } +} + diff --git a/src/bin/uniffi-bindgen-python.rs b/src/bin/uniffi-bindgen-python.rs new file mode 100644 index 0000000..e4f37bb --- /dev/null +++ b/src/bin/uniffi-bindgen-python.rs @@ -0,0 +1,65 @@ +use std::env; +use std::process; +use uniffi_bindgen::bindings::python::run_pipeline; +use uniffi_bindgen::cargo_metadata::CrateConfigSupplier; +use uniffi_bindgen::pipeline::initial::Root; +use camino::Utf8PathBuf; + +fn main() { + let args: Vec = env::args().collect(); + + if args.len() < 3 { + eprintln!("UniFFI Python Binding Generator"); + eprintln!(); + eprintln!("Usage: {} ", args[0]); + eprintln!(); + eprintln!("Example:"); + eprintln!(" {} target/release/libdojo_c.dylib bindings/python", args[0]); + eprintln!(); + process::exit(1); + } + + let library_path = Utf8PathBuf::from(&args[1]); + let out_dir = Utf8PathBuf::from(&args[2]); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release"); + process::exit(1); + } + + println!("Generating Python bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + // Use cargo metadata to get crate configuration + let metadata = match cargo_metadata::MetadataCommand::new().exec() { + Ok(m) => m, + Err(e) => { + eprintln!("Error getting cargo metadata: {}", e); + eprintln!("Make sure you're running this from a cargo project directory"); + process::exit(1); + } + }; + + let config_supplier = CrateConfigSupplier::from(metadata); + + match Root::from_library(config_supplier, &library_path, None) { + Ok(root) => { + match run_pipeline(root, &out_dir) { + Ok(_) => { + println!("✓ Python bindings generated successfully in {}", out_dir); + } + Err(e) => { + eprintln!("Error generating Python bindings: {}", e); + process::exit(1); + } + } + } + Err(e) => { + eprintln!("Error loading library metadata: {}", e); + process::exit(1); + } + } +} + diff --git a/src/bin/uniffi-bindgen-swift.rs b/src/bin/uniffi-bindgen-swift.rs new file mode 100644 index 0000000..5396425 --- /dev/null +++ b/src/bin/uniffi-bindgen-swift.rs @@ -0,0 +1,71 @@ +use std::env; +use std::process; +use uniffi_bindgen::bindings::{generate_swift_bindings, SwiftBindingsOptions}; +use camino::Utf8PathBuf; + +fn main() { + let args: Vec = env::args().collect(); + + if args.len() < 3 { + eprintln!("UniFFI Swift Binding Generator"); + eprintln!(); + eprintln!("Usage: {} [--swift-sources] [--headers] [--modulemap]", args[0]); + eprintln!(); + eprintln!("Options:"); + eprintln!(" --swift-sources Generate .swift source files (default)"); + eprintln!(" --headers Generate .h header files"); + eprintln!(" --modulemap Generate modulemap"); + eprintln!(" --xcframework Generate XCFramework-compatible modulemap"); + eprintln!(); + eprintln!("Examples:"); + eprintln!(" {} target/release/libdojo_c.dylib bindings/swift --swift-sources", args[0]); + eprintln!(" {} target/release/libdojo_c.dylib bindings/swift --headers --modulemap", args[0]); + eprintln!(); + process::exit(1); + } + + let library_path = Utf8PathBuf::from(&args[1]); + let out_dir = Utf8PathBuf::from(&args[2]); + + if !library_path.exists() { + eprintln!("Error: Library file not found: {}", library_path); + eprintln!("Build the library first with: cargo build --release"); + process::exit(1); + } + + // Parse options + let has_swift_sources = args.contains(&"--swift-sources".to_string()); + let has_headers = args.contains(&"--headers".to_string()); + let has_modulemap = args.contains(&"--modulemap".to_string()); + let has_xcframework = args.contains(&"--xcframework".to_string()); + + // Default to generating Swift sources if no specific flags are provided + let generate_swift_sources = has_swift_sources || (!has_headers && !has_modulemap); + + println!("Generating Swift bindings..."); + println!("Library: {}", library_path); + println!("Output: {}", out_dir); + + let options = SwiftBindingsOptions { + generate_swift_sources, + generate_headers: has_headers, + generate_modulemap: has_modulemap, + source: library_path, + out_dir, + xcframework: has_xcframework, + module_name: Some("DojoEngine".to_string()), + modulemap_filename: None, + metadata_no_deps: false, + link_frameworks: vec![], + }; + + match generate_swift_bindings(options) { + Ok(_) => { + println!("✓ Swift bindings generated successfully!"); + } + Err(e) => { + eprintln!("Error generating bindings: {}", e); + process::exit(1); + } + } +} diff --git a/src/dojo.udl b/src/dojo.udl new file mode 100644 index 0000000..9f3070f --- /dev/null +++ b/src/dojo.udl @@ -0,0 +1,746 @@ +// Simplified UDL - just the types that work easily with UniFFI +// Complex recursive types (Primitive, Ty, Clause, etc.) should be handled +// via procmacros in Rust rather than UDL + +namespace dojo { +}; + +// Core types +[Custom] +typedef string FieldElement; + +[Custom] +typedef string U256; + +// Enums +enum PaginationDirection { + "Forward", + "Backward", +}; + +enum OrderDirection { + "Asc", + "Desc", +}; + +enum ContractType { + "WORLD", + "ERC20", + "ERC721", + "ERC1155", + "UDC", + "OTHER", +}; + +enum CallType { + "Execute", + "ExecuteFromOutside", +}; + +enum PatternMatching { + "FixedLen", + "VariableLen", +}; + +enum LogicalOperator { + "And", + "Or", +}; + +enum ComparisonOperator { + "Eq", + "Neq", + "Gt", + "Gte", + "Lt", + "Lte", + "In", + "NotIn", + "Contains", + "ContainsAll", + "ContainsAny", + "ArrayLengthEq", + "ArrayLengthGt", + "ArrayLengthLt", +}; + +// Basic structures +dictionary Signature { + FieldElement r; + FieldElement s; +}; + +dictionary OrderBy { + string field; + OrderDirection direction; +}; + +dictionary Pagination { + string? cursor; + u32? limit; + PaginationDirection direction; + sequence order_by; +}; + +// Controller +dictionary Controller { + FieldElement address; + string username; + u64 deployed_at_timestamp; +}; + +dictionary ControllerQuery { + Pagination pagination; + sequence contract_addresses; + sequence usernames; +}; + +// Token types +dictionary Token { + FieldElement contract_address; + U256? token_id; + string name; + string symbol; + u8 decimals; + string metadata; + U256? total_supply; +}; + +dictionary TokenBalance { + U256 balance; + FieldElement account_address; + FieldElement contract_address; + U256? token_id; +}; + +dictionary TokenContract { + FieldElement contract_address; + string name; + string symbol; + u8 decimals; + string metadata; + string token_metadata; + U256? total_supply; +}; + +dictionary AttributeFilter { + string trait_name; + string trait_value; +}; + +dictionary TokenQuery { + sequence contract_addresses; + sequence token_ids; + sequence attribute_filters; + Pagination pagination; +}; + +dictionary TokenBalanceQuery { + sequence contract_addresses; + sequence account_addresses; + sequence token_ids; + Pagination pagination; +}; + +dictionary TokenContractQuery { + sequence contract_addresses; + sequence contract_types; + Pagination pagination; +}; + +dictionary TokenTransfer { + string id; + FieldElement contract_address; + FieldElement from_address; + FieldElement to_address; + U256 amount; + U256? token_id; + u64 executed_at; + string? event_id; +}; + +dictionary TokenTransferQuery { + sequence contract_addresses; + sequence account_addresses; + sequence token_ids; + Pagination pagination; +}; + +// Contract +dictionary Contract { + FieldElement contract_address; + ContractType contract_type; + u64? head; + u64? tps; + u64? last_block_timestamp; + FieldElement? last_pending_block_tx; + u64 updated_at; + u64 created_at; +}; + +dictionary ContractQuery { + sequence contract_addresses; + sequence contract_types; +}; + +// Transaction types +dictionary TransactionCall { + FieldElement contract_address; + string entrypoint; + sequence calldata; + CallType call_type; + FieldElement caller_address; +}; + +dictionary Transaction { + FieldElement transaction_hash; + FieldElement sender_address; + sequence calldata; + FieldElement max_fee; + sequence signature; + FieldElement nonce; + u64 block_number; + string transaction_type; + u64 block_timestamp; + sequence calls; + sequence unique_models; +}; + +dictionary TransactionFilter { + sequence transaction_hashes; + sequence caller_addresses; + sequence contract_addresses; + sequence entrypoints; + sequence model_selectors; + u64? from_block; + u64? to_block; +}; + +dictionary TransactionQuery { + TransactionFilter? filter; + Pagination pagination; +}; + +// Aggregation +dictionary AggregationQuery { + sequence aggregator_ids; + sequence entity_ids; + Pagination pagination; +}; + +dictionary AggregationEntry { + string id; + string aggregator_id; + string entity_id; + U256 value; + string display_value; + u64 position; + string model_id; + u64 created_at; + u64 updated_at; +}; + +// Activity +dictionary ActionCount { + string action_name; + u32 count; +}; + +dictionary Activity { + string id; + FieldElement world_address; + string namespace; + FieldElement caller_address; + u64 session_start; + u64 session_end; + u32 action_count; + sequence actions; + u64 updated_at; +}; + +dictionary ActivityQuery { + sequence world_addresses; + sequence namespaces; + sequence caller_addresses; + u64? from_time; + u64? to_time; + Pagination pagination; +}; + +// Achievement +dictionary AchievementTask { + string task_id; + string description; + u32 total; + u32 total_completions; + f64 completion_rate; + u64 created_at; +}; + +dictionary Achievement { + string id; + FieldElement world_address; + string namespace; + string entity_id; + boolean hidden; + u32 index; + u32 points; + string start; + string end; + string group; + string icon; + string title; + string description; + sequence tasks; + string? data; + u32 total_completions; + f64 completion_rate; + u64 created_at; + u64 updated_at; +}; + +dictionary AchievementQuery { + sequence world_addresses; + sequence namespaces; + boolean? hidden; + Pagination pagination; +}; + +dictionary TaskProgress { + string task_id; + u32 count; + boolean completed; +}; + +dictionary PlayerAchievementProgress { + Achievement achievement; + sequence task_progress; + boolean completed; + f64 progress_percentage; +}; + +dictionary PlayerAchievementStats { + u32 total_points; + u32 completed_achievements; + u32 total_achievements; + f64 completion_percentage; + u64? last_achievement_at; + u64 created_at; + u64 updated_at; +}; + +dictionary PlayerAchievementEntry { + FieldElement player_address; + PlayerAchievementStats stats; + sequence achievements; +}; + +dictionary PlayerAchievementQuery { + sequence world_addresses; + sequence namespaces; + sequence player_addresses; + Pagination pagination; +}; + +// General entity query +dictionary Query { + sequence world_addresses; + Pagination pagination; + Clause? clause; + boolean no_hashed_keys; + sequence models; + boolean historical; +}; + +// Event query +dictionary EventQuery { + KeysClause? keys; + Pagination pagination; +}; + +// SQL query result types +dictionary SqlField { + string name; + SqlValue value; +}; + +dictionary SqlRow { + sequence fields; +}; + +[Enum] +interface SqlValue { + Text(string value); + Integer(i64 value); + Real(f64 value); + Blob(sequence value); + Null(); +}; + +dictionary AchievementProgression { + string id; + string achievement_id; + string task_id; + FieldElement world_address; + string namespace; + FieldElement player_id; + u32 count; + boolean completed; + u64? completed_at; + u64 created_at; + u64 updated_at; +}; + +// Schema types - Complex enums with associated data + +[Enum] +interface Primitive { + I8(i8 value); + I16(i16 value); + I32(i32 value); + I64(i64 value); + I128(sequence value); + U8(u8 value); + U16(u16 value); + U32(u32 value); + U64(u64 value); + U128(sequence value); + U256(U256 value); + Bool(boolean value); + Felt252(FieldElement value); + ClassHash(FieldElement value); + ContractAddress(FieldElement value); + EthAddress(FieldElement value); +}; + +[Enum] +interface MemberValue { + Primitive(Primitive value); + String(string value); + List(sequence values); +}; + +dictionary Member { + string name; + Ty ty; + boolean key; +}; + +dictionary Struct { + string name; + sequence children; +}; + +dictionary EnumOption { + string name; + Ty ty; +}; + +dictionary EnumType { + string name; + u8 option; + sequence options; +}; + +dictionary FixedSizeArray { + sequence array; + u32 size; +}; + +[Enum] +interface Ty { + Primitive(Primitive value); + Struct(Struct value); + Enum(EnumType value); + Tuple(sequence values); + Array(sequence values); + FixedSizeArray(FixedSizeArray value); + ByteArray(string value); +}; + +[Enum] +interface ValueType { + String(string value); + Int(i64 value); + UInt(u64 value); + Bool(boolean value); + Bytes(sequence value); +}; + +// Query types - Complex enums for query building + +dictionary KeysClause { + sequence keys; + PatternMatching pattern_matching; + sequence models; +}; + +dictionary MemberClause { + string model; + string member; + ComparisonOperator operator; + MemberValue value; +}; + +dictionary CompositeClause { + LogicalOperator operator; + sequence clauses; +}; + +[Enum] +interface Clause { + HashedKeys(sequence keys); + Keys(KeysClause clause); + Member(MemberClause clause); + Composite(CompositeClause clause); +}; + +// Event and Message types +dictionary Event { + sequence keys; + sequence data; + FieldElement transaction_hash; +}; + +dictionary Message { + string message; + sequence signature; + FieldElement world_address; +}; + +// Entity, Model, and World types +dictionary Entity { + FieldElement world_address; + FieldElement hashed_keys; + sequence models; + u64 created_at; + u64 updated_at; + u64 executed_at; +}; + +dictionary Model { + FieldElement world_address; + Ty schema; + string namespace; + string name; + FieldElement selector; + u32 packed_size; + u32 unpacked_size; + FieldElement class_hash; + FieldElement contract_address; + string layout; + boolean use_legacy_store; +}; + +dictionary World { + FieldElement world_address; + sequence models; +}; + +// Error type +[Error] +enum DojoError { + "ClientError", + "SerializationError", + "NetworkError", + "InvalidInput", + "ConnectionError", + "PublishError", + "QueryError", + "SubscriptionError", +}; + +// Callback interfaces for subscriptions +callback interface EntityUpdateCallback { + void on_update(Entity entity); + void on_error(string error); +}; + +callback interface TokenBalanceUpdateCallback { + void on_update(TokenBalance balance); + void on_error(string error); +}; + +callback interface TokenUpdateCallback { + void on_update(Token token); + void on_error(string error); +}; + +callback interface TransactionUpdateCallback { + void on_update(Transaction transaction); + void on_error(string error); +}; + +callback interface EventUpdateCallback { + void on_update(Event event); + void on_error(string error); +}; + +// Pagination wrapper types for different result types +dictionary PageController { + sequence items; + string? next_cursor; +}; + +dictionary PageToken { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenBalance { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenContract { + sequence items; + string? next_cursor; +}; + +dictionary PageTokenTransfer { + sequence items; + string? next_cursor; +}; + +dictionary PageTransaction { + sequence items; + string? next_cursor; +}; + +dictionary PageAggregationEntry { + sequence items; + string? next_cursor; +}; + +dictionary PageActivity { + sequence items; + string? next_cursor; +}; + +dictionary PageAchievement { + sequence items; + string? next_cursor; +}; + +dictionary PagePlayerAchievement { + sequence items; + string? next_cursor; +}; + +dictionary PageEntity { + sequence items; + string? next_cursor; +}; + +dictionary PageEvent { + sequence items; + string? next_cursor; +}; + +// Main Dojo client interface +interface ToriiClient { + // Constructor - create a new client with default config (4MB max message size) + [Async, Throws=DojoError] + constructor(string torii_url); + + // Constructor - create a new client with custom max message size + [Async, Throws=DojoError, Name=new_with_config] + constructor(string torii_url, u64 max_message_size); + + // Publish offchain message + [Async, Throws=DojoError] + string publish_message(Message message); + + // Publish multiple offchain messages + [Async, Throws=DojoError] + sequence publish_message_batch(sequence messages); + + // Get world metadata + [Async, Throws=DojoError] + sequence worlds(sequence world_addresses); + + // Query controllers + [Async, Throws=DojoError] + PageController controllers(ControllerQuery query); + + // Query contracts + [Async, Throws=DojoError] + sequence contracts(ContractQuery query); + + // Query tokens + [Async, Throws=DojoError] + PageToken tokens(TokenQuery query); + + // Query token balances + [Async, Throws=DojoError] + PageTokenBalance token_balances(TokenBalanceQuery query); + + // Query token contracts + [Async, Throws=DojoError] + PageTokenContract token_contracts(TokenContractQuery query); + + // Query token transfers + [Async, Throws=DojoError] + PageTokenTransfer token_transfers(TokenTransferQuery query); + + // Query transactions + [Async, Throws=DojoError] + PageTransaction transactions(TransactionQuery query); + + // Query aggregations (leaderboards, stats, rankings) + [Async, Throws=DojoError] + PageAggregationEntry aggregations(AggregationQuery query); + + // Query activities (user session tracking) + [Async, Throws=DojoError] + PageActivity activities(ActivityQuery query); + + // Query achievements + [Async, Throws=DojoError] + PageAchievement achievements(AchievementQuery query); + + // Query player achievements + [Async, Throws=DojoError] + PagePlayerAchievement player_achievements(PlayerAchievementQuery query); + + // Query entities + [Async, Throws=DojoError] + PageEntity entities(Query query); + + // Query event messages + [Async, Throws=DojoError] + PageEntity event_messages(Query query); + + // Query Starknet events + [Async, Throws=DojoError] + PageEvent starknet_events(EventQuery query); + + // Execute SQL query + [Async, Throws=DojoError] + sequence sql(string query); + + // Subscription methods + // Subscribe to entity updates + [Async, Throws=DojoError] + u64 subscribe_entity_updates(Clause? clause, sequence world_addresses, EntityUpdateCallback callback); + + // Subscribe to token balance updates + [Async, Throws=DojoError] + u64 subscribe_token_balance_updates(sequence contract_addresses, sequence account_addresses, sequence token_ids, TokenBalanceUpdateCallback callback); + + // Subscribe to token updates + [Async, Throws=DojoError] + u64 subscribe_token_updates(sequence contract_addresses, sequence token_ids, TokenUpdateCallback callback); + + // Subscribe to transaction updates + [Async, Throws=DojoError] + u64 subscribe_transaction_updates(TransactionFilter? filter, TransactionUpdateCallback callback); + + // Subscribe to starknet event updates + [Async, Throws=DojoError] + u64 subscribe_event_updates(sequence keys, EventUpdateCallback callback); + + // Cancel a subscription + [Throws=DojoError] + void cancel_subscription(u64 subscription_id); +}; diff --git a/src/uniffi/README.md b/src/uniffi/README.md new file mode 100644 index 0000000..74dfd3d --- /dev/null +++ b/src/uniffi/README.md @@ -0,0 +1,93 @@ +# UniFFI Bindings + +This module provides foreign function interface (FFI) bindings for Dojo using Mozilla's [UniFFI](https://mozilla.github.io/uniffi-rs/) framework. + +## Structure + +``` +src/ +├── dojo.udl # UniFFI interface definition (required at crate root) +├── uniffi/ # UniFFI implementation +│ ├── mod.rs # Main module definition +│ ├── client.rs # ToriiClient implementation with subscription support +│ ├── types/ # Type definitions organized by domain +│ │ ├── mod.rs # Types module definition +│ │ ├── core.rs # Core types (FieldElement, U256, DojoError, Pagination) +│ │ ├── achievement.rs # Achievement and player achievement types +│ │ ├── activity.rs # Activity tracking types +│ │ ├── aggregation.rs # Aggregation (leaderboards, stats) types +│ │ ├── contract.rs # Contract query types +│ │ ├── controller.rs # Controller types +│ │ ├── entity.rs # Entity, Model, and World types +│ │ ├── event.rs # Event and event query types +│ │ ├── query.rs # Query types (Clause, KeysClause, etc.) +│ │ ├── schema.rs # Schema types (Ty, Struct, Enum, etc.) +│ │ ├── token.rs # Token and token-related types +│ │ └── transaction.rs # Transaction types and filters +│ └── README.md # This file +└── bin/ # Binding generator binaries + ├── uniffi-bindgen-swift.rs + ├── uniffi-bindgen-kotlin.rs + └── uniffi-bindgen-python.rs +``` + +**Note:** The `dojo.udl` file must be in `src/` (not `src/uniffi/`) because UniFFI requires it to be at the crate root level. + +## Supported Languages + +- **Swift** - iOS/macOS applications +- **Kotlin** - Android applications +- **Python** - Python applications and scripts + +## Generating Bindings + +Use the provided bindgen binaries: + +```bash +# Swift +cargo run --bin uniffi-bindgen-swift --release -- target/release/libdojo_c.dylib bindings/swift --swift-sources + +# Kotlin +cargo run --bin uniffi-bindgen-kotlin --release -- target/release/libdojo_c.dylib bindings/kotlin + +# Python +cargo run --bin uniffi-bindgen-python --release -- target/release/libdojo_c.dylib bindings/python +``` + +## Features + +### ToriiClient + +The main client interface provides: + +- **Queries**: entities, events, tokens, transactions, controllers, contracts, etc. +- **Subscriptions**: Real-time updates via callbacks +- **Message Publishing**: Submit offchain messages to the world +- **SQL Queries**: Direct database queries + +### Subscriptions + +Subscriptions use callbacks for real-time updates: + +- `subscribe_entity_updates` - Entity state changes +- `subscribe_token_balance_updates` - Token balance changes +- `subscribe_token_updates` - Token metadata updates +- `subscribe_transaction_updates` - Transaction updates +- `subscribe_event_updates` - Starknet event updates +- `cancel_subscription` - Cancel an active subscription + +### Type System + +All types are automatically converted between Rust and target languages: + +- **FieldElement**: Starknet field element (represented as hex string) +- **U256**: 256-bit unsigned integer (represented as hex string) +- **Enums**: Rust enums → Swift enums / Kotlin sealed classes / Python classes +- **Structs**: Rust structs → Swift structs / Kotlin data classes / Python dataclasses +- **Options**: `Option` → nullable types in target languages +- **Errors**: `DojoError` enum for all error cases + +## UDL Definition + +The interface is defined in `src/dojo.udl` using UniFFI Definition Language. + diff --git a/src/uniffi/client.rs b/src/uniffi/client.rs new file mode 100644 index 0000000..0f97cad --- /dev/null +++ b/src/uniffi/client.rs @@ -0,0 +1,537 @@ +// Client wrapper for UniFFI - exposes torii_client functionality + +use super::types::*; +use std::sync::{Arc, Mutex}; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::collections::HashMap; +use tokio::task::JoinHandle; + +// Callback traits for subscriptions +pub trait EntityUpdateCallback: Send + Sync { + fn on_update(&self, entity: Entity); + fn on_error(&self, error: String); +} + +pub trait TokenBalanceUpdateCallback: Send + Sync { + fn on_update(&self, balance: TokenBalance); + fn on_error(&self, error: String); +} + +pub trait TokenUpdateCallback: Send + Sync { + fn on_update(&self, token: Token); + fn on_error(&self, error: String); +} + +pub trait TransactionUpdateCallback: Send + Sync { + fn on_update(&self, transaction: Transaction); + fn on_error(&self, error: String); +} + +pub trait EventUpdateCallback: Send + Sync { + fn on_update(&self, event: Event); + fn on_error(&self, error: String); +} + +/// Main Dojo client for interacting with the Torii indexer +pub struct ToriiClient { + inner: Arc, + subscriptions: Arc>>>, + next_sub_id: Arc, +} + +impl ToriiClient { + /// Create a new Torii client with default configuration (4MB max message size) + pub async fn new(torii_url: String) -> Result { + let client = torii_client::Client::new(torii_url) + .await + .map_err(|_e| DojoError::ConnectionError)?; + + Ok(Self { + inner: Arc::new(client), + subscriptions: Arc::new(Mutex::new(HashMap::new())), + next_sub_id: Arc::new(AtomicU64::new(0)), + }) + } + + /// Create a new Torii client with custom max message size + pub async fn new_with_config( + torii_url: String, + max_message_size: u64, + ) -> Result { + let client = torii_client::Client::new_with_config(torii_url, max_message_size as usize) + .await + .map_err(|_e| DojoError::ConnectionError)?; + + Ok(Self { + inner: Arc::new(client), + subscriptions: Arc::new(Mutex::new(HashMap::new())), + next_sub_id: Arc::new(AtomicU64::new(0)), + }) + } + + /// Publish an offchain message to the world + /// Returns the entity ID of the published message + pub async fn publish_message(&self, message: Message) -> Result { + let msg: torii_proto::Message = message.into(); + self.inner + .publish_message(msg) + .await + .map_err(|_| DojoError::PublishError) + } + + /// Publish multiple offchain messages to the world + /// Returns the entity IDs of the published messages + pub async fn publish_message_batch(&self, messages: Vec) -> Result, DojoError> { + let msgs: Vec = messages + .into_iter() + .map(|m| m.into()) + .collect(); + self.inner + .publish_message_batch(msgs) + .await + .map_err(|_| DojoError::PublishError) + } + + /// Get world metadata for specified world addresses + pub async fn worlds(&self, world_addresses: Vec) -> Result, DojoError> { + let addrs: Result, DojoError> = world_addresses + .iter() + .map(field_element_to_felt) + .collect(); + let addrs = addrs?; + + let worlds = self.inner + .worlds(addrs) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(worlds.into_iter().map(|w| w.into()).collect()) + } + + /// Retrieve controllers matching the query + pub async fn controllers(&self, query: ControllerQuery) -> Result { + let q: torii_proto::ControllerQuery = query.into(); + let page = self.inner + .controllers(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageController { + items: page.items.into_iter().map(|c| c.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve contracts matching the query + pub async fn contracts(&self, query: ContractQuery) -> Result, DojoError> { + let q: torii_proto::ContractQuery = query.into(); + let contracts = self.inner + .contracts(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(contracts.into_iter().map(|c| c.into()).collect()) + } + + /// Retrieve tokens matching the query + pub async fn tokens(&self, query: TokenQuery) -> Result { + let q: torii_proto::TokenQuery = query.into(); + let page = self.inner + .tokens(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageToken { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token balances + pub async fn token_balances(&self, query: TokenBalanceQuery) -> Result { + let q: torii_proto::TokenBalanceQuery = query.into(); + let page = self.inner + .token_balances(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageTokenBalance { + items: page.items.into_iter().map(|b| b.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token contracts + pub async fn token_contracts(&self, query: TokenContractQuery) -> Result { + let q: torii_proto::TokenContractQuery = query.into(); + let page = self.inner + .token_contracts(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageTokenContract { + items: page.items.into_iter().map(|tc| tc.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve token transfers + pub async fn token_transfers(&self, query: TokenTransferQuery) -> Result { + let q: torii_proto::TokenTransferQuery = query.into(); + let page = self.inner + .token_transfers(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageTokenTransfer { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve transactions + pub async fn transactions(&self, query: TransactionQuery) -> Result { + let q: torii_proto::TransactionQuery = query.into(); + let page = self.inner + .transactions(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageTransaction { + items: page.items.into_iter().map(|t| t.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve aggregations (leaderboards, stats, rankings) + pub async fn aggregations(&self, query: AggregationQuery) -> Result { + let q: torii_proto::AggregationQuery = query.into(); + let page = self.inner + .aggregations(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageAggregationEntry { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve activities (user session tracking) + pub async fn activities(&self, query: ActivityQuery) -> Result { + let q: torii_proto::ActivityQuery = query.into(); + let page = self.inner + .activities(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageActivity { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve achievements + pub async fn achievements(&self, query: AchievementQuery) -> Result { + let q: torii_proto::AchievementQuery = query.into(); + let page = self.inner + .achievements(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageAchievement { + items: page.items.into_iter().map(|a| a.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve player achievements + pub async fn player_achievements(&self, query: PlayerAchievementQuery) -> Result { + let q: torii_proto::PlayerAchievementQuery = query.into(); + let page = self.inner + .player_achievements(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PagePlayerAchievement { + items: page.items.into_iter().map(|p| p.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve entities matching the query + pub async fn entities(&self, query: Query) -> Result { + let q: torii_proto::Query = query.into(); + let page = self.inner + .entities(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageEntity { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve event messages matching the query + pub async fn event_messages(&self, query: Query) -> Result { + let q: torii_proto::Query = query.into(); + let page = self.inner + .event_messages(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageEntity { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Retrieve raw Starknet events + pub async fn starknet_events(&self, query: EventQuery) -> Result { + let q: torii_proto::EventQuery = query.try_into()?; + let page = self.inner + .starknet_events(q) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + Ok(PageEvent { + items: page.items.into_iter().map(|e| e.into()).collect(), + next_cursor: page.next_cursor, + }) + } + + /// Execute a SQL query against the Torii database + pub async fn sql(&self, query: String) -> Result, DojoError> { + let rows = self.inner + .sql(query) + .await + .map_err(|e| DojoError::QueryError(e.to_string()))?; + + rows.into_iter().map(|r| r.try_into()).collect() + } + + /// Subscribe to entity updates + pub async fn subscribe_entity_updates( + &self, + clause: Option, + world_addresses: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let addrs: Result, DojoError> = world_addresses + .iter() + .map(field_element_to_felt) + .collect(); + let addrs = addrs?; + + let clause_proto = clause.map(|c| c.into()); + + let mut stream = self.inner + .on_entity_updated(clause_proto, addrs) + .await + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = tokio::spawn(async move { + use futures_util::StreamExt; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, entity)) => { + callback.on_update(entity.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to token balance updates + pub async fn subscribe_token_balance_updates( + &self, + contract_addresses: Vec, + account_addresses: Vec, + token_ids: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let contracts: Result, DojoError> = contract_addresses + .iter() + .map(field_element_to_felt) + .collect(); + let accounts: Result, DojoError> = account_addresses + .iter() + .map(field_element_to_felt) + .collect(); + let ids: Result, DojoError> = token_ids + .iter() + .map(uniffi_to_u256) + .collect(); + + let mut stream = self.inner + .on_token_balance_updated(contracts?, accounts?, ids?) + .await + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = tokio::spawn(async move { + use futures_util::StreamExt; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, balance)) => { + callback.on_update(balance.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to token updates + pub async fn subscribe_token_updates( + &self, + contract_addresses: Vec, + token_ids: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let contracts: Result, DojoError> = contract_addresses + .iter() + .map(field_element_to_felt) + .collect(); + let ids: Result, DojoError> = token_ids + .iter() + .map(uniffi_to_u256) + .collect(); + + let mut stream = self.inner + .on_token_updated(contracts?, ids?) + .await + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = tokio::spawn(async move { + use futures_util::StreamExt; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok((_id, token)) => { + callback.on_update(token.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to transaction updates + pub async fn subscribe_transaction_updates( + &self, + filter: Option, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let filter_proto = filter.map(|f| f.into()); + + let mut stream = self.inner + .on_transaction(filter_proto) + .await + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = tokio::spawn(async move { + use futures_util::StreamExt; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok(transaction) => { + callback.on_update(transaction.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Subscribe to Starknet event updates + pub async fn subscribe_event_updates( + &self, + keys: Vec, + callback: Box, + ) -> Result { + let sub_id = self.next_sub_id.fetch_add(1, Ordering::SeqCst); + + let keys_proto: Vec = keys.into_iter().map(|k| k.into()).collect(); + + let mut stream = self.inner + .on_starknet_event(keys_proto) + .await + .map_err(|_| DojoError::SubscriptionError)?; + + let handle = tokio::spawn(async move { + use futures_util::StreamExt; + // Skip the first message which contains the subscription ID + let _ = stream.next().await; + + while let Some(result) = stream.next().await { + match result { + Ok(event) => { + callback.on_update(event.into()); + } + Err(e) => { + callback.on_error(e.to_string()); + break; + } + } + } + }); + + self.subscriptions.lock().unwrap().insert(sub_id, handle); + Ok(sub_id) + } + + /// Cancel a subscription + pub fn cancel_subscription(&self, subscription_id: u64) -> Result<(), DojoError> { + let mut subs = self.subscriptions.lock().unwrap(); + if let Some(handle) = subs.remove(&subscription_id) { + handle.abort(); + Ok(()) + } else { + Err(DojoError::SubscriptionError) + } + } +} diff --git a/src/uniffi/mod.rs b/src/uniffi/mod.rs new file mode 100644 index 0000000..c422a6d --- /dev/null +++ b/src/uniffi/mod.rs @@ -0,0 +1,14 @@ +// UniFFI bindings for Dojo +// +// This module provides foreign function interface bindings for multiple languages +// (Swift, Kotlin, Python) using Mozilla's UniFFI framework. + +// Type definitions organized by domain +pub mod types; + +// Client implementation +pub mod client; + +// Re-export everything for convenience +pub use client::*; +pub use types::*; diff --git a/src/uniffi/types/achievement.rs b/src/uniffi/types/achievement.rs new file mode 100644 index 0000000..ae67098 --- /dev/null +++ b/src/uniffi/types/achievement.rs @@ -0,0 +1,239 @@ +// Achievement types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct AchievementTask { + pub task_id: String, + pub description: String, + pub total: u32, + pub total_completions: u32, + pub completion_rate: f64, + pub created_at: u64, +} + +impl From for AchievementTask { + fn from(val: torii_proto::AchievementTask) -> Self { + AchievementTask { + task_id: val.task_id, + description: val.description, + total: val.total, + total_completions: val.total_completions, + completion_rate: val.completion_rate, + created_at: val.created_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct Achievement { + pub id: String, + pub world_address: FieldElement, + pub namespace: String, + pub entity_id: String, + pub hidden: bool, + pub index: u32, + pub points: u32, + pub start: String, + pub end: String, + pub group: String, + pub icon: String, + pub title: String, + pub description: String, + pub tasks: Vec, + pub data: Option, + pub total_completions: u32, + pub completion_rate: f64, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for Achievement { + fn from(val: torii_proto::Achievement) -> Self { + let tasks: Vec = val.tasks.into_iter().map(|t| t.into()).collect(); + + Achievement { + id: val.id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + entity_id: val.entity_id, + hidden: val.hidden, + index: val.index, + points: val.points, + start: val.start, + end: val.end, + group: val.group, + icon: val.icon, + title: val.title, + description: val.description, + tasks, + data: val.data, + total_completions: val.total_completions, + completion_rate: val.completion_rate, + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct AchievementQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub hidden: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::AchievementQuery { + fn from(val: AchievementQuery) -> Self { + torii_proto::AchievementQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + hidden: val.hidden, + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TaskProgress { + pub task_id: String, + pub count: u32, + pub completed: bool, +} + +impl From for TaskProgress { + fn from(val: torii_proto::TaskProgress) -> Self { + TaskProgress { task_id: val.task_id, count: val.count, completed: val.completed } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementProgress { + pub achievement: Achievement, + pub task_progress: Vec, + pub completed: bool, + pub progress_percentage: f64, +} + +impl From for PlayerAchievementProgress { + fn from(val: torii_proto::PlayerAchievementProgress) -> Self { + let task_progress: Vec = val.task_progress.into_iter().map(|t| t.into()).collect(); + + PlayerAchievementProgress { + achievement: val.achievement.into(), + task_progress, + completed: val.completed, + progress_percentage: val.progress_percentage, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementStats { + pub total_points: u32, + pub completed_achievements: u32, + pub total_achievements: u32, + pub completion_percentage: f64, + pub last_achievement_at: Option, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for PlayerAchievementStats { + fn from(val: torii_proto::PlayerAchievementStats) -> Self { + PlayerAchievementStats { + total_points: val.total_points, + completed_achievements: val.completed_achievements, + total_achievements: val.total_achievements, + completion_percentage: val.completion_percentage, + last_achievement_at: val.last_achievement_at.map(|t| t.timestamp() as u64), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementEntry { + pub player_address: FieldElement, + pub stats: PlayerAchievementStats, + pub achievements: Vec, +} + +impl From for PlayerAchievementEntry { + fn from(val: torii_proto::PlayerAchievementEntry) -> Self { + let achievements: Vec = + val.achievements.into_iter().map(|a| a.into()).collect(); + + PlayerAchievementEntry { + player_address: felt_to_field_element(val.player_address), + stats: val.stats.into(), + achievements, + } + } +} + +#[derive(Debug, Clone)] +pub struct PlayerAchievementQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub player_addresses: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::PlayerAchievementQuery { + fn from(val: PlayerAchievementQuery) -> Self { + torii_proto::PlayerAchievementQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + player_addresses: val + .player_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct AchievementProgression { + pub id: String, + pub achievement_id: String, + pub task_id: String, + pub world_address: FieldElement, + pub namespace: String, + pub player_id: FieldElement, + pub count: u32, + pub completed: bool, + pub completed_at: Option, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for AchievementProgression { + fn from(val: torii_proto::AchievementProgression) -> Self { + AchievementProgression { + id: val.id, + achievement_id: val.achievement_id, + task_id: val.task_id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + player_id: felt_to_field_element(val.player_id), + count: val.count, + completed: val.completed, + completed_at: val.completed_at.map(|t| t.timestamp() as u64), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + diff --git a/src/uniffi/types/activity.rs b/src/uniffi/types/activity.rs new file mode 100644 index 0000000..29c37e3 --- /dev/null +++ b/src/uniffi/types/activity.rs @@ -0,0 +1,76 @@ +// Activity types +use super::core::*; +use chrono::DateTime; + +#[derive(Debug, Clone)] +pub struct ActionCount { + pub action_name: String, + pub count: u32, +} + +#[derive(Debug, Clone)] +pub struct Activity { + pub id: String, + pub world_address: FieldElement, + pub namespace: String, + pub caller_address: FieldElement, + pub session_start: u64, + pub session_end: u64, + pub action_count: u32, + pub actions: Vec, + pub updated_at: u64, +} + +impl From for Activity { + fn from(val: torii_proto::Activity) -> Self { + let actions: Vec = val + .actions + .into_iter() + .map(|(name, count)| ActionCount { action_name: name, count }) + .collect(); + + Activity { + id: val.id, + world_address: felt_to_field_element(val.world_address), + namespace: val.namespace, + caller_address: felt_to_field_element(val.caller_address), + session_start: val.session_start.timestamp() as u64, + session_end: val.session_end.timestamp() as u64, + action_count: val.action_count, + actions, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct ActivityQuery { + pub world_addresses: Vec, + pub namespaces: Vec, + pub caller_addresses: Vec, + pub from_time: Option, + pub to_time: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::ActivityQuery { + fn from(val: ActivityQuery) -> Self { + torii_proto::ActivityQuery { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + namespaces: val.namespaces, + caller_addresses: val + .caller_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + from_time: val.from_time.map(|t| DateTime::from_timestamp(t as i64, 0).unwrap()), + to_time: val.to_time.map(|t| DateTime::from_timestamp(t as i64, 0).unwrap()), + pagination: val.pagination.into(), + } + } +} + diff --git a/src/uniffi/types/aggregation.rs b/src/uniffi/types/aggregation.rs new file mode 100644 index 0000000..1d964bb --- /dev/null +++ b/src/uniffi/types/aggregation.rs @@ -0,0 +1,49 @@ +// Aggregation types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct AggregationQuery { + pub aggregator_ids: Vec, + pub entity_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::AggregationQuery { + fn from(val: AggregationQuery) -> Self { + torii_proto::AggregationQuery { + aggregator_ids: val.aggregator_ids, + entity_ids: val.entity_ids, + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct AggregationEntry { + pub id: String, + pub aggregator_id: String, + pub entity_id: String, + pub value: U256, + pub display_value: String, + pub position: u64, + pub model_id: String, + pub created_at: u64, + pub updated_at: u64, +} + +impl From for AggregationEntry { + fn from(val: torii_proto::AggregationEntry) -> Self { + AggregationEntry { + id: val.id, + aggregator_id: val.aggregator_id, + entity_id: val.entity_id, + value: u256_to_uniffi(val.value), + display_value: val.display_value, + position: val.position, + model_id: val.model_id, + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + } + } +} + diff --git a/src/uniffi/types/contract.rs b/src/uniffi/types/contract.rs new file mode 100644 index 0000000..4f88575 --- /dev/null +++ b/src/uniffi/types/contract.rs @@ -0,0 +1,85 @@ +// Contract types +use super::core::*; + +#[derive(Debug, Clone)] +pub enum ContractType { + WORLD, + ERC20, + ERC721, + ERC1155, + UDC, + OTHER, +} + +impl From for ContractType { + fn from(val: torii_proto::ContractType) -> Self { + match val { + torii_proto::ContractType::WORLD => ContractType::WORLD, + torii_proto::ContractType::ERC20 => ContractType::ERC20, + torii_proto::ContractType::ERC721 => ContractType::ERC721, + torii_proto::ContractType::ERC1155 => ContractType::ERC1155, + torii_proto::ContractType::UDC => ContractType::UDC, + torii_proto::ContractType::OTHER => ContractType::OTHER, + } + } +} + +impl From for torii_proto::ContractType { + fn from(val: ContractType) -> Self { + match val { + ContractType::WORLD => torii_proto::ContractType::WORLD, + ContractType::ERC20 => torii_proto::ContractType::ERC20, + ContractType::ERC721 => torii_proto::ContractType::ERC721, + ContractType::ERC1155 => torii_proto::ContractType::ERC1155, + ContractType::UDC => torii_proto::ContractType::UDC, + ContractType::OTHER => torii_proto::ContractType::OTHER, + } + } +} + +#[derive(Debug, Clone)] +pub struct Contract { + pub contract_address: FieldElement, + pub contract_type: ContractType, + pub head: Option, + pub tps: Option, + pub last_block_timestamp: Option, + pub last_pending_block_tx: Option, + pub updated_at: u64, + pub created_at: u64, +} + +impl From for Contract { + fn from(val: torii_proto::Contract) -> Self { + Contract { + contract_type: val.contract_type.into(), + head: val.head, + tps: val.tps, + last_block_timestamp: val.last_block_timestamp, + last_pending_block_tx: val.last_pending_block_tx.map(felt_to_field_element), + updated_at: val.updated_at.timestamp() as u64, + created_at: val.created_at.timestamp() as u64, + contract_address: felt_to_field_element(val.contract_address), + } + } +} + +#[derive(Debug, Clone)] +pub struct ContractQuery { + pub contract_addresses: Vec, + pub contract_types: Vec, +} + +impl From for torii_proto::ContractQuery { + fn from(val: ContractQuery) -> Self { + torii_proto::ContractQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_types: val.contract_types.into_iter().map(|t| t.into()).collect(), + } + } +} + diff --git a/src/uniffi/types/controller.rs b/src/uniffi/types/controller.rs new file mode 100644 index 0000000..6951fce --- /dev/null +++ b/src/uniffi/types/controller.rs @@ -0,0 +1,41 @@ +// Controller types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct Controller { + pub address: FieldElement, + pub username: String, + pub deployed_at_timestamp: u64, +} + +impl From for Controller { + fn from(val: torii_proto::Controller) -> Self { + Controller { + address: felt_to_field_element(val.address), + username: val.username, + deployed_at_timestamp: val.deployed_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct ControllerQuery { + pub pagination: Pagination, + pub contract_addresses: Vec, + pub usernames: Vec, +} + +impl From for torii_proto::ControllerQuery { + fn from(val: ControllerQuery) -> Self { + torii_proto::ControllerQuery { + pagination: val.pagination.into(), + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + usernames: val.usernames, + } + } +} + diff --git a/src/uniffi/types/core.rs b/src/uniffi/types/core.rs new file mode 100644 index 0000000..6be9a51 --- /dev/null +++ b/src/uniffi/types/core.rs @@ -0,0 +1,329 @@ +// Core types - FieldElement, U256, Error, Pagination, Signature, Call, BlockId + +// Newtype wrappers for custom type conversions +// These will be represented as strings in the UDL via [Custom] attribute + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FieldElement(pub String); + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct U256(pub String); + +// Custom type implementations for UniFFI +// These newtype wrappers will be represented as their inner type (String) in foreign languages +uniffi::custom_newtype!(FieldElement, String); +uniffi::custom_newtype!(U256, String); + +// Helper functions to convert between internal types and UniFFI types +pub fn felt_to_field_element(felt: starknet::core::types::Felt) -> FieldElement { + FieldElement(format!("0x{:064x}", felt)) +} + +pub fn field_element_to_felt(fe: &FieldElement) -> Result { + starknet::core::types::Felt::from_hex(&fe.0).map_err(|_| DojoError::InvalidInput) +} + +pub fn u256_to_uniffi(u: crypto_bigint::U256) -> U256 { + U256(format!("0x{:064x}", u)) +} + +pub fn uniffi_to_u256(u: &U256) -> Result { + let s = u.0.strip_prefix("0x").unwrap_or(&u.0); + let bytes = hex::decode(s).map_err(|_| DojoError::InvalidInput)?; + Ok(crypto_bigint::U256::from_be_slice(&bytes)) +} + +// Error types +#[derive(Debug, thiserror::Error)] +pub enum DojoError { + #[error("Client error: {0}")] + ClientError(String), + #[error("Serialization error: {0}")] + SerializationError(String), + #[error("Network error: {0}")] + NetworkError(String), + #[error("Invalid input")] + InvalidInput, + #[error("Connection error")] + ConnectionError, + #[error("Publish error")] + PublishError, + #[error("Query error: {0}")] + QueryError(String), + #[error("Subscription error")] + SubscriptionError, +} + +impl From for DojoError { + fn from(e: anyhow::Error) -> Self { + DojoError::ClientError(e.to_string()) + } +} + +// Pagination +#[derive(Debug, Clone)] +pub enum PaginationDirection { + Forward, + Backward, +} + +impl From for torii_proto::PaginationDirection { + fn from(val: PaginationDirection) -> Self { + match val { + PaginationDirection::Forward => torii_proto::PaginationDirection::Forward, + PaginationDirection::Backward => torii_proto::PaginationDirection::Backward, + } + } +} + +impl From for PaginationDirection { + fn from(val: torii_proto::PaginationDirection) -> Self { + match val { + torii_proto::PaginationDirection::Forward => PaginationDirection::Forward, + torii_proto::PaginationDirection::Backward => PaginationDirection::Backward, + } + } +} + +#[derive(Debug, Clone)] +pub enum OrderDirection { + Asc, + Desc, +} + +impl From for torii_proto::OrderDirection { + fn from(val: OrderDirection) -> Self { + match val { + OrderDirection::Asc => torii_proto::OrderDirection::Asc, + OrderDirection::Desc => torii_proto::OrderDirection::Desc, + } + } +} + +impl From for OrderDirection { + fn from(val: torii_proto::OrderDirection) -> Self { + match val { + torii_proto::OrderDirection::Asc => OrderDirection::Asc, + torii_proto::OrderDirection::Desc => OrderDirection::Desc, + } + } +} + +#[derive(Debug, Clone)] +pub struct OrderBy { + pub field: String, + pub direction: OrderDirection, +} + +impl From for torii_proto::OrderBy { + fn from(val: OrderBy) -> Self { + torii_proto::OrderBy { field: val.field, direction: val.direction.into() } + } +} + +impl From for OrderBy { + fn from(val: torii_proto::OrderBy) -> Self { + OrderBy { field: val.field, direction: val.direction.into() } + } +} + +#[derive(Debug, Clone)] +pub struct Pagination { + pub cursor: Option, + pub limit: Option, + pub direction: PaginationDirection, + pub order_by: Vec, +} + +impl From for torii_proto::Pagination { + fn from(val: Pagination) -> Self { + torii_proto::Pagination { + cursor: val.cursor, + limit: val.limit, + direction: val.direction.into(), + order_by: val.order_by.into_iter().map(|o| o.into()).collect(), + } + } +} + +impl From for Pagination { + fn from(val: torii_proto::Pagination) -> Self { + Pagination { + cursor: val.cursor, + limit: val.limit, + direction: val.direction.into(), + order_by: val.order_by.into_iter().map(|o| o.into()).collect(), + } + } +} + +// Note: Page is not included in UniFFI as it doesn't support generics. +// If you need paginated results, use the specific query methods that return +// collections directly (e.g., Vec, Vec, etc.) + +// Signature +#[derive(Debug, Clone)] +pub struct Signature { + pub r: FieldElement, + pub s: FieldElement, +} + +impl From for starknet::core::crypto::Signature { + fn from(val: Signature) -> Self { + Self { + r: field_element_to_felt(&val.r).unwrap(), + s: field_element_to_felt(&val.s).unwrap(), + } + } +} + +impl From for Signature { + fn from(val: starknet::core::crypto::Signature) -> Self { + Signature { r: felt_to_field_element(val.r), s: felt_to_field_element(val.s) } + } +} + +// Call +#[derive(Debug, Clone)] +pub struct Call { + pub to: FieldElement, + pub selector: String, + pub calldata: Vec, +} + +impl From for starknet::core::types::Call { + fn from(val: Call) -> Self { + starknet::core::types::Call { + to: field_element_to_felt(&val.to).unwrap(), + selector: starknet::core::utils::get_selector_from_name(&val.selector).unwrap(), + calldata: val.calldata.into_iter().map(|f| field_element_to_felt(&f).unwrap()).collect(), + } + } +} + +impl From for starknet::core::types::FunctionCall { + fn from(val: Call) -> Self { + starknet::core::types::FunctionCall { + contract_address: field_element_to_felt(&val.to).unwrap(), + entry_point_selector: starknet::core::utils::get_selector_from_name(&val.selector).unwrap(), + calldata: val.calldata.into_iter().map(|f| field_element_to_felt(&f).unwrap()).collect(), + } + } +} + +// BlockId and BlockTag +#[derive(Debug, Clone)] +pub enum BlockTag { + Latest, + PreConfirmed, +} + +impl From for starknet::core::types::BlockTag { + fn from(val: BlockTag) -> Self { + match val { + BlockTag::Latest => starknet::core::types::BlockTag::Latest, + BlockTag::PreConfirmed => starknet::core::types::BlockTag::PreConfirmed, + } + } +} + +#[derive(Debug, Clone)] +pub enum BlockId { + Hash(FieldElement), + Number(u64), + Tag(BlockTag), +} + +impl From for starknet::core::types::BlockId { + fn from(val: BlockId) -> Self { + match val { + BlockId::Hash(hash) => starknet::core::types::BlockId::Hash(field_element_to_felt(&hash).unwrap()), + BlockId::Number(number) => starknet::core::types::BlockId::Number(number), + BlockId::Tag(tag) => starknet::core::types::BlockId::Tag(tag.into()), + } + } +} + +// Pagination wrapper types for different result types +// These are used by the client but defined here for availability + +use super::controller::Controller; +use super::token::{Token, TokenBalance, TokenContract, TokenTransfer}; +use super::transaction::Transaction; +use super::aggregation::AggregationEntry; +use super::activity::Activity; +use super::achievement::{Achievement, PlayerAchievementEntry}; +use super::entity::Entity; +use super::event::Event; + +#[derive(Debug, Clone)] +pub struct PageController { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageToken { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenBalance { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenContract { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTokenTransfer { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageTransaction { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageAggregationEntry { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageActivity { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageAchievement { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PagePlayerAchievement { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageEntity { + pub items: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Clone)] +pub struct PageEvent { + pub items: Vec, + pub next_cursor: Option, +} diff --git a/src/uniffi/types/entity.rs b/src/uniffi/types/entity.rs new file mode 100644 index 0000000..5e7c7cb --- /dev/null +++ b/src/uniffi/types/entity.rs @@ -0,0 +1,130 @@ +// Entity, Model, and World types +use super::core::*; +use super::schema::{Struct, Ty}; +use chrono::DateTime; + +#[derive(Debug, Clone)] +pub struct Entity { + pub world_address: FieldElement, + pub hashed_keys: FieldElement, + pub models: Vec, + pub created_at: u64, + pub updated_at: u64, + pub executed_at: u64, +} + +impl From for torii_proto::schema::Entity { + fn from(val: Entity) -> Self { + torii_proto::schema::Entity { + world_address: field_element_to_felt(&val.world_address).unwrap(), + hashed_keys: field_element_to_felt(&val.hashed_keys).unwrap(), + models: val.models.into_iter().map(|m| m.into()).collect(), + created_at: DateTime::from_timestamp(val.created_at as i64, 0).unwrap(), + updated_at: DateTime::from_timestamp(val.updated_at as i64, 0).unwrap(), + executed_at: DateTime::from_timestamp(val.executed_at as i64, 0).unwrap(), + } + } +} + +impl From for Entity { + fn from(val: torii_proto::schema::Entity) -> Self { + Entity { + world_address: felt_to_field_element(val.world_address), + hashed_keys: felt_to_field_element(val.hashed_keys), + models: val.models.into_iter().map(|m| m.into()).collect(), + created_at: val.created_at.timestamp() as u64, + updated_at: val.updated_at.timestamp() as u64, + executed_at: val.executed_at.timestamp() as u64, + } + } +} + +#[derive(Debug, Clone)] +pub struct Model { + pub world_address: FieldElement, + pub schema: Ty, + pub namespace: String, + pub name: String, + pub selector: FieldElement, + pub packed_size: u32, + pub unpacked_size: u32, + pub class_hash: FieldElement, + pub contract_address: FieldElement, + pub layout: String, + pub use_legacy_store: bool, +} + +impl From for Model { + fn from(value: torii_proto::Model) -> Self { + let layout = serde_json::to_string(&value.layout).unwrap(); + + Model { + world_address: felt_to_field_element(value.world_address), + schema: value.schema.into(), + name: value.name, + namespace: value.namespace, + selector: felt_to_field_element(value.selector), + packed_size: value.packed_size, + unpacked_size: value.unpacked_size, + class_hash: felt_to_field_element(value.class_hash), + contract_address: felt_to_field_element(value.contract_address), + layout, + use_legacy_store: value.use_legacy_store, + } + } +} + +impl From for torii_proto::Model { + fn from(value: Model) -> Self { + let layout = serde_json::from_str(&value.layout).unwrap(); + + torii_proto::Model { + world_address: field_element_to_felt(&value.world_address).unwrap(), + schema: value.schema.into(), + namespace: value.namespace, + name: value.name, + selector: field_element_to_felt(&value.selector).unwrap(), + packed_size: value.packed_size, + unpacked_size: value.unpacked_size, + class_hash: field_element_to_felt(&value.class_hash).unwrap(), + contract_address: field_element_to_felt(&value.contract_address).unwrap(), + layout, + use_legacy_store: value.use_legacy_store, + } + } +} + +#[derive(Debug, Clone)] +pub struct World { + pub world_address: FieldElement, + pub models: Vec, +} + +impl From for World { + fn from(value: torii_proto::World) -> Self { + let models: Vec = value.models.into_values().map(|v| v.into()).collect(); + + World { world_address: felt_to_field_element(value.world_address), models } + } +} + +impl From for torii_proto::World { + fn from(value: World) -> Self { + let models: Vec = value.models.into_iter().map(|m| m.into()).collect(); + let models = models + .into_iter() + .map(|m| { + ( + dojo_types::naming::compute_selector_from_names(&m.namespace, &m.name), + m, + ) + }) + .collect(); + + torii_proto::World { + world_address: field_element_to_felt(&value.world_address).unwrap(), + models, + } + } +} + diff --git a/src/uniffi/types/event.rs b/src/uniffi/types/event.rs new file mode 100644 index 0000000..96a91f3 --- /dev/null +++ b/src/uniffi/types/event.rs @@ -0,0 +1,65 @@ +// Event and Message types +use super::core::*; +use super::query::*; + +#[derive(Debug, Clone)] +pub struct Event { + pub keys: Vec, + pub data: Vec, + pub transaction_hash: FieldElement, +} + +#[derive(Debug, Clone)] +pub struct EventQuery { + pub keys: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::Event { + fn from(val: Event) -> Self { + torii_proto::Event { + keys: val.keys.into_iter().map(|k| field_element_to_felt(&k).unwrap()).collect(), + data: val.data.into_iter().map(|d| field_element_to_felt(&d).unwrap()).collect(), + transaction_hash: field_element_to_felt(&val.transaction_hash).unwrap(), + } + } +} + +impl From for Event { + fn from(val: torii_proto::Event) -> Self { + Event { + keys: val.keys.into_iter().map(felt_to_field_element).collect(), + data: val.data.into_iter().map(felt_to_field_element).collect(), + transaction_hash: felt_to_field_element(val.transaction_hash), + } + } +} + +#[derive(Debug, Clone)] +pub struct Message { + pub message: String, + pub signature: Vec, + pub world_address: FieldElement, +} + +impl From for torii_proto::Message { + fn from(val: Message) -> Self { + torii_proto::Message { + message: val.message, + signature: val.signature.into_iter().map(|s| field_element_to_felt(&s).unwrap()).collect(), + world_address: field_element_to_felt(&val.world_address).unwrap(), + } + } +} + +impl TryInto for EventQuery { + type Error = DojoError; + + fn try_into(self) -> Result { + Ok(torii_proto::EventQuery { + keys: self.keys.map(|k| k.into()), + pagination: self.pagination.into(), + }) + } +} + diff --git a/src/uniffi/types/mod.rs b/src/uniffi/types/mod.rs new file mode 100644 index 0000000..4b669d8 --- /dev/null +++ b/src/uniffi/types/mod.rs @@ -0,0 +1,30 @@ +// Core types and error handling +pub mod core; + +// Domain types organized by category +pub mod achievement; +pub mod activity; +pub mod aggregation; +pub mod contract; +pub mod controller; +pub mod entity; +pub mod event; +pub mod query; +pub mod schema; +pub mod token; +pub mod transaction; + +// Re-export all public types for convenience +pub use achievement::*; +pub use activity::*; +pub use aggregation::*; +pub use contract::*; +pub use controller::*; +pub use core::*; +pub use entity::*; +pub use event::*; +pub use query::*; +pub use schema::*; +pub use token::*; +pub use transaction::*; + diff --git a/src/uniffi/types/query.rs b/src/uniffi/types/query.rs new file mode 100644 index 0000000..30a5512 --- /dev/null +++ b/src/uniffi/types/query.rs @@ -0,0 +1,310 @@ +// Query types - Query, Clause, KeysClause, MemberClause, CompositeClause +use super::core::*; +use super::schema::MemberValue; + +// SQL query result types +#[derive(Debug, Clone)] +pub struct SqlField { + pub name: String, + pub value: SqlValue, +} + +#[derive(Debug, Clone)] +pub struct SqlRow { + pub fields: Vec, +} + +#[derive(Debug, Clone)] +pub enum SqlValue { + Text { value: String }, + Integer { value: i64 }, + Real { value: f64 }, + Blob { value: Vec }, + Null, +} + +impl TryInto for torii_proto::SqlRow { + type Error = DojoError; + + fn try_into(self) -> Result { + let fields = self.fields.into_iter().map(|(name, v)| { + let value = match v { + torii_proto::SqlValue::Text(s) => SqlValue::Text { value: s }, + torii_proto::SqlValue::Integer(i) => SqlValue::Integer { value: i }, + torii_proto::SqlValue::Real(r) => SqlValue::Real { value: r }, + torii_proto::SqlValue::Blob(b) => SqlValue::Blob { value: b }, + torii_proto::SqlValue::Null => SqlValue::Null, + }; + SqlField { name, value } + }).collect(); + Ok(SqlRow { fields }) + } +} + +#[derive(Debug, Clone)] +pub enum PatternMatching { + FixedLen, + VariableLen, +} + +impl From for torii_proto::PatternMatching { + fn from(val: PatternMatching) -> Self { + match val { + PatternMatching::FixedLen => torii_proto::PatternMatching::FixedLen, + PatternMatching::VariableLen => torii_proto::PatternMatching::VariableLen, + } + } +} + +impl From for PatternMatching { + fn from(val: torii_proto::PatternMatching) -> Self { + match val { + torii_proto::PatternMatching::FixedLen => PatternMatching::FixedLen, + torii_proto::PatternMatching::VariableLen => PatternMatching::VariableLen, + } + } +} + +#[derive(Debug, Clone)] +pub struct KeysClause { + pub keys: Vec>, + pub pattern_matching: PatternMatching, + pub models: Vec, +} + +impl From for torii_proto::KeysClause { + fn from(val: KeysClause) -> Self { + torii_proto::KeysClause { + keys: val + .keys + .into_iter() + .map(|k| k.map(|s| field_element_to_felt(&s).unwrap())) + .collect(), + pattern_matching: val.pattern_matching.into(), + models: val.models, + } + } +} + +impl From for KeysClause { + fn from(val: torii_proto::KeysClause) -> Self { + KeysClause { + models: val.models, + keys: val.keys.into_iter().map(|k| k.map(felt_to_field_element)).collect(), + pattern_matching: val.pattern_matching.into(), + } + } +} + +#[derive(Debug, Clone)] +pub enum LogicalOperator { + And, + Or, +} + +impl From for torii_proto::LogicalOperator { + fn from(val: LogicalOperator) -> Self { + match val { + LogicalOperator::And => torii_proto::LogicalOperator::And, + LogicalOperator::Or => torii_proto::LogicalOperator::Or, + } + } +} + +impl From for LogicalOperator { + fn from(val: torii_proto::LogicalOperator) -> Self { + match val { + torii_proto::LogicalOperator::And => LogicalOperator::And, + torii_proto::LogicalOperator::Or => LogicalOperator::Or, + } + } +} + +#[derive(Debug, Clone)] +pub enum ComparisonOperator { + Eq, + Neq, + Gt, + Gte, + Lt, + Lte, + In, + NotIn, + Contains, + ContainsAll, + ContainsAny, + ArrayLengthEq, + ArrayLengthGt, + ArrayLengthLt, +} + +impl From for torii_proto::ComparisonOperator { + fn from(val: ComparisonOperator) -> Self { + match val { + ComparisonOperator::Eq => torii_proto::ComparisonOperator::Eq, + ComparisonOperator::Neq => torii_proto::ComparisonOperator::Neq, + ComparisonOperator::Gt => torii_proto::ComparisonOperator::Gt, + ComparisonOperator::Gte => torii_proto::ComparisonOperator::Gte, + ComparisonOperator::Lt => torii_proto::ComparisonOperator::Lt, + ComparisonOperator::Lte => torii_proto::ComparisonOperator::Lte, + ComparisonOperator::In => torii_proto::ComparisonOperator::In, + ComparisonOperator::NotIn => torii_proto::ComparisonOperator::NotIn, + ComparisonOperator::Contains => torii_proto::ComparisonOperator::Contains, + ComparisonOperator::ContainsAll => torii_proto::ComparisonOperator::ContainsAll, + ComparisonOperator::ContainsAny => torii_proto::ComparisonOperator::ContainsAny, + ComparisonOperator::ArrayLengthEq => torii_proto::ComparisonOperator::ArrayLengthEq, + ComparisonOperator::ArrayLengthGt => torii_proto::ComparisonOperator::ArrayLengthGt, + ComparisonOperator::ArrayLengthLt => torii_proto::ComparisonOperator::ArrayLengthLt, + } + } +} + +impl From for ComparisonOperator { + fn from(val: torii_proto::ComparisonOperator) -> Self { + match val { + torii_proto::ComparisonOperator::Eq => ComparisonOperator::Eq, + torii_proto::ComparisonOperator::Neq => ComparisonOperator::Neq, + torii_proto::ComparisonOperator::Gt => ComparisonOperator::Gt, + torii_proto::ComparisonOperator::Gte => ComparisonOperator::Gte, + torii_proto::ComparisonOperator::Lt => ComparisonOperator::Lt, + torii_proto::ComparisonOperator::Lte => ComparisonOperator::Lte, + torii_proto::ComparisonOperator::In => ComparisonOperator::In, + torii_proto::ComparisonOperator::NotIn => ComparisonOperator::NotIn, + torii_proto::ComparisonOperator::Contains => ComparisonOperator::Contains, + torii_proto::ComparisonOperator::ContainsAll => ComparisonOperator::ContainsAll, + torii_proto::ComparisonOperator::ContainsAny => ComparisonOperator::ContainsAny, + torii_proto::ComparisonOperator::ArrayLengthEq => ComparisonOperator::ArrayLengthEq, + torii_proto::ComparisonOperator::ArrayLengthGt => ComparisonOperator::ArrayLengthGt, + torii_proto::ComparisonOperator::ArrayLengthLt => ComparisonOperator::ArrayLengthLt, + } + } +} + +#[derive(Debug, Clone)] +pub struct MemberClause { + pub model: String, + pub member: String, + pub operator: ComparisonOperator, + pub value: MemberValue, +} + +impl From for torii_proto::MemberClause { + fn from(val: MemberClause) -> Self { + torii_proto::MemberClause { + member: val.member, + model: val.model, + operator: val.operator.into(), + value: val.value.into(), + } + } +} + +impl From for MemberClause { + fn from(val: torii_proto::MemberClause) -> Self { + MemberClause { + model: val.model, + member: val.member, + operator: val.operator.into(), + value: val.value.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct CompositeClause { + pub operator: LogicalOperator, + pub clauses: Vec, +} + +impl From for torii_proto::CompositeClause { + fn from(val: CompositeClause) -> Self { + torii_proto::CompositeClause { + operator: val.operator.into(), + clauses: val.clauses.into_iter().map(|c| c.into()).collect(), + } + } +} + +impl From for CompositeClause { + fn from(val: torii_proto::CompositeClause) -> Self { + CompositeClause { + operator: val.operator.into(), + clauses: val.clauses.into_iter().map(|c| c.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub enum Clause { + HashedKeys { keys: Vec }, + Keys { clause: KeysClause }, + Member { clause: MemberClause }, + Composite { clause: CompositeClause }, +} + +impl From for torii_proto::Clause { + fn from(val: Clause) -> Self { + match val { + Clause::HashedKeys { keys } => torii_proto::Clause::HashedKeys( + keys.into_iter().map(|k| field_element_to_felt(&k).unwrap()).collect(), + ), + Clause::Keys { clause } => torii_proto::Clause::Keys(clause.into()), + Clause::Member { clause } => torii_proto::Clause::Member(clause.into()), + Clause::Composite { clause } => torii_proto::Clause::Composite(clause.into()), + } + } +} + +impl From for Clause { + fn from(val: torii_proto::Clause) -> Self { + match val { + torii_proto::Clause::HashedKeys(keys) => { + Clause::HashedKeys { keys: keys.into_iter().map(felt_to_field_element).collect() } + } + torii_proto::Clause::Keys(clause) => Clause::Keys { clause: clause.into() }, + torii_proto::Clause::Member(clause) => Clause::Member { clause: clause.into() }, + torii_proto::Clause::Composite(clause) => Clause::Composite { clause: clause.into() }, + } + } +} + +#[derive(Debug, Clone)] +pub struct Query { + pub world_addresses: Vec, + pub pagination: Pagination, + pub clause: Option, + pub no_hashed_keys: bool, + pub models: Vec, + pub historical: bool, +} + +impl From for torii_proto::Query { + fn from(val: Query) -> Self { + torii_proto::Query { + world_addresses: val + .world_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + pagination: val.pagination.into(), + clause: val.clause.map(|c| c.into()), + models: val.models, + no_hashed_keys: val.no_hashed_keys, + historical: val.historical, + } + } +} + +impl From for Query { + fn from(val: torii_proto::Query) -> Self { + Query { + world_addresses: val.world_addresses.into_iter().map(felt_to_field_element).collect(), + pagination: val.pagination.into(), + clause: val.clause.map(|c| c.into()), + models: val.models, + no_hashed_keys: val.no_hashed_keys, + historical: val.historical, + } + } +} + diff --git a/src/uniffi/types/schema.rs b/src/uniffi/types/schema.rs new file mode 100644 index 0000000..bc88eff --- /dev/null +++ b/src/uniffi/types/schema.rs @@ -0,0 +1,331 @@ +// Schema types - Primitive, Ty, Struct, Enum, Member +use super::core::*; + +#[derive(Debug, Clone)] +pub enum Primitive { + I8 { value: i8 }, + I16 { value: i16 }, + I32 { value: i32 }, + I64 { value: i64 }, + I128 { value: Vec }, // 16 bytes + U8 { value: u8 }, + U16 { value: u16 }, + U32 { value: u32 }, + U64 { value: u64 }, + U128 { value: Vec }, // 16 bytes + U256 { value: U256 }, + Bool { value: bool }, + Felt252 { value: FieldElement }, + ClassHash { value: FieldElement }, + ContractAddress { value: FieldElement }, + EthAddress { value: FieldElement }, +} + +impl From for dojo_types::primitive::Primitive { + fn from(value: Primitive) -> Self { + match value { + Primitive::I8 { value: v } => dojo_types::primitive::Primitive::I8(Some(v)), + Primitive::I16 { value: v } => dojo_types::primitive::Primitive::I16(Some(v)), + Primitive::I32 { value: v } => dojo_types::primitive::Primitive::I32(Some(v)), + Primitive::I64 { value: v } => dojo_types::primitive::Primitive::I64(Some(v)), + Primitive::I128 { value: v } => { + let mut bytes = [0u8; 16]; + bytes.copy_from_slice(&v); + dojo_types::primitive::Primitive::I128(Some(i128::from_be_bytes(bytes))) + } + Primitive::U8 { value: v } => dojo_types::primitive::Primitive::U8(Some(v)), + Primitive::U16 { value: v } => dojo_types::primitive::Primitive::U16(Some(v)), + Primitive::U32 { value: v } => dojo_types::primitive::Primitive::U32(Some(v)), + Primitive::U64 { value: v } => dojo_types::primitive::Primitive::U64(Some(v)), + Primitive::U128 { value: v } => { + let mut bytes = [0u8; 16]; + bytes.copy_from_slice(&v); + dojo_types::primitive::Primitive::U128(Some(u128::from_be_bytes(bytes))) + } + Primitive::U256 { value: v } => dojo_types::primitive::Primitive::U256(Some(uniffi_to_u256(&v).unwrap())), + Primitive::Bool { value: v } => dojo_types::primitive::Primitive::Bool(Some(v)), + Primitive::Felt252 { value: v } => { + dojo_types::primitive::Primitive::Felt252(Some(field_element_to_felt(&v).unwrap())) + } + Primitive::ClassHash { value: v } => { + dojo_types::primitive::Primitive::ClassHash(Some(field_element_to_felt(&v).unwrap())) + } + Primitive::ContractAddress { value: v } => { + dojo_types::primitive::Primitive::ContractAddress(Some(field_element_to_felt(&v).unwrap())) + } + Primitive::EthAddress { value: v } => { + dojo_types::primitive::Primitive::EthAddress(Some(field_element_to_felt(&v).unwrap())) + } + } + } +} + +impl From for Primitive { + fn from(value: dojo_types::primitive::Primitive) -> Self { + match value { + dojo_types::primitive::Primitive::I8(v) => Primitive::I8 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I16(v) => Primitive::I16 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I32(v) => Primitive::I32 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I64(v) => Primitive::I64 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::I128(v) => { + Primitive::I128 { value: v.unwrap_or(0).to_be_bytes().to_vec() } + } + dojo_types::primitive::Primitive::U8(v) => Primitive::U8 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U16(v) => Primitive::U16 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U32(v) => Primitive::U32 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U64(v) => Primitive::U64 { value: v.unwrap_or(0) }, + dojo_types::primitive::Primitive::U128(v) => { + Primitive::U128 { value: v.unwrap_or(0).to_be_bytes().to_vec() } + } + dojo_types::primitive::Primitive::U256(v) => { + Primitive::U256 { value: v.map(u256_to_uniffi).unwrap_or_else(|| U256("0x0".to_string())) } + } + dojo_types::primitive::Primitive::Bool(v) => Primitive::Bool { value: v.unwrap_or(false) }, + dojo_types::primitive::Primitive::Felt252(v) => { + Primitive::Felt252 { value: v.map(felt_to_field_element).unwrap_or_else(|| FieldElement("0x0".to_string())) } + } + dojo_types::primitive::Primitive::ClassHash(v) => { + Primitive::ClassHash { value: v.map(felt_to_field_element).unwrap_or_else(|| FieldElement("0x0".to_string())) } + } + dojo_types::primitive::Primitive::ContractAddress(v) => { + Primitive::ContractAddress { value: v.map(felt_to_field_element).unwrap_or_else(|| FieldElement("0x0".to_string())) } + } + dojo_types::primitive::Primitive::EthAddress(v) => { + Primitive::EthAddress { value: v.map(felt_to_field_element).unwrap_or_else(|| FieldElement("0x0".to_string())) } + } + } + } +} + +#[derive(Debug, Clone)] +pub enum MemberValue { + Primitive { value: Primitive }, + String { value: String }, + List { values: Vec }, +} + +impl From for torii_proto::MemberValue { + fn from(val: MemberValue) -> Self { + match val { + MemberValue::Primitive { value } => torii_proto::MemberValue::Primitive(value.into()), + MemberValue::String { value } => torii_proto::MemberValue::String(value), + MemberValue::List { values } => { + torii_proto::MemberValue::List(values.into_iter().map(|v| v.into()).collect()) + } + } + } +} + +impl From for MemberValue { + fn from(val: torii_proto::MemberValue) -> Self { + match val { + torii_proto::MemberValue::Primitive(value) => MemberValue::Primitive { value: value.into() }, + torii_proto::MemberValue::String(value) => MemberValue::String { value }, + torii_proto::MemberValue::List(values) => { + MemberValue::List { values: values.into_iter().map(|v| v.into()).collect() } + } + } + } +} + +#[derive(Debug, Clone)] +pub struct FixedSizeArray { + pub array: Vec, + pub size: u32, +} + +#[derive(Debug, Clone)] +pub enum Ty { + Primitive { value: Primitive }, + Struct { value: Struct }, + Enum { value: EnumType }, + Tuple { values: Vec }, + Array { values: Vec }, + FixedSizeArray { value: FixedSizeArray }, + ByteArray { value: String }, +} + +impl From for Ty { + fn from(val: dojo_types::schema::Ty) -> Self { + match val { + dojo_types::schema::Ty::Primitive(primitive) => Ty::Primitive { value: primitive.into() }, + dojo_types::schema::Ty::Struct(struct_) => Ty::Struct { value: struct_.into() }, + dojo_types::schema::Ty::Enum(enum_) => Ty::Enum { value: enum_.into() }, + dojo_types::schema::Ty::Tuple(tuple) => { + Ty::Tuple { values: tuple.into_iter().map(|t| t.into()).collect() } + } + dojo_types::schema::Ty::Array(array) => { + Ty::Array { values: array.into_iter().map(|t| t.into()).collect() } + } + dojo_types::schema::Ty::FixedSizeArray((ty, size)) => Ty::FixedSizeArray { value: FixedSizeArray { + array: ty.into_iter().map(|t| t.into()).collect(), + size, + }}, + dojo_types::schema::Ty::ByteArray(array) => Ty::ByteArray { value: array }, + } + } +} + +impl From for dojo_types::schema::Ty { + fn from(val: Ty) -> Self { + match val { + Ty::Primitive { value } => dojo_types::schema::Ty::Primitive(value.into()), + Ty::Struct { value } => dojo_types::schema::Ty::Struct(value.into()), + Ty::Enum { value } => dojo_types::schema::Ty::Enum(value.into()), + Ty::Tuple { values } => { + dojo_types::schema::Ty::Tuple(values.into_iter().map(|t| t.into()).collect()) + } + Ty::Array { values } => { + dojo_types::schema::Ty::Array(values.into_iter().map(|t| t.into()).collect()) + } + Ty::FixedSizeArray { value: fixed_size_array } => dojo_types::schema::Ty::FixedSizeArray(( + fixed_size_array.array.into_iter().map(|t| t.into()).collect(), + fixed_size_array.size, + )), + Ty::ByteArray { value } => dojo_types::schema::Ty::ByteArray(value), + } + } +} + +#[derive(Debug, Clone)] +pub struct Member { + pub name: String, + pub ty: Ty, + pub key: bool, +} + +impl From for Member { + fn from(value: dojo_types::schema::Member) -> Self { + Member { name: value.name, ty: value.ty.into(), key: value.key } + } +} + +impl From for dojo_types::schema::Member { + fn from(value: Member) -> Self { + dojo_types::schema::Member { name: value.name, ty: value.ty.into(), key: value.key } + } +} + +#[derive(Debug, Clone)] +pub struct Struct { + pub name: String, + pub children: Vec, +} + +impl From for dojo_types::schema::Struct { + fn from(value: Struct) -> Self { + dojo_types::schema::Struct { + name: value.name, + children: value.children.into_iter().map(|c| c.into()).collect(), + } + } +} + +impl From for Struct { + fn from(value: dojo_types::schema::Struct) -> Self { + Struct { + name: value.name, + children: value.children.into_iter().map(|c| c.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub struct EnumOption { + pub name: String, + pub ty: Ty, +} + +impl From for EnumOption { + fn from(value: dojo_types::schema::EnumOption) -> Self { + EnumOption { name: value.name, ty: value.ty.into() } + } +} + +impl From for dojo_types::schema::EnumOption { + fn from(value: EnumOption) -> Self { + dojo_types::schema::EnumOption { name: value.name, ty: value.ty.into() } + } +} + +#[derive(Debug, Clone)] +pub struct EnumType { + pub name: String, + pub option: u8, + pub options: Vec, +} + +impl From for EnumType { + fn from(value: dojo_types::schema::Enum) -> Self { + EnumType { + name: value.name, + option: value.option.unwrap_or(0), + options: value.options.into_iter().map(|o| o.into()).collect(), + } + } +} + +impl From for dojo_types::schema::Enum { + fn from(value: EnumType) -> Self { + dojo_types::schema::Enum { + name: value.name, + option: Some(value.option), + options: value.options.into_iter().map(|o| o.into()).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub enum ValueType { + String { value: String }, + Int { value: i64 }, + UInt { value: u64 }, + Bool { value: bool }, + Bytes { value: Vec }, +} + +impl From for torii_proto::ValueType { + fn from(val: ValueType) -> Self { + match val { + ValueType::String { value: v } => torii_proto::ValueType::String(v), + ValueType::Int { value: v } => torii_proto::ValueType::Int(v), + ValueType::UInt { value: v } => torii_proto::ValueType::UInt(v), + ValueType::Bool { value: v } => torii_proto::ValueType::Bool(v), + ValueType::Bytes { value: v } => torii_proto::ValueType::Bytes(v), + } + } +} + +impl From for ValueType { + fn from(val: torii_proto::ValueType) -> Self { + match val { + torii_proto::ValueType::String(v) => ValueType::String { value: v }, + torii_proto::ValueType::Int(v) => ValueType::Int { value: v }, + torii_proto::ValueType::UInt(v) => ValueType::UInt { value: v }, + torii_proto::ValueType::Bool(v) => ValueType::Bool { value: v }, + torii_proto::ValueType::Bytes(v) => ValueType::Bytes { value: v }, + } + } +} + +#[derive(Debug, Clone)] +pub struct Value { + pub primitive_type: Primitive, + pub value_type: ValueType, +} + +impl From for Value { + fn from(val: torii_proto::Value) -> Self { + Value { primitive_type: val.primitive_type.into(), value_type: val.value_type.into() } + } +} + +impl From for torii_proto::Value { + fn from(val: Value) -> Self { + torii_proto::Value { + primitive_type: val.primitive_type.into(), + value_type: val.value_type.into(), + } + } +} + diff --git a/src/uniffi/types/token.rs b/src/uniffi/types/token.rs new file mode 100644 index 0000000..439a513 --- /dev/null +++ b/src/uniffi/types/token.rs @@ -0,0 +1,209 @@ +// Token types +use super::core::*; + +#[derive(Debug, Clone)] +pub struct Token { + pub contract_address: FieldElement, + pub token_id: Option, + pub name: String, + pub symbol: String, + pub decimals: u8, + pub metadata: String, + pub total_supply: Option, +} + +impl From for Token { + fn from(val: torii_proto::Token) -> Self { + Token { + token_id: val.token_id.map(u256_to_uniffi), + contract_address: felt_to_field_element(val.contract_address), + name: val.name, + symbol: val.symbol, + decimals: val.decimals, + metadata: val.metadata, + total_supply: val.total_supply.map(u256_to_uniffi), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenBalance { + pub balance: U256, + pub account_address: FieldElement, + pub contract_address: FieldElement, + pub token_id: Option, +} + +impl From for TokenBalance { + fn from(val: torii_proto::TokenBalance) -> Self { + TokenBalance { + balance: u256_to_uniffi(val.balance), + account_address: felt_to_field_element(val.account_address), + contract_address: felt_to_field_element(val.contract_address), + token_id: val.token_id.map(u256_to_uniffi), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenContract { + pub contract_address: FieldElement, + pub name: String, + pub symbol: String, + pub decimals: u8, + pub metadata: String, + pub token_metadata: String, + pub total_supply: Option, +} + +impl From for TokenContract { + fn from(val: torii_proto::TokenContract) -> Self { + Self { + contract_address: felt_to_field_element(val.contract_address), + name: val.name, + symbol: val.symbol, + decimals: val.decimals, + token_metadata: val.token_metadata, + total_supply: val.total_supply.map(u256_to_uniffi), + metadata: val.metadata, + } + } +} + +#[derive(Debug, Clone)] +pub struct AttributeFilter { + pub trait_name: String, + pub trait_value: String, +} + +impl From for torii_proto::TokenAttributeFilter { + fn from(val: AttributeFilter) -> Self { + torii_proto::TokenAttributeFilter { trait_name: val.trait_name, trait_value: val.trait_value } + } +} + +#[derive(Debug, Clone)] +pub struct TokenQuery { + pub contract_addresses: Vec, + pub token_ids: Vec, + pub attribute_filters: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenQuery { + fn from(val: TokenQuery) -> Self { + torii_proto::TokenQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + attribute_filters: val.attribute_filters.into_iter().map(|f| f.into()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenBalanceQuery { + pub contract_addresses: Vec, + pub account_addresses: Vec, + pub token_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenBalanceQuery { + fn from(val: TokenBalanceQuery) -> Self { + torii_proto::TokenBalanceQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + account_addresses: val + .account_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenContractQuery { + pub contract_addresses: Vec, + pub contract_types: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenContractQuery { + fn from(val: TokenContractQuery) -> Self { + torii_proto::TokenContractQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_types: val.contract_types.into_iter().map(|t| t.into()).collect(), + pagination: val.pagination.into(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenTransfer { + pub id: String, + pub contract_address: FieldElement, + pub from_address: FieldElement, + pub to_address: FieldElement, + pub amount: U256, + pub token_id: Option, + pub executed_at: u64, + pub event_id: Option, +} + +impl From for TokenTransfer { + fn from(val: torii_proto::TokenTransfer) -> Self { + TokenTransfer { + id: val.id, + contract_address: felt_to_field_element(val.contract_address), + from_address: felt_to_field_element(val.from_address), + to_address: felt_to_field_element(val.to_address), + amount: u256_to_uniffi(val.amount), + token_id: val.token_id.map(u256_to_uniffi), + executed_at: val.executed_at.timestamp() as u64, + event_id: val.event_id, + } + } +} + +#[derive(Debug, Clone)] +pub struct TokenTransferQuery { + pub contract_addresses: Vec, + pub account_addresses: Vec, + pub token_ids: Vec, + pub pagination: Pagination, +} + +impl From for torii_proto::TokenTransferQuery { + fn from(val: TokenTransferQuery) -> Self { + torii_proto::TokenTransferQuery { + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + account_addresses: val + .account_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + token_ids: val.token_ids.into_iter().map(|t| uniffi_to_u256(&t).unwrap()).collect(), + pagination: val.pagination.into(), + } + } +} + diff --git a/src/uniffi/types/transaction.rs b/src/uniffi/types/transaction.rs new file mode 100644 index 0000000..8d0657a --- /dev/null +++ b/src/uniffi/types/transaction.rs @@ -0,0 +1,128 @@ +// Transaction types +use super::core::*; + +#[derive(Debug, Clone)] +pub enum CallType { + Execute, + ExecuteFromOutside, +} + +impl From for CallType { + fn from(val: torii_proto::CallType) -> Self { + match val { + torii_proto::CallType::Execute => CallType::Execute, + torii_proto::CallType::ExecuteFromOutside => CallType::ExecuteFromOutside, + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionCall { + pub contract_address: FieldElement, + pub entrypoint: String, + pub calldata: Vec, + pub call_type: CallType, + pub caller_address: FieldElement, +} + +impl From for TransactionCall { + fn from(val: torii_proto::TransactionCall) -> Self { + TransactionCall { + contract_address: felt_to_field_element(val.contract_address), + entrypoint: val.entrypoint, + calldata: val.calldata.into_iter().map(felt_to_field_element).collect(), + call_type: val.call_type.into(), + caller_address: felt_to_field_element(val.caller_address), + } + } +} + +#[derive(Debug, Clone)] +pub struct Transaction { + pub transaction_hash: FieldElement, + pub sender_address: FieldElement, + pub calldata: Vec, + pub max_fee: FieldElement, + pub signature: Vec, + pub nonce: FieldElement, + pub block_number: u64, + pub transaction_type: String, + pub block_timestamp: u64, + pub calls: Vec, + pub unique_models: Vec, +} + +impl From for Transaction { + fn from(val: torii_proto::Transaction) -> Self { + Transaction { + transaction_hash: felt_to_field_element(val.transaction_hash), + sender_address: felt_to_field_element(val.sender_address), + calldata: val.calldata.into_iter().map(felt_to_field_element).collect(), + max_fee: felt_to_field_element(val.max_fee), + signature: val.signature.into_iter().map(felt_to_field_element).collect(), + nonce: felt_to_field_element(val.nonce), + block_number: val.block_number, + transaction_type: val.transaction_type, + block_timestamp: val.block_timestamp.timestamp() as u64, + calls: val.calls.into_iter().map(|c| c.into()).collect(), + unique_models: val.unique_models.into_iter().map(felt_to_field_element).collect(), + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionFilter { + pub transaction_hashes: Vec, + pub caller_addresses: Vec, + pub contract_addresses: Vec, + pub entrypoints: Vec, + pub model_selectors: Vec, + pub from_block: Option, + pub to_block: Option, +} + +impl From for torii_proto::TransactionFilter { + fn from(val: TransactionFilter) -> Self { + torii_proto::TransactionFilter { + transaction_hashes: val + .transaction_hashes + .into_iter() + .map(|h| field_element_to_felt(&h).unwrap()) + .collect(), + caller_addresses: val + .caller_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + contract_addresses: val + .contract_addresses + .into_iter() + .map(|a| field_element_to_felt(&a).unwrap()) + .collect(), + entrypoints: val.entrypoints, + model_selectors: val + .model_selectors + .into_iter() + .map(|s| field_element_to_felt(&s).unwrap()) + .collect(), + from_block: val.from_block, + to_block: val.to_block, + } + } +} + +#[derive(Debug, Clone)] +pub struct TransactionQuery { + pub filter: Option, + pub pagination: Pagination, +} + +impl From for torii_proto::TransactionQuery { + fn from(val: TransactionQuery) -> Self { + torii_proto::TransactionQuery { + filter: val.filter.map(|f| f.into()), + pagination: val.pagination.into(), + } + } +} +