Skip to content

Commit

Permalink
fix: missing rpc methods in helios-ts provider (#425)
Browse files Browse the repository at this point in the history
* expose eth_getTransactionByHash & eth_getTransactionByBlockHashAndIndex in helios-ts provider

* get_transaction_by_block_hash_and_index in OpStackClient

---------

Co-authored-by: Noah Citron <noah@jeff.org>
  • Loading branch information
eshaan7 and ncitron authored Nov 20, 2024
1 parent c34324c commit c929028
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helios-ts/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ export class HeliosProvider {
case "eth_getTransactionReceipt": {
return this.#client.get_transaction_receipt(req.params[0]);
}
case "eth_getTransactionByHash": {
return this.#client.get_transaction_by_hash(req.params[0]);
}
case "eth_getTransactionByBlockHashAndIndex": {
return this.#client.get_transaction_by_block_hash_and_index(req.params[0], req.params[1]);
}
case "eth_getBlockReceipts":
return this.#client.get_block_receipts(req.params[0]);
}
case "eth_getLogs": {
return this.#client.get_logs(req.params[0]);
}
Expand Down
15 changes: 15 additions & 0 deletions helios-ts/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ impl EthereumClient {
Ok(serde_wasm_bindgen::to_value(&tx)?)
}

#[wasm_bindgen]
pub async fn get_transaction_by_block_hash_and_index(
&self,
hash: JsValue,
index: JsValue,
) -> Result<JsValue, JsError> {
let hash: B256 = serde_wasm_bindgen::from_value(hash)?;
let index: u64 = serde_wasm_bindgen::from_value(index)?;
let tx = self
.inner
.get_transaction_by_block_hash_and_index(hash, index)
.await;
Ok(serde_wasm_bindgen::to_value(&tx)?)
}

#[wasm_bindgen]
pub async fn get_transaction_count(
&self,
Expand Down
15 changes: 15 additions & 0 deletions helios-ts/src/opstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ impl OpStackClient {
Ok(serde_wasm_bindgen::to_value(&tx)?)
}

#[wasm_bindgen]
pub async fn get_transaction_by_block_hash_and_index(
&self,
hash: JsValue,
index: JsValue,
) -> Result<JsValue, JsError> {
let hash: B256 = serde_wasm_bindgen::from_value(hash)?;
let index: u64 = serde_wasm_bindgen::from_value(index)?;
let tx = self
.inner
.get_transaction_by_block_hash_and_index(hash, index)
.await;
Ok(serde_wasm_bindgen::to_value(&tx)?)
}

#[wasm_bindgen]
pub async fn get_transaction_count(
&self,
Expand Down
2 changes: 2 additions & 0 deletions rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Helios provides a variety of RPC methods for interacting with the Ethereum netwo
| `eth_getBlockByHash` | `get_block_by_hash` | Returns the information of a block by hash. | `get_block_by_hash(&self, hash: &str, full_tx: bool)` |
| `eth_sendRawTransaction` | `send_raw_transaction` | Submits a raw transaction to the network. | `client.send_raw_transaction(&self, bytes: &str)` |
| `eth_getTransactionReceipt` | `get_transaction_receipt` | Returns the receipt of a transaction by transaction hash. | `client.get_transaction_receipt(&self, hash: &str)` |
| `eth_getTransactionByHash` | `get_transaction_by_hash` | Returns the information about a transaction requested by transaction hash. | `client.get_transaction_by_hash(&self, hash: &str)`
| `eth_getTransactionByBlockHashAndIndex` | `get_transaction_by_block_hash_and_index` | Returns information about a transaction by block hash and transaction index position. | `client.get_transaction_by_block_hash_and_index(&self, hash: &str, index: u64)`
| `eth_getBlockReceipts` | `get_block_receipts` | Returns all transaction receipts of a block by number. | `client.get_block_receipts(&self, block: BlockTag)` |
| `eth_getLogs` | `get_logs` | Returns an array of logs matching the filter. | `client.get_logs(&self, filter: Filter)` |
| `eth_getStorageAt` | `get_storage_at` | Returns the value from a storage position at a given address. | `client.get_storage_at(&self, address: &str, slot: H256, block: BlockTag)` |
Expand Down

0 comments on commit c929028

Please sign in to comment.