There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(ios,android): setup uniffi infra (#8828)
Brooooooklynadc69548efc8
diff --git a/.github/workflows/release-mobile.yml b/.github/workflows/release-mobile.ymlindex b57ef8694e..dddc11a6a9 100644--- a/.github/workflows/release-mobile.yml+++ b/.github/workflows/release-mobile.yml@@ -37,9 +37,25 @@ env:KEYCHAIN_NAME: ${{ github.workspace }}/signing_tempjobs:+ output-env:+ runs-on: ubuntu-latest+ outputs:+ ENVIRONMENT: ${{ steps.env.outputs.ENVIRONMENT }}+ steps:+ - name: Output Environment+ id: env+ run: |+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then+ echo "ENVIRONMENT=${{ github.event.inputs.build-type }}" >> $GITHUB_OUTPUT+ else+ echo "ENVIRONMENT=" >> $GITHUB_OUTPUT+ fi+build-ios-web:+ needs:+ - output-envruns-on: ubuntu-latest- environment: ${{ inputs.build-type || github.event.inputs.build-type }}+ environment: ${{ needs.output-env.outputs.ENVIRONMENT }}outputs:RELEASE_VERSION: ${{ steps.version.outputs.APP_VERSION }}steps:@@ -71,7 +87,9 @@ jobs:build-android-web:runs-on: ubuntu-latest- environment: ${{ github.event.inputs.build-type || inputs.build-type }}+ needs:+ - output-env+ environment: ${{ needs.output-env.outputs.ENVIRONMENT }}outputs:RELEASE_VERSION: ${{ steps.version.outputs.APP_VERSION }}steps:@@ -132,6 +150,10 @@ jobs:- uses: maxim-lobanov/setup-xcode@v1with:xcode-version: latest-stable+ - name: Setup Rust+ uses: ./.github/actions/setup-rust+ with:+ targets: 'aarch64-apple-ios'- name: Testflightif: ${{ env.BUILD_TYPE != 'stable' }}working-directory: packages/frontend/apps/ios/App@@ -169,8 +191,15 @@ jobs:electron-install: falsehard-link-nm: falseenableScripts: false+ - name: Setup Rust+ uses: ./.github/actions/setup-rust+ with:+ targets: 'aarch64-linux-android'- name: Cap syncrun: yarn workspace @affine/android cap sync+ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'- name: Auth gcloudid: authuses: google-github-actions/auth@v2@@ -185,6 +214,7 @@ jobs:with:distribution: 'temurin'java-version: '17'+ cache: 'gradle'- name: Auto increment version codeid: bumpif: ${{ env.BUILD_TARGET == 'distribution' }}@@ -199,6 +229,7 @@ jobs:AFFINE_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_PASSWORD }}AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD }}AFFINE_ANDROID_SIGN_KEYSTORE: ${{ secrets.AFFINE_ANDROID_SIGN_KEYSTORE }}+- name: Upload to Google Playuses: r0adkll/upload-google-play@v1if: ${{ env.BUILD_TARGET == 'distribution' }}diff --git a/Cargo.lock b/Cargo.lockindex 97096f74fe..e17db4c8ba 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -27,6 +27,14 @@ dependencies = ["sha3",]+[[package]]+name = "affine_mobile_native"+version = "0.0.0"+dependencies = [+ "affine_common",+ "uniffi",+]+[[package]]name = "affine_native"version = "0.0.0"@@ -35,6 +43,7 @@ dependencies = ["affine_schema","anyhow","chrono",+ "criterion2","dotenv","napi","napi-build",@@ -119,6 +128,61 @@ dependencies = ["libc",]+[[package]]+name = "anes"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "735d4f398ca57cfa2880225c2bf81c3b9af3be5bb22e44ae70118dad38713e84"++[[package]]+name = "anstream"+version = "0.6.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"+dependencies = [+ "anstyle",+ "anstyle-parse",+ "anstyle-query",+ "anstyle-wincon",+ "colorchoice",+ "is_terminal_polyfill",+ "utf8parse",+]++[[package]]+name = "anstyle"+version = "1.0.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"++[[package]]+name = "anstyle-parse"+version = "0.2.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"+dependencies = [+ "utf8parse",+]++[[package]]+name = "anstyle-query"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"+dependencies = [+ "windows-sys 0.59.0",+]++[[package]]+name = "anstyle-wincon"+version = "3.0.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"+dependencies = [+ "anstyle",+ "windows-sys 0.59.0",+]+[[package]]name = "anyhow"version = "1.0.93"@@ -134,6 +198,47 @@ dependencies = ["derive_arbitrary",]+[[package]]+name = "askama"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"+dependencies = [+ "askama_derive",+ "askama_escape",+]++[[package]]+name = "askama_derive"+version = "0.12.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"+dependencies = [+ "askama_parser",+ "basic-toml",+ "mime",+ "mime_guess",+ "proc-macro2",+ "quote",+ "serde",+ "syn",+]++[[package]]+name = "askama_escape"+version = "0.10.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"++[[package]]+name = "askama_parser"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"+dependencies = [+ "nom",+]+[[package]]name = "atoi"version = "2.0.0"@@ -182,6 +287,24 @@ version = "1.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"+[[package]]+name = "basic-toml"+version = "0.1.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "823388e228f614e9558c6804262db37960ec8821856535f5c3f59913140558f8"+dependencies = [+ "serde",+]++[[package]]+name = "bincode"+version = "1.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"+dependencies = [+ "serde",+]+[[package]]name = "bit-set"version = "0.5.3"@@ -233,6 +356,12 @@ dependencies = ["generic-array",]+[[package]]+name = "bpaf"+version = "0.9.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "50fd5174866dc2fa2ddc96e8fb800852d37f064f32a45c7b7c2f8fa2c64c77fa"+[[package]]name = "bstr"version = "1.11.0"@@ -262,6 +391,44 @@ version = "1.9.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"+[[package]]+name = "camino"+version = "1.1.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"+dependencies = [+ "serde",+]++[[package]]+name = "cargo-platform"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc"+dependencies = [+ "serde",+]++[[package]]+name = "cargo_metadata"+version = "0.15.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"+dependencies = [+ "camino",+ "cargo-platform",+ "semver",+ "serde",+ "serde_json",+ "thiserror",+]++[[package]]+name = "cast"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"+[[package]]name = "cc"version = "1.2.2"@@ -291,6 +458,79 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "ciborium"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"+dependencies = [+ "ciborium-io",+ "ciborium-ll",+ "serde",+]++[[package]]+name = "ciborium-io"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"++[[package]]+name = "ciborium-ll"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"+dependencies = [+ "ciborium-io",+ "half",+]++[[package]]+name = "clap"+version = "4.5.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"+dependencies = [+ "clap_builder",+ "clap_derive",+]++[[package]]+name = "clap_builder"+version = "4.5.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"+dependencies = [+ "anstream",+ "anstyle",+ "clap_lex",+ "strsim",+]++[[package]]+name = "clap_derive"+version = "4.5.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"+dependencies = [+ "heck",+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "clap_lex"+version = "0.7.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"++[[package]]+name = "colorchoice"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"+[[package]]name = "concurrent-queue"version = "2.5.0"@@ -345,6 +585,23 @@ version = "2.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"+[[package]]+name = "criterion2"+version = "2.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09db22066fd79bd628faf416dac96e44054deb00531601bcc20c6d12506b3701"+dependencies = [+ "anes",+ "bpaf",+ "cast",+ "ciborium",+ "num-traits",+ "oorandom",+ "serde",+ "serde_json",+ "walkdir",+]+[[package]]name = "crossbeam-deque"version = "0.8.5"@@ -379,6 +636,12 @@ version = "0.8.20"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"+[[package]]+name = "crunchy"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"+[[package]]name = "crypto-common"version = "0.1.6"@@ -572,6 +835,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 = "fsevent-sys"version = "4.1.0"@@ -699,6 +971,33 @@ version = "0.31.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"+[[package]]+name = "glob"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"++[[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 = "half"+version = "2.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"+dependencies = [+ "cfg-if",+ "crunchy",+]+[[package]]name = "hashbrown"version = "0.14.5"@@ -964,6 +1263,12 @@ dependencies = ["cfg-if",]+[[package]]+name = "is_terminal_polyfill"+version = "1.70.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"+[[package]]name = "itoa"version = "1.0.14"@@ -1159,6 +1464,22 @@ dependencies = ["libmimalloc-sys",]+[[package]]+name = "mime"+version = "0.3.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"++[[package]]+name = "mime_guess"+version = "2.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"+dependencies = [+ "mime",+ "unicase",+]+[[package]]name = "minimal-lexical"version = "0.2.1"@@ -1363,6 +1684,12 @@ version = "1.20.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"+[[package]]+name = "oorandom"+version = "11.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"+[[package]]name = "ordered-float"version = "4.5.0"@@ -1468,6 +1795,12 @@ version = "0.3.31"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"+[[package]]+name = "plain"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"+[[package]]name = "ppv-lite86"version = "0.2.20"@@ -1747,11 +2080,34 @@ 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.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]+[[package]]name = "semver"version = "1.0.23"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"+dependencies = [+ "serde",+][[package]]name = "serde"@@ -1863,6 +2219,12 @@ dependencies = ["rand_core",]+[[package]]+name = "siphasher"+version = "0.3.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"+[[package]]name = "slab"version = "0.4.9"@@ -1881,6 +2243,12 @@ dependencies = ["serde",]+[[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.2.2"@@ -2136,6 +2504,12 @@ version = "1.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"+[[package]]+name = "static_assertions"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"+[[package]]name = "stringprep"version = "0.1.5"@@ -2147,6 +2521,12 @@ dependencies = ["unicode-properties",]+[[package]]+name = "strsim"+version = "0.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"+[[package]]name = "subtle"version = "2.6.1"@@ -2194,6 +2574,15 @@ dependencies = ["windows-sys 0.59.0",]+[[package]]+name = "textwrap"+version = "0.16.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"+dependencies = [+ "smawk",+]+[[package]]name = "thiserror"version = "1.0.69"@@ -2305,6 +2694,15 @@ dependencies = ["tokio",]+[[package]]+name = "toml"+version = "0.5.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"+dependencies = [+ "serde",+]+[[package]]name = "tracing"version = "0.1.41"@@ -2373,6 +2771,12 @@ version = "1.17.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"+[[package]]+name = "unicase"+version = "2.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df"+[[package]]name = "unicode-bidi"version = "0.3.17"@@ -2412,6 +2816,136 @@ version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"+[[package]]+name = "uniffi"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4cb08c58c7ed7033150132febe696bef553f891b1ede57424b40d87a89e3c170"+dependencies = [+ "anyhow",+ "camino",+ "cargo_metadata",+ "clap",+ "uniffi_bindgen",+ "uniffi_build",+ "uniffi_core",+ "uniffi_macros",+]++[[package]]+name = "uniffi_bindgen"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cade167af943e189a55020eda2c314681e223f1e42aca7c4e52614c2b627698f"+dependencies = [+ "anyhow",+ "askama",+ "camino",+ "cargo_metadata",+ "fs-err",+ "glob",+ "goblin",+ "heck",+ "once_cell",+ "paste",+ "serde",+ "textwrap",+ "toml",+ "uniffi_meta",+ "uniffi_udl",+]++[[package]]+name = "uniffi_build"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4c7cf32576e08104b7dc2a6a5d815f37616e66c6866c2a639fe16e6d2286b75b"+dependencies = [+ "anyhow",+ "camino",+ "uniffi_bindgen",+]++[[package]]+name = "uniffi_checksum_derive"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a"+dependencies = [+ "quote",+ "syn",+]++[[package]]+name = "uniffi_core"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bc7687007d2546c454d8ae609b105daceb88175477dac280707ad6d95bcd6f1f"+dependencies = [+ "anyhow",+ "bytes",+ "log",+ "once_cell",+ "paste",+ "static_assertions",+]++[[package]]+name = "uniffi_macros"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "12c65a5b12ec544ef136693af8759fb9d11aefce740fb76916721e876639033b"+dependencies = [+ "bincode",+ "camino",+ "fs-err",+ "once_cell",+ "proc-macro2",+ "quote",+ "serde",+ "syn",+ "toml",+ "uniffi_meta",+]++[[package]]+name = "uniffi_meta"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a74ed96c26882dac1ca9b93ca23c827e284bacbd7ec23c6f0b0372f747d59e4"+dependencies = [+ "anyhow",+ "bytes",+ "siphasher",+ "uniffi_checksum_derive",+]++[[package]]+name = "uniffi_testing"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6a6f984f0781f892cc864a62c3a5c60361b1ccbd68e538e6c9fbced5d82268ac"+dependencies = [+ "anyhow",+ "camino",+ "cargo_metadata",+ "fs-err",+ "once_cell",+]++[[package]]+name = "uniffi_udl"+version = "0.28.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "037820a4cfc4422db1eaa82f291a3863c92c7d1789dc513489c36223f9b4cdfc"+dependencies = [+ "anyhow",+ "textwrap",+ "uniffi_meta",+ "uniffi_testing",+ "weedle2",+]+[[package]]name = "untrusted"version = "0.9.0"@@ -2441,6 +2975,12 @@ version = "1.0.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"+[[package]]+name = "utf8parse"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"+[[package]]name = "uuid"version = "1.11.0"@@ -2562,6 +3102,15 @@ 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 = "whoami"version = "1.5.2"diff --git a/Cargo.toml b/Cargo.tomlindex 1a3af21819..1d53c6d655 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -3,12 +3,14 @@ members = ["./packages/backend/native","./packages/common/native","./packages/frontend/native",- "./packages/frontend/native/schema"+ "./packages/frontend/native/schema",+ "./packages/frontend/mobile-native",]resolver = "2"[workspace.dependencies]affine_common = { path = "./packages/common/native" }+criterion2 = { version = "2", default-features = false }anyhow = "1"chrono = "0.4"dotenv = "0.15"diff --git a/packages/frontend/apps/android/App/app/build.gradle b/packages/frontend/apps/android/App/app/build.gradleindex 25ba97352b..1533b00470 100644--- a/packages/frontend/apps/android/App/app/build.gradle+++ b/packages/frontend/apps/android/App/app/build.gradle@@ -1,8 +1,14 @@+import org.jetbrains.kotlin.gradle.dsl.JvmTarget+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion+apply plugin: 'com.android.application'+apply plugin: 'kotlin-android'+apply from: 'capacitor.build.gradle'android {- namespace "app.affine.pro"+ namespace "app.affine.pro"compileSdk rootProject.ext.compileSdkVersion+ ndkVersion = new File(sdkDirectory, "ndk").listFiles().sort().last().namedefaultConfig {applicationId "app.affine.pro"minSdkVersion rootProject.ext.minSdkVersion@@ -15,6 +21,9 @@ android {// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'}+ ndk {+ abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'+ }}buildTypes {release {@@ -22,10 +31,14 @@ android {proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}+ compileOptions {+ sourceCompatibility JavaVersion.VERSION_17+ targetCompatibility JavaVersion.VERSION_17+ }}repositories {- flatDir{+ flatDir {dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'}}@@ -40,15 +53,64 @@ dependencies {androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"implementation project(':capacitor-cordova-android-plugins')+ implementation "net.java.dev.jna:jna:5.15.0@aar"+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0"+ implementation 'androidx.core:core-ktx:1.15.0'}-apply from: 'capacitor.build.gradle'-try {def servicesJSON = file('google-services.json')if (servicesJSON.text) {apply plugin: 'com.google.gms.google-services'}-} catch(Exception e) {+} catch(Exception ignored) {logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")}++apply plugin: 'org.mozilla.rust-android-gradle.rust-android'++cargo {+ module = "../../../../mobile-native"+ libname = "affine_mobile_native"+ targets = ["arm64"]+ pythonCommand = "python3.12"+ targetDirectory = "../../../../../../target"+ apiLevel = 28+ targetIncludes = ["libaffine_mobile_native.so"]+ profile = "release"+}++kotlin {+ compilerOptions {+ apiVersion = KotlinVersion.KOTLIN_2_0+ jvmTarget = JvmTarget.JVM_17+ }+}++afterEvaluate {+ // The `cargoBuild` task isn't available until after evaluation.+ android.applicationVariants.configureEach { variant ->+ def productFlavor = ""+ variant.productFlavors.each {+ productFlavor += "${it.name.capitalize()}"+ }+ def buildType = "${variant.buildType.name.capitalize()}"+ tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])+ }+}++android.applicationVariants.configureEach { variant ->+ def t = tasks.register("generate${variant.name.capitalize()}UniFFIBindings", Exec) {+ workingDir "${project.projectDir}"+ // Runs the bindings generation, note that you must have uniffi-bindgen installed and in your PATH environment variable+ commandLine 'cargo', 'run', '--bin', 'uniffi-bindgen', 'generate', '--library', "${buildDir}/rustJniLibs/android/arm64-v8a/libaffine_mobile_native.so", '--language', 'kotlin', '--out-dir', "${project.projectDir}/src/main/java"+ dependsOn("cargoBuild")+ }+ variant.javaCompileProvider.get().dependsOn(t)+}++tasks.whenTaskAdded { task ->+ if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {+ task.dependsOn 'cargoBuild'+ }+}diff --git a/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.java b/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.javadeleted file mode 100644index 14d1851144..0000000000--- a/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.java+++ /dev/null@@ -1,5 +0,0 @@-package app.affine.pro;--import com.getcapacitor.BridgeActivity;--public class MainActivity extends BridgeActivity {}diff --git a/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.kt b/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.ktnew file mode 100644index 0000000000..a80bb58163--- /dev/null+++ b/packages/frontend/apps/android/App/app/src/main/java/app/affine/pro/MainActivity.kt@@ -0,0 +1,15 @@+package app.affine.pro++import android.os.Build+import android.os.Bundle+import android.util.Log+import androidx.annotation.RequiresApi+import com.getcapacitor.BridgeActivity+import uniffi.affine_mobile_native.hashcashMint;++class MainActivity : BridgeActivity() {+ @RequiresApi(Build.VERSION_CODES.R)+ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ }+}diff --git a/packages/frontend/apps/android/App/app/src/main/java/uniffi/affine_mobile_native/affine_mobile_native.kt b/packages/frontend/apps/android/App/app/src/main/java/uniffi/affine_mobile_native/affine_mobile_native.ktnew file mode 100644index 0000000000..8679e47477--- /dev/null+++ b/packages/frontend/apps/android/App/app/src/main/java/uniffi/affine_mobile_native/affine_mobile_native.kt@@ -0,0 +1,1148 @@+// 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 uniffi.affine_mobile_native++// 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.Callback+import com.sun.jna.Library+import com.sun.jna.Native+import com.sun.jna.Pointer+import com.sun.jna.Structure+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.ConcurrentHashMap+import java.util.concurrent.atomic.AtomicLong++// 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+ */[email protected]("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.INSTANCE.ffi_affine_mobile_native_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.INSTANCE.ffi_affine_mobile_native_rustbuffer_free(buf, status)+ }+ }++ @Suppress("TooGenericExceptionThrown")+ fun asByteBuffer() =+ this.data?.getByteBuffer(0, this.len.toLong())?.also {+ it.order(ByteOrder.BIG_ENDIAN)+ }+}++/**+ * The equivalent of the `*mut RustBuffer` type.+ * Required for callbacks taking in an out pointer.+ *+ * Size is the sum of all values in the struct.+ *+ * @suppress+ */+class RustBufferByReference : ByReference(16) {+ /**+ * Set the pointed-to `RustBuffer` to the given value.+ */+ fun setValue(value: RustBuffer.ByValue) {+ // NOTE: The offsets are as they are in the C-like struct.+ val pointer = getPointer()+ pointer.setLong(0, value.capacity)+ pointer.setLong(8, value.len)+ pointer.setPointer(16, value.data)+ }++ /**+ * Get a `RustBuffer.ByValue` from this reference.+ */+ fun getValue(): RustBuffer.ByValue {+ val pointer = getPointer()+ val value = RustBuffer.ByValue()+ value.writeField("capacity", pointer.getLong(0))+ value.writeField("len", pointer.getLong(8))+ value.writeField("data", pointer.getLong(16))++ return value+ }+}++// 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.+[email protected]("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<KotlinType, FfiType> {+ // 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<KotlinType> : FfiConverter<KotlinType, RustBuffer.ByValue> {+ 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()+[email protected]("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 = code == UNIFFI_CALL_SUCCESS++ fun isError(): Boolean = code == UNIFFI_CALL_ERROR++ fun isPanic(): Boolean = 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<E> {+ 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 <U, E : kotlin.Exception> uniffiRustCallWithError(+ errorHandler: UniffiRustCallStatusErrorHandler<E>,+ 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 <E : kotlin.Exception> uniffiCheckCallStatus(+ errorHandler: UniffiRustCallStatusErrorHandler<E>,+ 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<InternalException> {+ 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 <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U =+ uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)++internal inline fun <T> 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 <T, reified E : Throwable> 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())+ }+ }+}++// Map handles to objects+//+// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.+internal class UniffiHandleMap<T : Any> {+ private val map = ConcurrentHashMap<Long, T>()+ private val counter =+ java.util.concurrent.atomic+ .AtomicLong(0)++ 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(1)+ map.put(handle, obj)+ return handle+ }++ // Get an object from the handle map+ fun get(handle: Long): T = 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 = 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 "affine_mobile_native"+}++private inline fun <reified Lib : Library> loadIndirect(componentName: String): Lib =+ Native.load<Lib>(findLibraryName(componentName), Lib::class.java)++// Define FFI callback types+internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {+ fun callback(+ `data`: Long,+ `pollResult`: Byte,+ )+}++internal interface UniffiForeignFutureFree : com.sun.jna.Callback {+ fun callback(`handle`: Long)+}++internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {+ fun callback(`handle`: Long)+}+[email protected]("handle", "free")+internal open class UniffiForeignFuture(+ @JvmField internal var `handle`: Long = 0.toLong(),+ @JvmField internal var `free`: UniffiForeignFutureFree? = null,+) : Structure() {+ class UniffiByValue(+ `handle`: Long = 0.toLong(),+ `free`: UniffiForeignFutureFree? = null,+ ) : UniffiForeignFuture(`handle`, `free`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFuture) {+ `handle` = other.`handle`+ `free` = other.`free`+ }+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructU8(+ @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(),+ ) : UniffiForeignFutureStructU8(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructU8.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructI8(+ @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(),+ ) : UniffiForeignFutureStructI8(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructI8.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructU16(+ @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(),+ ) : UniffiForeignFutureStructU16(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructU16.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructI16(+ @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(),+ ) : UniffiForeignFutureStructI16(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructI16.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructU32(+ @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(),+ ) : UniffiForeignFutureStructU32(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructU32.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructI32(+ @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(),+ ) : UniffiForeignFutureStructI32(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructI32.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructU64(+ @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(),+ ) : UniffiForeignFutureStructU64(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructU64.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructI64(+ @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(),+ ) : UniffiForeignFutureStructI64(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructI64.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructF32(+ @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(),+ ) : UniffiForeignFutureStructF32(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructF32.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructF64(+ @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(),+ ) : UniffiForeignFutureStructF64(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructF64.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructPointer(+ @JvmField internal var `returnValue`: Pointer = Pointer.NULL,+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),+) : Structure() {+ class UniffiByValue(+ `returnValue`: Pointer = Pointer.NULL,+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),+ ) : UniffiForeignFutureStructPointer(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructPointer.UniffiByValue,+ )+}+[email protected]("returnValue", "callStatus")+internal open class UniffiForeignFutureStructRustBuffer(+ @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(),+ ) : UniffiForeignFutureStructRustBuffer(`returnValue`, `callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) {+ `returnValue` = other.`returnValue`+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,+ )+}+[email protected]("callStatus")+internal open class UniffiForeignFutureStructVoid(+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),+) : Structure() {+ class UniffiByValue(+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),+ ) : UniffiForeignFutureStructVoid(`callStatus`),+ Structure.ByValue++ internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) {+ `callStatus` = other.`callStatus`+ }+}++internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {+ fun callback(+ `callbackData`: Long,+ `result`: UniffiForeignFutureStructVoid.UniffiByValue,+ )+}++// A JNA Library to expose the extern-C FFI definitions.+// This is an implementation detail which will be called internally by the public API.++internal interface UniffiLib : Library {+ companion object {+ internal val INSTANCE: UniffiLib by lazy {+ loadIndirect<UniffiLib>(componentName = "affine_mobile_native")+ .also { lib: UniffiLib ->+ uniffiCheckContractApiVersion(lib)+ uniffiCheckApiChecksums(lib)+ }+ }+ }++ fun uniffi_affine_mobile_native_fn_func_hashcash_mint(+ `resource`: RustBuffer.ByValue,+ `bits`: Int,+ uniffi_out_err: UniffiRustCallStatus,+ ): RustBuffer.ByValue++ fun ffi_affine_mobile_native_rustbuffer_alloc(+ `size`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): RustBuffer.ByValue++ fun ffi_affine_mobile_native_rustbuffer_from_bytes(+ `bytes`: ForeignBytes.ByValue,+ uniffi_out_err: UniffiRustCallStatus,+ ): RustBuffer.ByValue++ fun ffi_affine_mobile_native_rustbuffer_free(+ `buf`: RustBuffer.ByValue,+ uniffi_out_err: UniffiRustCallStatus,+ ): Unit++ fun ffi_affine_mobile_native_rustbuffer_reserve(+ `buf`: RustBuffer.ByValue,+ `additional`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): RustBuffer.ByValue++ fun ffi_affine_mobile_native_rust_future_poll_u8(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_u8(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_u8(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_u8(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Byte++ fun ffi_affine_mobile_native_rust_future_poll_i8(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_i8(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_i8(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_i8(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Byte++ fun ffi_affine_mobile_native_rust_future_poll_u16(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_u16(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_u16(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_u16(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Short++ fun ffi_affine_mobile_native_rust_future_poll_i16(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_i16(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_i16(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_i16(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Short++ fun ffi_affine_mobile_native_rust_future_poll_u32(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_u32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_u32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_u32(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Int++ fun ffi_affine_mobile_native_rust_future_poll_i32(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_i32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_i32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_i32(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Int++ fun ffi_affine_mobile_native_rust_future_poll_u64(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_u64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_u64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_u64(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Long++ fun ffi_affine_mobile_native_rust_future_poll_i64(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_i64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_i64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_i64(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Long++ fun ffi_affine_mobile_native_rust_future_poll_f32(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_f32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_f32(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_f32(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Float++ fun ffi_affine_mobile_native_rust_future_poll_f64(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_f64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_f64(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_f64(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Double++ fun ffi_affine_mobile_native_rust_future_poll_pointer(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_pointer(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_pointer(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_pointer(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Pointer++ fun ffi_affine_mobile_native_rust_future_poll_rust_buffer(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_rust_buffer(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_rust_buffer(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_rust_buffer(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): RustBuffer.ByValue++ fun ffi_affine_mobile_native_rust_future_poll_void(+ `handle`: Long,+ `callback`: UniffiRustFutureContinuationCallback,+ `callbackData`: Long,+ ): Unit++ fun ffi_affine_mobile_native_rust_future_cancel_void(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_free_void(`handle`: Long): Unit++ fun ffi_affine_mobile_native_rust_future_complete_void(+ `handle`: Long,+ uniffi_out_err: UniffiRustCallStatus,+ ): Unit++ fun uniffi_affine_mobile_native_checksum_func_hashcash_mint(): Short++ fun ffi_affine_mobile_native_uniffi_contract_version(): Int+}++private fun uniffiCheckContractApiVersion(lib: UniffiLib) {+ // Get the bindings contract version from our ComponentInterface+ val bindings_contract_version = 26+ // Get the scaffolding contract version by calling the into the dylib+ val scaffolding_contract_version = lib.ffi_affine_mobile_native_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: UniffiLib) {+ if (lib.uniffi_affine_mobile_native_checksum_func_hashcash_mint() != 23633.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }+}++// 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?) {+ args+ .filterIsInstance<Disposable>()+ .forEach(Disposable::destroy)+ }+ }+}++/**+ * @suppress+ */+inline fun <T : Disposable?, R> 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+ }+ }++/**+ * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.+ *+ * @suppress+ * */+object NoPointer++/**+ * @suppress+ */+public object FfiConverterUInt : FfiConverter<UInt, Int> {+ override fun lift(value: Int): UInt = value.toUInt()++ override fun read(buf: ByteBuffer): UInt = lift(buf.getInt())++ override fun lower(value: UInt): Int = value.toInt()++ override fun allocationSize(value: UInt) = 4UL++ override fun write(+ value: UInt,+ buf: ByteBuffer,+ ) {+ buf.putInt(value.toInt())+ }+}++/**+ * @suppress+ */+public object FfiConverterString : FfiConverter<String, RustBuffer.ByValue> {+ // 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)+ }+}++fun `hashcashMint`(+ `resource`: kotlin.String,+ `bits`: kotlin.UInt,+): kotlin.String =+ FfiConverterString.lift(+ uniffiRustCall { _status ->+ UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_func_hashcash_mint(+ FfiConverterString.lower(`resource`),+ FfiConverterUInt.lower(`bits`),+ _status,+ )+ },+ )diff --git a/packages/frontend/apps/android/App/build.gradle b/packages/frontend/apps/android/App/build.gradleindex c7415e32ee..d87af22dc5 100644--- a/packages/frontend/apps/android/App/build.gradle+++ b/packages/frontend/apps/android/App/build.gradle@@ -2,9 +2,12 @@buildscript {- repositories {+ repositories {google()mavenCentral()+ maven {+ url "https://plugins.gradle.org/m2/"+ }}dependencies {classpath 'com.android.tools.build:gradle:8.7.3'@@ -15,6 +18,11 @@ buildscript {}}+plugins {+ id("org.mozilla.rust-android-gradle.rust-android") version "0.9.5"+ id("org.jetbrains.kotlin.jvm") version "2.0.21"+}+apply from: "variables.gradle"allprojects {@@ -23,7 +31,3 @@ allprojects {mavenCentral()}}--task clean(type: Delete) {- delete rootProject.buildDir-}diff --git a/packages/frontend/apps/android/App/settings.gradle b/packages/frontend/apps/android/App/settings.gradleindex 3b4431d772..944c98f423 100644--- a/packages/frontend/apps/android/App/settings.gradle+++ b/packages/frontend/apps/android/App/settings.gradle@@ -2,4 +2,4 @@ include ':app'include ':capacitor-cordova-android-plugins'project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')-apply from: 'capacitor.settings.gradle'\ No newline at end of file+apply from: 'capacitor.settings.gradle'diff --git a/packages/frontend/apps/android/App/variables.gradle b/packages/frontend/apps/android/App/variables.gradleindex 1b54d472bd..3abba966db 100644--- a/packages/frontend/apps/android/App/variables.gradle+++ b/packages/frontend/apps/android/App/variables.gradle@@ -1,7 +1,7 @@ext {minSdkVersion = 22- compileSdkVersion = 34- targetSdkVersion = 34+ compileSdkVersion = 35+ targetSdkVersion = 35androidxActivityVersion = '1.8.0'androidxAppCompatVersion = '1.7.0'androidxCoordinatorLayoutVersion = '1.2.0'@@ -13,4 +13,4 @@ ext {androidxJunitVersion = '1.2.1'androidxEspressoCoreVersion = '3.6.1'cordovaAndroidVersion = '10.1.1'-}\ No newline at end of file+}diff --git a/packages/frontend/apps/ios/.gitignore b/packages/frontend/apps/ios/.gitignoreindex b5ddda903f..fe4c9921b6 100644--- a/packages/frontend/apps/ios/.gitignore+++ b/packages/frontend/apps/ios/.gitignore@@ -17,3 +17,4 @@ App/**/*.p8*.zip*.cerApp/fastlane/report.xml+App/*.adiff --git a/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj b/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxprojindex a7d6f5f240..db3b1cfc90 100644--- a/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj+++ b/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj@@ -18,6 +18,10 @@9D90BE2D2CCB9876006677DB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D90BE222CCB9876006677DB /* Main.storyboard */; };9D90BE2E2CCB9876006677DB /* public in Resources */ = {isa = PBXBuildFile; fileRef = 9D90BE232CCB9876006677DB /* public */; };C4C413792CBE705D00337889 /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };+ C4C97C6E2D0304D100BC2AD1 /* libaffine_mobile_native.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */; };+ C4C97C7C2D030BE000BC2AD1 /* affine_mobile_native.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C6F2D0307B700BC2AD1 /* affine_mobile_native.swift */; };+ C4C97C7D2D030BE000BC2AD1 /* affine_mobile_nativeFFI.h in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C702D0307B700BC2AD1 /* affine_mobile_nativeFFI.h */; };+ C4C97C7E2D030BE000BC2AD1 /* affine_mobile_nativeFFI.modulemap in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C712D0307B700BC2AD1 /* affine_mobile_nativeFFI.modulemap */; };E93B276C2CED92B1001409B8 /* NavigationGesturePlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = E93B276B2CED92B1001409B8 /* NavigationGesturePlugin.swift */; };/* End PBXBuildFile section */@@ -36,6 +40,11 @@9D90BE232CCB9876006677DB /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };+ C4C97C6B2D03027900BC2AD1 /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libaffine_mobile_native.a; path = "../../../../../target/aarch64-apple-ios-sim/release/libaffine_mobile_native.a"; sourceTree = "<group>"; };+ C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libaffine_mobile_native.a; sourceTree = "<group>"; };+ C4C97C6F2D0307B700BC2AD1 /* affine_mobile_native.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = affine_mobile_native.swift; sourceTree = "<group>"; };+ C4C97C702D0307B700BC2AD1 /* affine_mobile_nativeFFI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = affine_mobile_nativeFFI.h; sourceTree = "<group>"; };+ C4C97C712D0307B700BC2AD1 /* affine_mobile_nativeFFI.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = affine_mobile_nativeFFI.modulemap; sourceTree = "<group>"; };E93B276B2CED92B1001409B8 /* NavigationGesturePlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationGesturePlugin.swift; sourceTree = "<group>"; };FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };/* End PBXFileReference section */@@ -45,6 +54,7 @@isa = PBXFrameworksBuildPhase;buildActionMask = 2147483647;files = (+ C4C97C6E2D0304D100BC2AD1 /* libaffine_mobile_native.a in Frameworks */,C4C413792CBE705D00337889 /* Pods_App.framework in Frameworks */,);runOnlyForDeploymentPostprocessing = 0;@@ -55,6 +65,8 @@27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = {isa = PBXGroup;children = (+ C4C97C6B2D03027900BC2AD1 /* libaffine_mobile_native.a */,+ C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */,AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */,);name = Frameworks;@@ -63,6 +75,7 @@504EC2FB1FED79650016851F = {isa = PBXGroup;children = (+ C4C97C722D0307B700BC2AD1 /* uniffi */,9D90BE242CCB9876006677DB /* App */,504EC3051FED79650016851F /* Products */,7F8756D8B27F46E3366F6CEA /* Pods */,@@ -124,6 +137,17 @@path = App;sourceTree = "<group>";};+ C4C97C722D0307B700BC2AD1 /* uniffi */ = {+ isa = PBXGroup;+ children = (+ C4C97C6F2D0307B700BC2AD1 /* affine_mobile_native.swift */,+ C4C97C702D0307B700BC2AD1 /* affine_mobile_nativeFFI.h */,+ C4C97C712D0307B700BC2AD1 /* affine_mobile_nativeFFI.modulemap */,+ );+ name = uniffi;+ path = App/uniffi;+ sourceTree = "<group>";+ };E93B276A2CED9298001409B8 /* NavigationGesture */ = {isa = PBXGroup;children = (@@ -139,6 +163,7 @@isa = PBXNativeTarget;buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */;buildPhases = (+ C4C97C6A2D0300E100BC2AD1 /* Build Rust */,6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */,504EC3001FED79650016851F /* Sources */,504EC3011FED79650016851F /* Frameworks */,@@ -237,6 +262,24 @@shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n";showEnvVarsInLog = 0;};+ C4C97C6A2D0300E100BC2AD1 /* Build Rust */ = {+ isa = PBXShellScriptBuildPhase;+ buildActionMask = 2147483647;+ files = (+ );+ inputFileListPaths = (+ );+ inputPaths = (+ );+ name = "Build Rust";+ outputFileListPaths = (+ );+ outputPaths = (+ );+ runOnlyForDeploymentPostprocessing = 0;+ shellPath = /bin/sh;+ shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nbash $SRCROOT/xc-universal-binary.sh affine_mobile_native $SRCROOT/../../../mobile-native $CONFIGURATION\\n\n";+ };/* End PBXShellScriptBuildPhase section *//* Begin PBXSourcesBuildPhase section */@@ -244,6 +287,9 @@isa = PBXSourcesBuildPhase;buildActionMask = 2147483647;files = (+ C4C97C7C2D030BE000BC2AD1 /* affine_mobile_native.swift in Sources */,+ C4C97C7D2D030BE000BC2AD1 /* affine_mobile_nativeFFI.h in Sources */,+ C4C97C7E2D030BE000BC2AD1 /* affine_mobile_nativeFFI.modulemap in Sources */,E93B276C2CED92B1001409B8 /* NavigationGesturePlugin.swift in Sources */,9D90BE252CCB9876006677DB /* CookieManager.swift in Sources */,9D90BE262CCB9876006677DB /* CookiePlugin.swift in Sources */,@@ -400,6 +446,10 @@"$(inherited)","@executable_path/Frameworks",);+ LIBRARY_SEARCH_PATHS = (+ "$(inherited)",+ "$(PROJECT_DIR)",+ );MARKETING_VERSION = 1.0;OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro;@@ -407,6 +457,7 @@PROVISIONING_PROFILE_SPECIFIER = "AppStore app.affine.pro";"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "AppStore app.affine.pro";SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;+ SWIFT_OBJC_BRIDGING_HEADER = "IOSApp-Bridging-Header.h";SWIFT_VERSION = 5.0;TARGETED_DEVICE_FAMILY = "1,2";XROS_DEPLOYMENT_TARGET = 2.0;@@ -430,6 +481,10 @@"$(inherited)","@executable_path/Frameworks",);+ LIBRARY_SEARCH_PATHS = (+ "$(inherited)",+ "$(PROJECT_DIR)",+ );MARKETING_VERSION = 1.0;ONLY_ACTIVE_ARCH = NO;PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro;@@ -437,6 +492,7 @@PROVISIONING_PROFILE_SPECIFIER = "AppStore app.affine.pro";"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "AppStore app.affine.pro";SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";+ SWIFT_OBJC_BRIDGING_HEADER = "IOSApp-Bridging-Header.h";SWIFT_VERSION = 5.0;TARGETED_DEVICE_FAMILY = "1,2";XROS_DEPLOYMENT_TARGET = 2.0;diff --git a/packages/frontend/apps/ios/App/App/plugins/Cookie/HashcashPlugin.swift b/packages/frontend/apps/ios/App/App/plugins/Cookie/HashcashPlugin.swiftindex 90f42d6123..808749ff50 100644--- a/packages/frontend/apps/ios/App/App/plugins/Cookie/HashcashPlugin.swift+++ b/packages/frontend/apps/ios/App/App/plugins/Cookie/HashcashPlugin.swift@@ -1,5 +1,4 @@import Capacitor-import CryptoSwift@objc(HashcashPlugin)public class HashcashPlugin: CAPPlugin, CAPBridgedPlugin {@@ -13,95 +12,7 @@ public class HashcashPlugin: CAPPlugin, CAPBridgedPlugin {DispatchQueue.global(qos: .default).async {let challenge = call.getString("challenge") ?? ""let bits = call.getInt("bits") ?? 20;- call.resolve(["value": Stamp.mint(resource: challenge, bits: UInt32(bits)).format()])+ call.resolve(["value": hashcashMint(resource: challenge, bits: UInt32(bits))])}}}--let SALT_LENGTH = 16--struct Stamp {- let version: String- let claim: UInt32- let ts: String- let resource: String- let ext: String- let rand: String- let counter: String-- func checkExpiration() -> Bool {- let dateFormatter = DateFormatter()- dateFormatter.dateFormat = "yyyyMMddHHmmss"- guard let date = dateFormatter.date(from: ts) else { return false }- return Date().addingTimeInterval(5 * 60) <= date- }-- func check(bits: UInt32, resource: String) -> Bool {- if version == "1" && bits <= claim && checkExpiration() && self.resource == resource {- let hexDigits = Int(floor(Float(claim) / 4.0))-- // Check challenge- let formatted = format()- let result = formatted.data(using: .utf8)!.sha3(.sha256).compactMap { String(format: "%02x", $0) }.joined()- return result.prefix(hexDigits) == String(repeating: "0", count: hexDigits)- } else {- return false- }- }-- func format() -> String {- return "\(version):\(claim):\(ts):\(resource):\(ext):\(rand):\(counter)"- }-- static func mint(resource: String, bits: UInt32? = nil) -> Stamp {- let version = "1"- let now = Date()- let dateFormatter = DateFormatter()- dateFormatter.dateFormat = "yyyyMMddHHmmss"- let ts = dateFormatter.string(from: now)- let bits = bits ?? 20- let rand = String((0..<SALT_LENGTH).map { _ in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".randomElement()! })- let challenge = "\(version):\(bits):\(ts):\(resource)::\(rand)"-- let hexDigits = Int(ceil(Float(bits) / 4.0))- let zeros = String(repeating: "0", count: hexDigits)- var counter = 0- var counterHex = ""- var hasher = SHA3(variant: .sha256)-- while true {- let toHash = "\(challenge):\(String(format: "%x", counter))"- let hashed = try! hasher.finish(withBytes: toHash.data(using: .utf8)!.bytes)- let result = hashed.compactMap { String(format: "%02x", $0) }.joined()-- if result.prefix(hexDigits) == zeros {- counterHex = String(format: "%x", counter)- break- }- counter += 1- }-- return Stamp(version: version, claim: bits, ts: ts, resource: resource, ext: "", rand: rand, counter: counterHex)- }-}--extension Stamp {- init?(from string: String) throws {- let parts = string.split(separator: ":")- guard parts.count == 7 else {- throw NSError(domain: "StampError", code: 0, userInfo: [NSLocalizedDescriptionKey: "Malformed stamp, expected 7 parts, got \(parts.count)"])- }-- guard let claim = UInt32(parts[1]) else {- throw NSError(domain: "StampError", code: 1, userInfo: [NSLocalizedDescriptionKey: "Malformed stamp"])- }-- self.version = String(parts[0])- self.claim = claim- self.ts = String(parts[2])- self.resource = String(parts[3])- self.ext = String(parts[4])- self.rand = String(parts[5])- self.counter = String(parts[6])- }-}diff --git a/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_native.swift b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_native.swiftnew file mode 100644index 0000000000..30d7930ce7--- /dev/null+++ b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_native.swift@@ -0,0 +1,497 @@+// 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(affine_mobile_nativeFFI)+import affine_mobile_nativeFFI+#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<UInt8>) -> RustBuffer {+ try! rustCall { ffi_affine_mobile_native_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_affine_mobile_native_rustbuffer_free(self, $0) }+ }+}++fileprivate extension ForeignBytes {+ init(bufferPointer: UnsafeBufferPointer<UInt8>) {+ 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<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {+ let range = reader.offset..<reader.offset + MemoryLayout<T>.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<UInt8> {+ 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<S>(_ 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<T: FixedWidthInteger>(_ 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<T>(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<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {+ let neverThrow: ((RustBuffer) throws -> Never)? = nil+ return try makeRustCall(callback, errorHandler: neverThrow)+}++private func rustCallWithError<T, E: Swift.Error>(+ _ errorHandler: @escaping (RustBuffer) throws -> E,+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {+ try makeRustCall(callback, errorHandler: errorHandler)+}++private func makeRustCall<T, E: Swift.Error>(+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,+ errorHandler: ((RustBuffer) throws -> E)?+) throws -> T {+ uniffiEnsureInitialized()+ var callStatus = RustCallStatus.init()+ let returnedVal = callback(&callStatus)+ try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)+ return returnedVal+}++private func uniffiCheckCallStatus<E: Swift.Error>(+ 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<T>(+ callStatus: UnsafeMutablePointer<RustCallStatus>,+ 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<T, E>(+ callStatus: UnsafeMutablePointer<RustCallStatus>,+ 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))+ }+}+fileprivate class UniffiHandleMap<T> {+ private var map: [UInt64: T] = [:]+ private let lock = NSLock()+ private var currentHandle: UInt64 = 1++ func insert(obj: T) -> UInt64 {+ lock.withLock {+ let handle = currentHandle+ currentHandle += 1+ 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+ }+ }++ @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.+++#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 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<UInt8>(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 func hashcashMint(resource: String, bits: UInt32) -> String {+ return try! FfiConverterString.lift(try! rustCall() {+ uniffi_affine_mobile_native_fn_func_hashcash_mint(+ FfiConverterString.lower(resource),+ FfiConverterUInt32.lower(bits),$0+ )+})+}++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 var initializationResult: InitializationResult = {+ // Get the bindings contract version from our ComponentInterface+ let bindings_contract_version = 26+ // Get the scaffolding contract version by calling the into the dylib+ let scaffolding_contract_version = ffi_affine_mobile_native_uniffi_contract_version()+ if bindings_contract_version != scaffolding_contract_version {+ return InitializationResult.contractVersionMismatch+ }+ if (uniffi_affine_mobile_native_checksum_func_hashcash_mint() != 23633) {+ return InitializationResult.apiChecksumMismatch+ }++ return InitializationResult.ok+}()++private func uniffiEnsureInitialized() {+ 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 filediff --git a/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.h b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.hnew file mode 100644index 0000000000..127e443db8--- /dev/null+++ b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.h@@ -0,0 +1,551 @@+// 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 <stdbool.h>+#include <stddef.h>+#include <stdint.h>++// 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_FREE+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_FREE+typedef void (*UniffiForeignFutureFree)(uint64_t+ );++#endif+#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE+#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE+typedef void (*UniffiCallbackInterfaceFree)(uint64_t+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE+#define UNIFFI_FFIDEF_FOREIGN_FUTURE+typedef struct UniffiForeignFuture {+ uint64_t handle;+ UniffiForeignFutureFree _Nonnull free;+} UniffiForeignFuture;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U8+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U8+typedef struct UniffiForeignFutureStructU8 {+ uint8_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructU8;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8+typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureStructU8+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I8+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I8+typedef struct UniffiForeignFutureStructI8 {+ int8_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructI8;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8+typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureStructI8+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U16+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U16+typedef struct UniffiForeignFutureStructU16 {+ uint16_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructU16;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16+typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureStructU16+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I16+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I16+typedef struct UniffiForeignFutureStructI16 {+ int16_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructI16;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16+typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureStructI16+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U32+typedef struct UniffiForeignFutureStructU32 {+ uint32_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructU32;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32+typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureStructU32+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I32+typedef struct UniffiForeignFutureStructI32 {+ int32_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructI32;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32+typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureStructI32+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U64+typedef struct UniffiForeignFutureStructU64 {+ uint64_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructU64;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64+typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureStructU64+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I64+typedef struct UniffiForeignFutureStructI64 {+ int64_t returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructI64;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64+typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureStructI64+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F32+typedef struct UniffiForeignFutureStructF32 {+ float returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructF32;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32+typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureStructF32+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F64+typedef struct UniffiForeignFutureStructF64 {+ double returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructF64;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64+typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureStructF64+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_POINTER+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_POINTER+typedef struct UniffiForeignFutureStructPointer {+ void*_Nonnull returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructPointer;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_POINTER+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_POINTER+typedef void (*UniffiForeignFutureCompletePointer)(uint64_t, UniffiForeignFutureStructPointer+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_RUST_BUFFER+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_RUST_BUFFER+typedef struct UniffiForeignFutureStructRustBuffer {+ RustBuffer returnValue;+ RustCallStatus callStatus;+} UniffiForeignFutureStructRustBuffer;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER+typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureStructRustBuffer+ );++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_VOID+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_VOID+typedef struct UniffiForeignFutureStructVoid {+ RustCallStatus callStatus;+} UniffiForeignFutureStructVoid;++#endif+#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID+#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID+typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid+ );++#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_AFFINE_MOBILE_NATIVE_FN_FUNC_HASHCASH_MINT+#define UNIFFI_FFIDEF_UNIFFI_AFFINE_MOBILE_NATIVE_FN_FUNC_HASHCASH_MINT+RustBuffer uniffi_affine_mobile_native_fn_func_hashcash_mint(RustBuffer resource, uint32_t bits, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_ALLOC+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_ALLOC+RustBuffer ffi_affine_mobile_native_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_FROM_BYTES+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_FROM_BYTES+RustBuffer ffi_affine_mobile_native_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_FREE+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_FREE+void ffi_affine_mobile_native_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_RESERVE+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUSTBUFFER_RESERVE+RustBuffer ffi_affine_mobile_native_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U8+void ffi_affine_mobile_native_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U8+void ffi_affine_mobile_native_rust_future_cancel_u8(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U8+void ffi_affine_mobile_native_rust_future_free_u8(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U8+uint8_t ffi_affine_mobile_native_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I8+void ffi_affine_mobile_native_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I8+void ffi_affine_mobile_native_rust_future_cancel_i8(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I8+void ffi_affine_mobile_native_rust_future_free_i8(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I8+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I8+int8_t ffi_affine_mobile_native_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U16+void ffi_affine_mobile_native_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U16+void ffi_affine_mobile_native_rust_future_cancel_u16(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U16+void ffi_affine_mobile_native_rust_future_free_u16(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U16+uint16_t ffi_affine_mobile_native_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I16+void ffi_affine_mobile_native_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I16+void ffi_affine_mobile_native_rust_future_cancel_i16(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I16+void ffi_affine_mobile_native_rust_future_free_i16(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I16+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I16+int16_t ffi_affine_mobile_native_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U32+void ffi_affine_mobile_native_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U32+void ffi_affine_mobile_native_rust_future_cancel_u32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U32+void ffi_affine_mobile_native_rust_future_free_u32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U32+uint32_t ffi_affine_mobile_native_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I32+void ffi_affine_mobile_native_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I32+void ffi_affine_mobile_native_rust_future_cancel_i32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I32+void ffi_affine_mobile_native_rust_future_free_i32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I32+int32_t ffi_affine_mobile_native_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_U64+void ffi_affine_mobile_native_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_U64+void ffi_affine_mobile_native_rust_future_cancel_u64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_U64+void ffi_affine_mobile_native_rust_future_free_u64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_U64+uint64_t ffi_affine_mobile_native_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_I64+void ffi_affine_mobile_native_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_I64+void ffi_affine_mobile_native_rust_future_cancel_i64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_I64+void ffi_affine_mobile_native_rust_future_free_i64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_I64+int64_t ffi_affine_mobile_native_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_F32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_F32+void ffi_affine_mobile_native_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_F32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_F32+void ffi_affine_mobile_native_rust_future_cancel_f32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_F32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_F32+void ffi_affine_mobile_native_rust_future_free_f32(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_F32+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_F32+float ffi_affine_mobile_native_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_F64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_F64+void ffi_affine_mobile_native_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_F64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_F64+void ffi_affine_mobile_native_rust_future_cancel_f64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_F64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_F64+void ffi_affine_mobile_native_rust_future_free_f64(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_F64+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_F64+double ffi_affine_mobile_native_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_POINTER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_POINTER+void ffi_affine_mobile_native_rust_future_poll_pointer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_POINTER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_POINTER+void ffi_affine_mobile_native_rust_future_cancel_pointer(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_POINTER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_POINTER+void ffi_affine_mobile_native_rust_future_free_pointer(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_POINTER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_POINTER+void*_Nonnull ffi_affine_mobile_native_rust_future_complete_pointer(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_RUST_BUFFER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_RUST_BUFFER+void ffi_affine_mobile_native_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_RUST_BUFFER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_RUST_BUFFER+void ffi_affine_mobile_native_rust_future_cancel_rust_buffer(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_RUST_BUFFER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_RUST_BUFFER+void ffi_affine_mobile_native_rust_future_free_rust_buffer(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_RUST_BUFFER+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_RUST_BUFFER+RustBuffer ffi_affine_mobile_native_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_VOID+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_POLL_VOID+void ffi_affine_mobile_native_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_VOID+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_CANCEL_VOID+void ffi_affine_mobile_native_rust_future_cancel_void(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_VOID+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_FREE_VOID+void ffi_affine_mobile_native_rust_future_free_void(uint64_t handle+);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_VOID+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_RUST_FUTURE_COMPLETE_VOID+void ffi_affine_mobile_native_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_AFFINE_MOBILE_NATIVE_CHECKSUM_FUNC_HASHCASH_MINT+#define UNIFFI_FFIDEF_UNIFFI_AFFINE_MOBILE_NATIVE_CHECKSUM_FUNC_HASHCASH_MINT+uint16_t uniffi_affine_mobile_native_checksum_func_hashcash_mint(void++);+#endif+#ifndef UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_UNIFFI_CONTRACT_VERSION+#define UNIFFI_FFIDEF_FFI_AFFINE_MOBILE_NATIVE_UNIFFI_CONTRACT_VERSION+uint32_t ffi_affine_mobile_native_uniffi_contract_version(void++);+#endif+diff --git a/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.modulemap b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.modulemapnew file mode 100644index 0000000000..a7925044fd--- /dev/null+++ b/packages/frontend/apps/ios/App/App/uniffi/affine_mobile_nativeFFI.modulemap@@ -0,0 +1,4 @@+module affine_mobile_nativeFFI {+ header "affine_mobile_nativeFFI.h"+ export *+}\ No newline at end of filediff --git a/packages/frontend/apps/ios/App/IOSApp-Bridging-Header.h b/packages/frontend/apps/ios/App/IOSApp-Bridging-Header.hnew file mode 100644index 0000000000..3d871e22ef--- /dev/null+++ b/packages/frontend/apps/ios/App/IOSApp-Bridging-Header.h@@ -0,0 +1,6 @@+#ifndef IOSApp_Bridging_Header_h+#define IOSApp_Bridging_Header_h++#import "affine_mobile_nativeFFI.h"++#endif /* IOSApp_Bridging_Header_h */diff --git a/packages/frontend/apps/ios/App/Podfile.lock b/packages/frontend/apps/ios/App/Podfile.lockindex 934d930c0e..759c19c7f5 100644--- a/packages/frontend/apps/ios/App/Podfile.lock+++ b/packages/frontend/apps/ios/App/Podfile.lock@@ -50,4 +50,4 @@ SPEC CHECKSUMS:PODFILE CHECKSUM: e0c0ccf027ea6d51e476f0baf9d44d97b9a90a4b-COCOAPODS: 1.16.2+COCOAPODS: 1.15.2diff --git a/packages/frontend/apps/ios/App/xc-universal-binary.sh b/packages/frontend/apps/ios/App/xc-universal-binary.shnew file mode 100644index 0000000000..4c13990bd2--- /dev/null+++ b/packages/frontend/apps/ios/App/xc-universal-binary.sh@@ -0,0 +1,74 @@+#!/usr/bin/env bash+set -eEuvx++function error_help()+{+ ERROR_MSG="It looks like something went wrong building the Universal Binary."+ echo "error: ${ERROR_MSG}"+}+trap error_help ERR++# XCode tries to be helpful and overwrites the PATH. Reset that.+PATH="$(bash -l -c 'echo $PATH')"++# This should be invoked from inside xcode, not manually+if [[ "${#}" -ne 3 ]]+then+ echo "Usage (note: only call inside xcode!):"+ echo "path/to/build-scripts/xc-universal-binary.sh <FFI_TARGET> <SRC_ROOT_PATH> <buildvariant>"+ exit 1+fi+# what to pass to cargo build -p, e.g. logins_ffi+FFI_TARGET=${1}+# path to source code root+SRC_ROOT=${2}+# buildvariant from our xcconfigs+BUILDVARIANT=$(echo "${3}" | tr '[:upper:]' '[:lower:]')++RELFLAG=+if [[ "${BUILDVARIANT}" != "debug" ]]; then+ RELFLAG=release+else+ RELFLAG=debug+fi++if [[ -n "${SDK_DIR:-}" ]]; then+ # Assume we're in Xcode, which means we're probably cross-compiling.+ # In this case, we need to add an extra library search path for build scripts and proc-macros,+ # which run on the host instead of the target.+ # (macOS Big Sur does not have linkable libraries in /usr/lib/.)+ export LIBRARY_PATH="${SDK_DIR}/usr/lib:${LIBRARY_PATH:-}"+fi++IS_SIMULATOR=0+if [ "${LLVM_TARGET_TRIPLE_SUFFIX-}" = "-simulator" ]; then+ IS_SIMULATOR=1+fi++for arch in $ARCHS; do+ case "$arch" in+ x86_64)+ if [ $IS_SIMULATOR -eq 0 ]; then+ echo "Building for x86_64, but not a simulator build. What's going on?" >&2+ exit 2+ fi++ # Intel iOS simulator+ export CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios"+ $HOME/.cargo/bin/cargo rustc -p "${FFI_TARGET}" --lib --crate-type staticlib --$RELFLAG --target x86_64-apple-ios+ ;;++ arm64)+ if [ $IS_SIMULATOR -eq 0 ]; then+ # Hardware iOS targets+ $HOME/.cargo/bin/cargo rustc -p "${FFI_TARGET}" --lib --crate-type staticlib --$RELFLAG --target aarch64-apple-ios+ cp $SRC_ROOT/../../../target/aarch64-apple-ios/${RELFLAG}/lib${FFI_TARGET}.a $SRCROOT/lib${FFI_TARGET}.a+ else+ # M1 iOS simulator+ $HOME/.cargo/bin/cargo rustc -p "${FFI_TARGET}" --lib --crate-type staticlib --$RELFLAG --target aarch64-apple-ios-sim+ cp $SRC_ROOT/../../../target/aarch64-apple-ios-sim/${RELFLAG}/lib${FFI_TARGET}.a $SRCROOT/lib${FFI_TARGET}.a+ fi+ esac+done++$HOME/.cargo/bin/cargo run --bin uniffi-bindgen generate --library $SRCROOT/lib${FFI_TARGET}.a --language swift --out-dir $SRCROOT/../../ios/App/App/uniffidiff --git a/packages/frontend/mobile-native/Cargo.toml b/packages/frontend/mobile-native/Cargo.tomlnew file mode 100644index 0000000000..531e966aad--- /dev/null+++ b/packages/frontend/mobile-native/Cargo.toml@@ -0,0 +1,19 @@+[package]+edition = "2021"+name = "affine_mobile_native"+version = "0.0.0"++[lib]+crate-type = ["cdylib", "staticlib"]++[[bin]]+# This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen.+name = "uniffi-bindgen"+path = "uniffi-bindgen.rs"++[dependencies]+affine_common = { workspace = true }+uniffi = { version = "0.28", features = ["cli"] }++[build-dependencies]+uniffi = { version = "0.28", features = ["build"] }diff --git a/packages/frontend/mobile-native/src/lib.rs b/packages/frontend/mobile-native/src/lib.rsnew file mode 100644index 0000000000..595c15cc38--- /dev/null+++ b/packages/frontend/mobile-native/src/lib.rs@@ -0,0 +1,8 @@+use affine_common::hashcash::Stamp;++uniffi::setup_scaffolding!("affine_mobile_native");++#[uniffi::export]+pub fn hashcash_mint(resource: String, bits: u32) -> String {+ Stamp::mint(resource, Some(bits)).format()+}diff --git a/packages/frontend/mobile-native/uniffi-bindgen.rs b/packages/frontend/mobile-native/uniffi-bindgen.rsnew file mode 100644index 0000000000..fdd5910c19--- /dev/null+++ b/packages/frontend/mobile-native/uniffi-bindgen.rs@@ -0,0 +1,3 @@+fn main() {+ uniffi::uniffi_bindgen_main()+}diff --git a/packages/frontend/native/Cargo.toml b/packages/frontend/native/Cargo.tomlindex 0fc3c7e3f9..0c71b42593 100644--- a/packages/frontend/native/Cargo.toml+++ b/packages/frontend/native/Cargo.toml@@ -4,13 +4,21 @@ name = "affine_native"version = "0.0.0"[lib]-crate-type = ["cdylib"]+crate-type = ["rlib", "cdylib"]++[features]+noop = ["napi/noop", "napi-derive/noop"]++[[bench]]+name = "hashcash"+harness = false[dependencies]affine_common = { workspace = true }affine_schema = { path = "./schema" }anyhow = { workspace = true }chrono = { workspace = true }+criterion2 = { workspace = true }napi = { workspace = true }napi-derive = { workspace = true }notify = { workspace = true, features = ["serde"] }diff --git a/packages/frontend/native/benches/hashcash.rs b/packages/frontend/native/benches/hashcash.rsnew file mode 100644index 0000000000..0fd4ded6d2--- /dev/null+++ b/packages/frontend/native/benches/hashcash.rs@@ -0,0 +1,28 @@+use std::hint::black_box;++use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};++use affine_native::hashcash::Stamp;++fn bench_hashcash(c: &mut Criterion) {+ let mut group = c.benchmark_group("hashcash");++ group.bench_function(BenchmarkId::from_parameter("Generate"), |b| {+ b.iter(|| {+ black_box(Stamp::mint("test".to_string(), Some(20)).format());+ });+ });++ group.bench_function(BenchmarkId::from_parameter("Verify"), |b| {+ b.iter(|| {+ black_box(+ Stamp::try_from("1:20:20241114061212:test::RsRAAkoxjr4FattQ:292f0d")+ .unwrap()+ .check(20, "test"),+ );+ });+ });+}++criterion_group!(benches, bench_hashcash);+criterion_main!(benches);diff --git a/packages/frontend/native/build.rs b/packages/frontend/native/build.rsindex 3a7a6c97b3..a5d6b2087f 100644--- a/packages/frontend/native/build.rs+++ b/packages/frontend/native/build.rs@@ -14,6 +14,7 @@ async fn main() -> Result<(), std::io::Error> {fs::remove_file(db_path)?;}+ #[cfg(not(feature = "noop"))]napi_build::setup();let options = SqliteConnectOptions::new().filename(db_path)diff --git a/packages/frontend/native/src/hashcash.rs b/packages/frontend/native/src/hashcash.rsindex a9aa75f0b9..b1e32cd61f 100644--- a/packages/frontend/native/src/hashcash.rs+++ b/packages/frontend/native/src/hashcash.rs@@ -1,7 +1,7 @@use std::convert::TryFrom;use affine_common::hashcash::Stamp;-use napi::{bindgen_prelude::AsyncTask, Env, JsBoolean, JsString, Result as NapiResult, Task};+use napi::{bindgen_prelude::AsyncTask, Env, Result, Task};use napi_derive::napi;pub struct AsyncVerifyChallengeResponse {@@ -13,9 +13,9 @@ pub struct AsyncVerifyChallengeResponse {#[napi]impl Task for AsyncVerifyChallengeResponse {type Output = bool;- type JsValue = JsBoolean;+ type JsValue = bool;- fn compute(&mut self) -> NapiResult<Self::Output> {+ fn compute(&mut self) -> Result<Self::Output> {Ok(if let Ok(stamp) = Stamp::try_from(self.response.as_str()) {stamp.check(self.bits, &self.resource)} else {@@ -23,8 +23,8 @@ impl Task for AsyncVerifyChallengeResponse {})}- fn resolve(&mut self, env: Env, output: bool) -> NapiResult<Self::JsValue> {- env.get_boolean(output)+ fn resolve(&mut self, _: Env, output: bool) -> Result<Self::JsValue> {+ Ok(output)}}@@ -49,14 +49,14 @@ pub struct AsyncMintChallengeResponse {#[napi]impl Task for AsyncMintChallengeResponse {type Output = String;- type JsValue = JsString;+ type JsValue = String;- fn compute(&mut self) -> NapiResult<Self::Output> {+ fn compute(&mut self) -> Result<Self::Output> {Ok(Stamp::mint(self.resource.clone(), self.bits).format())}- fn resolve(&mut self, env: Env, output: String) -> NapiResult<Self::JsValue> {- env.create_string(&output)+ fn resolve(&mut self, _: Env, output: String) -> Result<Self::JsValue> {+ Ok(output)}}