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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +179 -0
- package/package.json +29 -0
- package/template/CLAUDE.md +160 -0
- package/template/README.md +102 -0
- package/template/_gitignore +5 -0
- package/template/biome.json +40 -0
- package/template/index.html +13 -0
- package/template/package.json +30 -0
- package/template/rust/README.md +16 -0
- package/template/rust/sia-sdk-rs/.changeset/added_cancel_function_to_cancel_inflight_packed_uploads.md +6 -0
- package/template/rust/sia-sdk-rs/.changeset/check_if_we_have_enough_hosts_prior_to_encoding_in_upload_slabs.md +16 -0
- package/template/rust/sia-sdk-rs/.changeset/fix_slab_length_in_packed_object.md +5 -0
- package/template/rust/sia-sdk-rs/.changeset/fix_upload_racing_race_conditon.md +13 -0
- package/template/rust/sia-sdk-rs/.changeset/improved_parallelism_of_packed_uploads.md +5 -0
- package/template/rust/sia-sdk-rs/.changeset/progress_callback_will_now_be_called_as_expected_for_packed_uploads.md +5 -0
- package/template/rust/sia-sdk-rs/.github/dependabot.yml +10 -0
- package/template/rust/sia-sdk-rs/.github/workflows/main.yml +36 -0
- package/template/rust/sia-sdk-rs/.github/workflows/prepare-release.yml +34 -0
- package/template/rust/sia-sdk-rs/.github/workflows/release.yml +30 -0
- package/template/rust/sia-sdk-rs/.rustfmt.toml +4 -0
- package/template/rust/sia-sdk-rs/Cargo.lock +4127 -0
- package/template/rust/sia-sdk-rs/Cargo.toml +3 -0
- package/template/rust/sia-sdk-rs/LICENSE +21 -0
- package/template/rust/sia-sdk-rs/README.md +30 -0
- package/template/rust/sia-sdk-rs/indexd/CHANGELOG.md +79 -0
- package/template/rust/sia-sdk-rs/indexd/Cargo.toml +79 -0
- package/template/rust/sia-sdk-rs/indexd/benches/upload.rs +258 -0
- package/template/rust/sia-sdk-rs/indexd/src/app_client.rs +1710 -0
- package/template/rust/sia-sdk-rs/indexd/src/builder.rs +354 -0
- package/template/rust/sia-sdk-rs/indexd/src/download.rs +379 -0
- package/template/rust/sia-sdk-rs/indexd/src/hosts.rs +659 -0
- package/template/rust/sia-sdk-rs/indexd/src/lib.rs +827 -0
- package/template/rust/sia-sdk-rs/indexd/src/mock.rs +162 -0
- package/template/rust/sia-sdk-rs/indexd/src/object_encryption.rs +125 -0
- package/template/rust/sia-sdk-rs/indexd/src/quic.rs +575 -0
- package/template/rust/sia-sdk-rs/indexd/src/rhp4.rs +52 -0
- package/template/rust/sia-sdk-rs/indexd/src/slabs.rs +497 -0
- package/template/rust/sia-sdk-rs/indexd/src/upload.rs +629 -0
- package/template/rust/sia-sdk-rs/indexd/src/wasm_time.rs +41 -0
- package/template/rust/sia-sdk-rs/indexd/src/web_transport.rs +398 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/CHANGELOG.md +76 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/Cargo.toml +47 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/README.md +10 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/example.py +130 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/bin/uniffi-bindgen.rs +3 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/builder.rs +377 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/io.rs +155 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/lib.rs +1039 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/logging.rs +58 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/tls.rs +23 -0
- package/template/rust/sia-sdk-rs/indexd_wasm/Cargo.toml +33 -0
- package/template/rust/sia-sdk-rs/indexd_wasm/src/lib.rs +818 -0
- package/template/rust/sia-sdk-rs/knope.toml +54 -0
- package/template/rust/sia-sdk-rs/sia_derive/CHANGELOG.md +38 -0
- package/template/rust/sia-sdk-rs/sia_derive/Cargo.toml +19 -0
- package/template/rust/sia-sdk-rs/sia_derive/src/lib.rs +278 -0
- package/template/rust/sia-sdk-rs/sia_sdk/CHANGELOG.md +91 -0
- package/template/rust/sia-sdk-rs/sia_sdk/Cargo.toml +59 -0
- package/template/rust/sia-sdk-rs/sia_sdk/benches/merkle_root.rs +12 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/blake2.rs +22 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/consensus.rs +767 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v1.rs +257 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v2.rs +291 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding.rs +26 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async/v2.rs +367 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async.rs +6 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encryption.rs +303 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/erasure_coding.rs +347 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/lib.rs +15 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/macros.rs +435 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/merkle.rs +112 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/merkle.rs +357 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/rpc.rs +1507 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/types.rs +146 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp.rs +7 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/seed.rs +278 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/signing.rs +236 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/common.rs +677 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/currency.rs +450 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/specifier.rs +110 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/spendpolicy.rs +778 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/utils.rs +117 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/v1.rs +1737 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/v2.rs +1726 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/work.rs +59 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types.rs +16 -0
- package/template/scripts/setup-rust.js +29 -0
- package/template/src/App.tsx +13 -0
- package/template/src/components/DevNote.tsx +21 -0
- package/template/src/components/auth/ApproveScreen.tsx +84 -0
- package/template/src/components/auth/AuthFlow.tsx +77 -0
- package/template/src/components/auth/ConnectScreen.tsx +214 -0
- package/template/src/components/auth/LoadingScreen.tsx +8 -0
- package/template/src/components/auth/RecoveryScreen.tsx +182 -0
- package/template/src/components/upload/UploadZone.tsx +314 -0
- package/template/src/index.css +9 -0
- package/template/src/lib/constants.ts +8 -0
- package/template/src/lib/format.ts +35 -0
- package/template/src/lib/hex.ts +13 -0
- package/template/src/lib/sdk.ts +25 -0
- package/template/src/lib/wasm-env.ts +5 -0
- package/template/src/main.tsx +12 -0
- package/template/src/stores/auth.ts +86 -0
- package/template/tsconfig.app.json +31 -0
- package/template/tsconfig.json +7 -0
- package/template/tsconfig.node.json +26 -0
- package/template/vite.config.ts +18 -0
- package/template/wasm/indexd_wasm/indexd_wasm.d.ts +309 -0
- package/template/wasm/indexd_wasm/indexd_wasm.js +1507 -0
- package/template/wasm/indexd_wasm/indexd_wasm_bg.wasm +0 -0
- 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"
|