create-sia-app 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +179 -0
  3. package/package.json +29 -0
  4. package/template/CLAUDE.md +160 -0
  5. package/template/README.md +102 -0
  6. package/template/_gitignore +5 -0
  7. package/template/biome.json +40 -0
  8. package/template/index.html +13 -0
  9. package/template/package.json +30 -0
  10. package/template/rust/README.md +16 -0
  11. package/template/rust/sia-sdk-rs/.changeset/added_cancel_function_to_cancel_inflight_packed_uploads.md +6 -0
  12. package/template/rust/sia-sdk-rs/.changeset/check_if_we_have_enough_hosts_prior_to_encoding_in_upload_slabs.md +16 -0
  13. package/template/rust/sia-sdk-rs/.changeset/fix_slab_length_in_packed_object.md +5 -0
  14. package/template/rust/sia-sdk-rs/.changeset/fix_upload_racing_race_conditon.md +13 -0
  15. package/template/rust/sia-sdk-rs/.changeset/improved_parallelism_of_packed_uploads.md +5 -0
  16. package/template/rust/sia-sdk-rs/.changeset/progress_callback_will_now_be_called_as_expected_for_packed_uploads.md +5 -0
  17. package/template/rust/sia-sdk-rs/.github/dependabot.yml +10 -0
  18. package/template/rust/sia-sdk-rs/.github/workflows/main.yml +36 -0
  19. package/template/rust/sia-sdk-rs/.github/workflows/prepare-release.yml +34 -0
  20. package/template/rust/sia-sdk-rs/.github/workflows/release.yml +30 -0
  21. package/template/rust/sia-sdk-rs/.rustfmt.toml +4 -0
  22. package/template/rust/sia-sdk-rs/Cargo.lock +4127 -0
  23. package/template/rust/sia-sdk-rs/Cargo.toml +3 -0
  24. package/template/rust/sia-sdk-rs/LICENSE +21 -0
  25. package/template/rust/sia-sdk-rs/README.md +30 -0
  26. package/template/rust/sia-sdk-rs/indexd/CHANGELOG.md +79 -0
  27. package/template/rust/sia-sdk-rs/indexd/Cargo.toml +79 -0
  28. package/template/rust/sia-sdk-rs/indexd/benches/upload.rs +258 -0
  29. package/template/rust/sia-sdk-rs/indexd/src/app_client.rs +1710 -0
  30. package/template/rust/sia-sdk-rs/indexd/src/builder.rs +354 -0
  31. package/template/rust/sia-sdk-rs/indexd/src/download.rs +379 -0
  32. package/template/rust/sia-sdk-rs/indexd/src/hosts.rs +659 -0
  33. package/template/rust/sia-sdk-rs/indexd/src/lib.rs +827 -0
  34. package/template/rust/sia-sdk-rs/indexd/src/mock.rs +162 -0
  35. package/template/rust/sia-sdk-rs/indexd/src/object_encryption.rs +125 -0
  36. package/template/rust/sia-sdk-rs/indexd/src/quic.rs +575 -0
  37. package/template/rust/sia-sdk-rs/indexd/src/rhp4.rs +52 -0
  38. package/template/rust/sia-sdk-rs/indexd/src/slabs.rs +497 -0
  39. package/template/rust/sia-sdk-rs/indexd/src/upload.rs +629 -0
  40. package/template/rust/sia-sdk-rs/indexd/src/wasm_time.rs +41 -0
  41. package/template/rust/sia-sdk-rs/indexd/src/web_transport.rs +398 -0
  42. package/template/rust/sia-sdk-rs/indexd_ffi/CHANGELOG.md +76 -0
  43. package/template/rust/sia-sdk-rs/indexd_ffi/Cargo.toml +47 -0
  44. package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/README.md +10 -0
  45. package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/example.py +130 -0
  46. package/template/rust/sia-sdk-rs/indexd_ffi/src/bin/uniffi-bindgen.rs +3 -0
  47. package/template/rust/sia-sdk-rs/indexd_ffi/src/builder.rs +377 -0
  48. package/template/rust/sia-sdk-rs/indexd_ffi/src/io.rs +155 -0
  49. package/template/rust/sia-sdk-rs/indexd_ffi/src/lib.rs +1039 -0
  50. package/template/rust/sia-sdk-rs/indexd_ffi/src/logging.rs +58 -0
  51. package/template/rust/sia-sdk-rs/indexd_ffi/src/tls.rs +23 -0
  52. package/template/rust/sia-sdk-rs/indexd_wasm/Cargo.toml +33 -0
  53. package/template/rust/sia-sdk-rs/indexd_wasm/src/lib.rs +818 -0
  54. package/template/rust/sia-sdk-rs/knope.toml +54 -0
  55. package/template/rust/sia-sdk-rs/sia_derive/CHANGELOG.md +38 -0
  56. package/template/rust/sia-sdk-rs/sia_derive/Cargo.toml +19 -0
  57. package/template/rust/sia-sdk-rs/sia_derive/src/lib.rs +278 -0
  58. package/template/rust/sia-sdk-rs/sia_sdk/CHANGELOG.md +91 -0
  59. package/template/rust/sia-sdk-rs/sia_sdk/Cargo.toml +59 -0
  60. package/template/rust/sia-sdk-rs/sia_sdk/benches/merkle_root.rs +12 -0
  61. package/template/rust/sia-sdk-rs/sia_sdk/src/blake2.rs +22 -0
  62. package/template/rust/sia-sdk-rs/sia_sdk/src/consensus.rs +767 -0
  63. package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v1.rs +257 -0
  64. package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v2.rs +291 -0
  65. package/template/rust/sia-sdk-rs/sia_sdk/src/encoding.rs +26 -0
  66. package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async/v2.rs +367 -0
  67. package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async.rs +6 -0
  68. package/template/rust/sia-sdk-rs/sia_sdk/src/encryption.rs +303 -0
  69. package/template/rust/sia-sdk-rs/sia_sdk/src/erasure_coding.rs +347 -0
  70. package/template/rust/sia-sdk-rs/sia_sdk/src/lib.rs +15 -0
  71. package/template/rust/sia-sdk-rs/sia_sdk/src/macros.rs +435 -0
  72. package/template/rust/sia-sdk-rs/sia_sdk/src/merkle.rs +112 -0
  73. package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/merkle.rs +357 -0
  74. package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/rpc.rs +1507 -0
  75. package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/types.rs +146 -0
  76. package/template/rust/sia-sdk-rs/sia_sdk/src/rhp.rs +7 -0
  77. package/template/rust/sia-sdk-rs/sia_sdk/src/seed.rs +278 -0
  78. package/template/rust/sia-sdk-rs/sia_sdk/src/signing.rs +236 -0
  79. package/template/rust/sia-sdk-rs/sia_sdk/src/types/common.rs +677 -0
  80. package/template/rust/sia-sdk-rs/sia_sdk/src/types/currency.rs +450 -0
  81. package/template/rust/sia-sdk-rs/sia_sdk/src/types/specifier.rs +110 -0
  82. package/template/rust/sia-sdk-rs/sia_sdk/src/types/spendpolicy.rs +778 -0
  83. package/template/rust/sia-sdk-rs/sia_sdk/src/types/utils.rs +117 -0
  84. package/template/rust/sia-sdk-rs/sia_sdk/src/types/v1.rs +1737 -0
  85. package/template/rust/sia-sdk-rs/sia_sdk/src/types/v2.rs +1726 -0
  86. package/template/rust/sia-sdk-rs/sia_sdk/src/types/work.rs +59 -0
  87. package/template/rust/sia-sdk-rs/sia_sdk/src/types.rs +16 -0
  88. package/template/scripts/setup-rust.js +29 -0
  89. package/template/src/App.tsx +13 -0
  90. package/template/src/components/DevNote.tsx +21 -0
  91. package/template/src/components/auth/ApproveScreen.tsx +84 -0
  92. package/template/src/components/auth/AuthFlow.tsx +77 -0
  93. package/template/src/components/auth/ConnectScreen.tsx +214 -0
  94. package/template/src/components/auth/LoadingScreen.tsx +8 -0
  95. package/template/src/components/auth/RecoveryScreen.tsx +182 -0
  96. package/template/src/components/upload/UploadZone.tsx +314 -0
  97. package/template/src/index.css +9 -0
  98. package/template/src/lib/constants.ts +8 -0
  99. package/template/src/lib/format.ts +35 -0
  100. package/template/src/lib/hex.ts +13 -0
  101. package/template/src/lib/sdk.ts +25 -0
  102. package/template/src/lib/wasm-env.ts +5 -0
  103. package/template/src/main.tsx +12 -0
  104. package/template/src/stores/auth.ts +86 -0
  105. package/template/tsconfig.app.json +31 -0
  106. package/template/tsconfig.json +7 -0
  107. package/template/tsconfig.node.json +26 -0
  108. package/template/vite.config.ts +18 -0
  109. package/template/wasm/indexd_wasm/indexd_wasm.d.ts +309 -0
  110. package/template/wasm/indexd_wasm/indexd_wasm.js +1507 -0
  111. package/template/wasm/indexd_wasm/indexd_wasm_bg.wasm +0 -0
  112. package/template/wasm/indexd_wasm/package.json +31 -0
