(
private_key: &PrivateKey,
program: &str,
function: &str,
inputs: Array,
priority_fee_credits: f64,
fee_record: Option<RecordPlaintext>,
url: O
| 247 | #[wasm_bindgen(js_name = buildExecutionTransaction)] |
| 248 | #[allow(clippy::too_many_arguments)] |
| 249 | pub async fn execute( |
| 250 | private_key: &PrivateKey, |
| 251 | program: &str, |
| 252 | function: &str, |
| 253 | inputs: Array, |
| 254 | priority_fee_credits: f64, |
| 255 | fee_record: Option<RecordPlaintext>, |
| 256 | url: Option<String>, |
| 257 | imports: Option<Object>, |
| 258 | proving_key: Option<ProvingKey>, |
| 259 | verifying_key: Option<VerifyingKey>, |
| 260 | fee_proving_key: Option<ProvingKey>, |
| 261 | fee_verifying_key: Option<VerifyingKey>, |
| 262 | query: Option<QueryOption>, |
| 263 | edition: Option<u16>, |
| 264 | program_imports: Option<ProgramImports>, |
| 265 | ) -> Result<Transaction, String> { |
| 266 | let edition = edition.unwrap_or(1); |
| 267 | let mut owned_process; |
| 268 | let program_native; |
| 269 | let mut inner_guard; |
| 270 | let process: &mut ProcessNative = match program_imports.as_ref() { |
| 271 | Some(pi) => { |
| 272 | let (native, guard) = pi.prepare_for_execution(program, edition)?; |
| 273 | program_native = native; |
| 274 | inner_guard = guard; |
| 275 | &mut inner_guard.process |
| 276 | } |
| 277 | None => { |
| 278 | owned_process = ProcessNative::load_web().map_err(|err| err.to_string())?; |
| 279 | program_native = ProgramNative::from_str(program).map_err(|e| e.to_string())?; |
| 280 | ProgramManager::resolve_imports(&mut owned_process, imports, Some(&program_native.id().to_string()))?; |
| 281 | &mut owned_process |
| 282 | } |
| 283 | }; |
| 284 | let transaction = Self::execute_inner( |
| 285 | process, |
| 286 | private_key, |
| 287 | program, |
| 288 | function, |
| 289 | inputs, |
| 290 | priority_fee_credits, |
| 291 | fee_record, |
| 292 | url, |
| 293 | proving_key, |
| 294 | verifying_key, |
| 295 | fee_proving_key, |
| 296 | fee_verifying_key, |
| 297 | query, |
| 298 | edition, |
| 299 | program_native, |
| 300 | ) |
| 301 | .await?; |
| 302 | Ok(transaction) |
| 303 | } |
| 304 | |
| 305 | /// Execute an authorization. |
| 306 | /// |
no test coverage detected