Skip to content

Commit 582fda3

Browse files
fix: replace numeric response with hex string for blockNumber and chainId (#776)
1 parent e167626 commit 582fda3

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

helios-ts/lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class HeliosProvider {
188188
return this.#client.get_balance(req.params[0], req.params[1]);
189189
}
190190
case "eth_chainId": {
191-
return this.#chainId;
191+
return `0x${this.#chainId.toString(16)}`;
192192
}
193193
case "eth_blockNumber": {
194194
return this.#client.get_block_number();

helios-ts/src/ethereum.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ impl EthereumClient {
178178
}
179179

180180
#[wasm_bindgen]
181-
pub async fn get_block_number(&self) -> Result<u32, JsError> {
182-
map_err(self.inner.get_block_number().await).map(|v| v.to())
181+
pub async fn get_block_number(&self) -> Result<String, JsError> {
182+
let v = map_err(self.inner.get_block_number().await)?;
183+
Ok(format!("0x{:x}", v))
183184
}
184185

185186
#[wasm_bindgen]

helios-ts/src/linea.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ impl LineaClient {
100100
}
101101

102102
#[wasm_bindgen]
103-
pub async fn get_block_number(&self) -> Result<u32, JsError> {
104-
map_err(self.inner.get_block_number().await).map(|v| v.to())
103+
pub async fn get_block_number(&self) -> Result<String, JsError> {
104+
let v = map_err(self.inner.get_block_number().await)?;
105+
Ok(format!("0x{:x}", v))
105106
}
106107

107108
#[wasm_bindgen]

helios-ts/src/opstack.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ impl OpStackClient {
118118
}
119119

120120
#[wasm_bindgen]
121-
pub async fn get_block_number(&self) -> Result<u32, JsError> {
122-
map_err(self.inner.get_block_number().await).map(|v| v.to())
121+
pub async fn get_block_number(&self) -> Result<String, JsError> {
122+
let v = map_err(self.inner.get_block_number().await)?;
123+
Ok(format!("0x{:x}", v))
123124
}
124125

125126
#[wasm_bindgen]

0 commit comments

Comments
 (0)