@@ -0,0 +1,58 @@
1
+ use std::sync::{Arc, Mutex, Once};
2
+
3
+ static LOGGER: Mutex<Option<Arc<dyn Logger>>> = Mutex::new(None);
4
+ static LOGGER_SET: Once = Once::new();
5
+
6
+ static FORWARDER: ForwardLogger = ForwardLogger;
7
+
8
+ struct ForwardLogger;
9
+
10
+ impl log::Log for ForwardLogger {
11
+ fn enabled(&self, meta: &log::Metadata) -> bool {
12
+ for target in ["indexd", "app_client", "indexd_ffi"] {
13
+ if meta.target().contains(target) {
14
+ return true;
15
+ }
16
+ }
17
+ false
18
+ }
19
+
20
+ fn log(&self, record: &log::Record) {
21
+ if !self.enabled(record.metadata()) {
22
+ return;
23
+ }
24
+ if let Some(logger) = { LOGGER.lock().unwrap().clone() } {
25
+ let msg = format!("{}", record.args());
26
+ match record.level() {
27
+ log::Level::Error => logger.error(msg),
28
+ log::Level::Warn => logger.warn(msg),
29
+ log::Level::Info => logger.info(msg),
30
+ log::Level::Debug => logger.debug(msg),
31
+ log::Level::Trace => logger.debug(msg),
32
+ }
33
+ }
34
+ }
35
+
36
+ fn flush(&self) {}
37
+ }
38
+
39
+ /// Sets a foreign logger to receive log messages from the SDK.
40
+ #[uniffi::export]
41
+ pub fn set_logger(logger: Arc<dyn Logger>, level: String) {
42
+ LOGGER_SET.call_once(|| {
43
+ // lazy init the logger
44
+ log::set_logger(&FORWARDER).unwrap();
45
+ });
46
+ LOGGER.lock().unwrap().replace(logger.clone());
47
+ if let Ok(level) = level.parse::<log::LevelFilter>() {
48
+ log::set_max_level(level);
49
+ }
50
+ }
51
+
52
+ #[uniffi::export(with_foreign)]
53
+ pub trait Logger: Send + Sync {
54
+ fn info(&self, msg: String);
55
+ fn warn(&self, msg: String);
56
+ fn error(&self, msg: String);
57
+ fn debug(&self, msg: String);
58
+ }
@@ -0,0 +1,23 @@
1
+ use rustls::ClientConfig;
2
+
3
+ /// Returns a rustls ClientConfig that uses the webpki roots
4
+ /// on Android
5
+ ///
6
+ /// Avoid [rustls-platform-verifier] until https://github.com/rustls/rustls-platform-verifier/issues/115 is resolved
7
+ #[cfg(target_os = "android")]
8
+ pub fn tls_config() -> ClientConfig {
9
+ use rustls::RootCertStore;
10
+ let roots = RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.to_vec());
11
+ ClientConfig::builder()
12
+ .with_root_certificates(roots)
13
+ .with_no_client_auth()
14
+ }
15
+
16
+ /// Returns a rustls ClientConfig that uses the platform trust store
17
+ /// on non-Android OSes using [rustls-platform-verifier]
18
+ #[cfg(not(target_os = "android"))]
19
+ pub fn tls_config() -> ClientConfig {
20
+ use rustls_platform_verifier::ConfigVerifierExt; // adds with_platform_verifier()
21
+ // Uses platform trust store on non-Android OSes.
22
+ ClientConfig::with_platform_verifier().expect("failed to create tls config")
23
+ }
@@ -0,0 +1,33 @@
1
+ [package]
2
+ name = "indexd_wasm"
3
+ version = "0.2.0"
4
+ edition = "2024"
5
+ repository = "https://github.com/SiaFoundation/sia-sdk-rs"
6
+ license = "MIT"
7
+ description = "WASM SDK for interacting with a Sia network indexer"
8
+ authors = ["The Sia Foundation"]
9
+ categories = ["cryptography::cryptocurrencies"]
10
+ keywords = ["sia", "decentralized", "blockchain", "depin", "storage"]
11
+
12
+ [lib]
13
+ crate-type = ["cdylib", "rlib"]
14
+
15
+ [dependencies]
16
+ indexd = { version = "0.2.0", path = "../indexd" }
17
+ sia_sdk = { version = "0.2.0", path = "../sia_sdk" }
18
+ wasm-bindgen = "0.2"
19
+ wasm-bindgen-futures = "0.4"
20
+ serde = { version = "1.0", features = ["derive"] }
21
+ serde_json = "1.0"
22
+ serde-wasm-bindgen = "0.6"
23
+ js-sys = "0.3"
24
+ web-sys = { version = "0.3", features = ["console"] }
25
+ thiserror = "2.0"
26
+ rand = "0.10.0"
27
+ getrandom_02 = { package = "getrandom", version = "0.2", features = ["js"] }
28
+ getrandom = { version = "0.4", features = ["wasm_js"] }
29
+ tokio = { version = "1.49.0", features = ["rt"] }
30
+ console_error_panic_hook = "0.1"
31
+ log = "0.4"
32
+ console_log = "1"
33
+ chrono = "0.4"