|
@@ -229,19 +229,7 @@ impl NearClient {
|
229
|
229
|
.map_err(Error::DeserializeExecutionOutcome)
|
230
|
230
|
})?;
|
231
|
231
|
|
232
|
|
- match execution_outcome.status {
|
233
|
|
- FinalExecutionStatus::Failure(err) => Err(Error::TxExecution(err)),
|
234
|
|
- FinalExecutionStatus::SuccessValue(data) => {
|
235
|
|
- signer.update_nonce(execution_outcome.transaction.nonce);
|
236
|
|
-
|
237
|
|
- Ok(Output {
|
238
|
|
- transaction: execution_outcome.transaction_outcome,
|
239
|
|
- logs: extract_logs(execution_outcome.receipts_outcome),
|
240
|
|
- data,
|
241
|
|
- })
|
242
|
|
- }
|
243
|
|
- _ => Err(Error::TxNotStarted),
|
244
|
|
- }
|
|
232
|
+ proceed_outcome(signer, execution_outcome)
|
245
|
233
|
}
|
246
|
234
|
|
247
|
235
|
/// Execute a transaction with a function call to the smart contract
|
|
@@ -441,6 +429,7 @@ pub struct FunctionCall<'a> {
|
441
|
429
|
|
442
|
430
|
impl<'a> FunctionCall<'a> {
|
443
|
431
|
/// Sends a transaction and waits until transaction is fully complete. (Has a 10 second timeout)
|
|
432
|
+ /// Also, possible that an output data will be empty if the transaction is still executing
|
444
|
433
|
pub async fn commit(self, block_finality: Finality) -> Result<Output> {
|
445
|
434
|
let transaction_bytes =
|
446
|
435
|
serialize_transaction(&self.info, self.actions, block_finality).await?;
|
|
@@ -459,21 +448,7 @@ impl<'a> FunctionCall<'a> {
|
459
|
448
|
.map_err(Error::DeserializeExecutionOutcome)
|
460
|
449
|
})?;
|
461
|
450
|
|
462
|
|
- match execution_outcome.status {
|
463
|
|
- FinalExecutionStatus::Failure(err) => Err(Error::TxExecution(err)),
|
464
|
|
- FinalExecutionStatus::SuccessValue(data) => {
|
465
|
|
- self.info
|
466
|
|
- .signer()
|
467
|
|
- .update_nonce(execution_outcome.transaction.nonce);
|
468
|
|
-
|
469
|
|
- Ok(Output {
|
470
|
|
- transaction: execution_outcome.transaction_outcome,
|
471
|
|
- logs: extract_logs(execution_outcome.receipts_outcome),
|
472
|
|
- data,
|
473
|
|
- })
|
474
|
|
- }
|
475
|
|
- _ => Err(Error::TxNotStarted),
|
476
|
|
- }
|
|
451
|
+ proceed_outcome(self.info.signer(), execution_outcome)
|
477
|
452
|
}
|
478
|
453
|
|
479
|
454
|
/// Sends a transaction and immediately returns transaction hash.
|
|
@@ -493,3 +468,28 @@ impl<'a> FunctionCall<'a> {
|
493
|
468
|
})
|
494
|
469
|
}
|
495
|
470
|
}
|
|
471
|
+
|
|
472
|
+#[allow(clippy::result_large_err)]
|
|
473
|
+pub(crate) fn proceed_outcome(
|
|
474
|
+ signer: &Signer,
|
|
475
|
+ execution_outcome: FinalExecutionOutcomeView,
|
|
476
|
+) -> Result<Output> {
|
|
477
|
+ signer.update_nonce(execution_outcome.transaction.nonce);
|
|
478
|
+ let transaction = execution_outcome.transaction_outcome;
|
|
479
|
+ let logs = extract_logs(execution_outcome.receipts_outcome);
|
|
480
|
+
|
|
481
|
+ match execution_outcome.status {
|
|
482
|
+ FinalExecutionStatus::Failure(err) => Err(Error::TxExecution(err)),
|
|
483
|
+ FinalExecutionStatus::SuccessValue(data) => Ok(Output {
|
|
484
|
+ transaction,
|
|
485
|
+ logs,
|
|
486
|
+ data,
|
|
487
|
+ }),
|
|
488
|
+ FinalExecutionStatus::NotStarted => Err(Error::TxNotStarted),
|
|
489
|
+ FinalExecutionStatus::Started => Ok(Output {
|
|
490
|
+ transaction,
|
|
491
|
+ logs,
|
|
492
|
+ data: vec![],
|
|
493
|
+ }),
|
|
494
|
+ }
|
|
495
|
+}
|