Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cargo build --release --target x86_64-unknown-linux-gnu
# Building wasm32 binary
cargo build --release --target wasm32-unknown-unknown
# Building using wasm-pack
bunx wasm-pack build --release --target web
bunx wasm-pack build --release
```

## Running
Expand Down
22 changes: 22 additions & 0 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,28 @@ impl Client {
}
}

#[wasm_bindgen(js_name = getAllEntities)]
pub async fn get_all_entities(&self, limit: u32, offset: u32) -> Result<JsValue, JsValue> {
#[cfg(feature = "console-error-panic")]
console_error_panic_hook::set_once();

let results = self
.inner
.entities(torii_grpc::types::Query {
limit,
offset,
clause: None,
})
.await;

match results {
Ok(entities) => Ok(js_sys::JSON::parse(
&parse_entities_as_json_str(entities).to_string(),
)?),
Err(err) => Err(JsValue::from(format!("failed to get entities: {err}"))),
}
}

#[wasm_bindgen(js_name = getEventMessages)]
pub async fn get_event_messages(&self, query: Query) -> Result<JsValue, JsValue> {
#[cfg(feature = "console-error-panic")]
Expand Down