(
private_key: &PrivateKey,
program: &str,
function: &str,
inputs: Array,
prove_execution: bool,
cache: bool,
imports: Option<Object>,
p
| 154 | #[wasm_bindgen(js_name = executeFunctionOffline)] |
| 155 | #[allow(clippy::too_many_arguments)] |
| 156 | pub async fn execute_function_offline( |
| 157 | private_key: &PrivateKey, |
| 158 | program: &str, |
| 159 | function: &str, |
| 160 | inputs: Array, |
| 161 | prove_execution: bool, |
| 162 | cache: bool, |
| 163 | imports: Option<Object>, |
| 164 | proving_key: Option<ProvingKey>, |
| 165 | verifying_key: Option<VerifyingKey>, |
| 166 | url: Option<String>, |
| 167 | query: Option<QueryOption>, |
| 168 | edition: Option<u16>, |
| 169 | program_imports: Option<ProgramImports>, |
| 170 | ) -> Result<ExecutionResponse, String> { |
| 171 | let node_url = url.as_deref().unwrap_or(DEFAULT_URL); |
| 172 | let inputs = inputs.to_vec(); |
| 173 | let rng = &mut rand::rng(); |
| 174 | let edition = edition.unwrap_or(1); |
| 175 | |
| 176 | let mut resolved = ResolvedProcess::resolve(&program_imports, program, edition, imports)?; |
| 177 | let program_native = resolved.program().clone(); |
| 178 | let process = resolved.process_mut(); |
| 179 | |
| 180 | let (response, mut trace) = execute_program!( |
| 181 | process, |
| 182 | process_inputs!(inputs), |
| 183 | program, |
| 184 | function, |
| 185 | private_key, |
| 186 | proving_key, |
| 187 | verifying_key, |
| 188 | rng, |
| 189 | edition |
| 190 | ); |
| 191 | |
| 192 | let mut execution_response = if prove_execution { |
| 193 | log("Preparing inclusion proofs for execution"); |
| 194 | if let Some(ref query) = query { |
| 195 | trace.prepare_async(query).await.map_err(|err| err.to_string())?; |
| 196 | } else { |
| 197 | let function_name = IdentifierNative::from_str(function).map_err(|err| err.to_string())?; |
| 198 | let view_key = |
| 199 | ViewKeyNative::try_from(PrivateKeyNative::from(private_key)).map_err(|err| err.to_string())?; |
| 200 | let query = SnapshotQuery::try_from_inputs( |
| 201 | node_url, |
| 202 | &program_native, |
| 203 | &function_name, |
| 204 | &view_key, |
| 205 | &inputs.to_vec(), |
| 206 | ) |
| 207 | .await |
| 208 | .map_err(|err| err.to_string())?; |
| 209 | trace.prepare_async(&query).await.map_err(|err| err.to_string())?; |
| 210 | }; |
| 211 | |
| 212 | log("Proving execution"); |
| 213 | let locator = program_native.id().to_string().add("/").add(function); |
nothing calls this directly
no test coverage detected