From 48be492e7d3563daf41bade254debcae661dc546 Mon Sep 17 00:00:00 2001 From: starkbamse <139136798+starkbamse@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:22:26 +0200 Subject: [PATCH] Custom timeout WASM Allow specification of custom timeout in WASM --- src/core.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.rs b/src/core.rs index 9e2c2c9..dc88c0b 100644 --- a/src/core.rs +++ b/src/core.rs @@ -203,6 +203,7 @@ impl RustlinkJS { /// - `fetch_interval_seconds`: How often to update data points (to prevent RPC rate limitation) /// - `contracts`: A list of tuples containing a ticker name and its corresponding contract address on the EVM chain /// - `callback`: A JavaScript function (async or sync) that will be called every time a new data point is fetched + /// - `call_timeout_seconds`: The timeout for each contract call in seconds /// ```javascript /// import init, { RustlinkJS } from '../web/rustlink.js'; /// @@ -221,7 +222,7 @@ impl RustlinkJS { /// console.log("Callback received:", roundData); /// } /// - /// let rustlink = new RustlinkJS(rpcUrl, fetchIntervalSeconds, contracts, callback); + /// let rustlink = new RustlinkJS(rpcUrl, fetchIntervalSeconds, contracts, callback, 10); /// /// rustlink.start(); /// console.log("Stopping after 5 seconds"); @@ -238,6 +239,7 @@ impl RustlinkJS { fetch_interval_seconds: u64, contracts: Contracts, callback: Function, + call_timeout_seconds: u64, ) -> Self { // Cast `JsValue` to `Function` @@ -250,7 +252,7 @@ impl RustlinkJS { fetch_interval_seconds, reflector, contracts, - std::time::Duration::from_secs(10), + std::time::Duration::from_secs(call_timeout_seconds), ) .map_err(|e| JsValue::from_str(&format!("{}", e))) .unwrap();