Skip to content

Commit

Permalink
update wasm bindgens
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaan7 committed Nov 22, 2024
1 parent 10a24e1 commit 98e8be0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
20 changes: 12 additions & 8 deletions helios-ts/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,27 @@ impl EthereumClient {
}

#[wasm_bindgen]
pub async fn get_block_transaction_count_by_hash(&self, hash: JsValue) -> Result<u32, JsError> {
pub async fn get_block_transaction_count_by_hash(
&self,
hash: JsValue,
) -> Result<Option<u32>, JsError> {
let hash: B256 = serde_wasm_bindgen::from_value(hash)?;
let count = map_err(self.inner.get_block_transaction_count_by_hash(hash).await)?;
Ok(count as u32)
Ok(count.map(|v| v as u32))
}

#[wasm_bindgen]
pub async fn get_block_transaction_count_by_number(
&self,
block: JsValue,
) -> Result<u32, JsError> {
) -> Result<Option<u32>, JsError> {
let block: BlockTag = serde_wasm_bindgen::from_value(block)?;
let res = self
.inner
.get_block_transaction_count_by_number(block)
.await;
Ok(map_err(res)? as u32)
let count = map_err(
self.inner
.get_block_transaction_count_by_number(block)
.await,
)?;
Ok(count.map(|v| v as u32))
}

#[wasm_bindgen]
Expand Down
20 changes: 12 additions & 8 deletions helios-ts/src/opstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,27 @@ impl OpStackClient {
}

#[wasm_bindgen]
pub async fn get_block_transaction_count_by_hash(&self, hash: JsValue) -> Result<u32, JsError> {
pub async fn get_block_transaction_count_by_hash(
&self,
hash: JsValue,
) -> Result<Option<u32>, JsError> {
let hash: B256 = serde_wasm_bindgen::from_value(hash)?;
let count = map_err(self.inner.get_block_transaction_count_by_hash(hash).await)?;
Ok(count as u32)
Ok(count.map(|v| v as u32))
}

#[wasm_bindgen]
pub async fn get_block_transaction_count_by_number(
&self,
block: JsValue,
) -> Result<u32, JsError> {
) -> Result<Option<u32>, JsError> {
let block: BlockTag = serde_wasm_bindgen::from_value(block)?;
let res = self
.inner
.get_block_transaction_count_by_number(block)
.await;
Ok(map_err(res)? as u32)
let count = map_err(
self.inner
.get_block_transaction_count_by_number(block)
.await,
)?;
Ok(count.map(|v| v as u32))
}

#[wasm_bindgen]
Expand Down

0 comments on commit 98e8be0

Please sign in to comment.