MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / call

Function call

fendermint/eth/api/src/apis/eth.rs:703–735  ·  view source on GitHub ↗

Executes a new message call immediately without creating a transaction on the block chain.

(
    data: JsonRpcData<C>,
    Params((tx, block_id)): Params<(TypedTransactionCompat, et::BlockId)>,
)

Source from the content-addressed store, hash-verified

701
702/// Executes a new message call immediately without creating a transaction on the block chain.
703pub async fn call<C>(
704 data: JsonRpcData<C>,
705 Params((tx, block_id)): Params<(TypedTransactionCompat, et::BlockId)>,
706) -> JsonRpcResult<et::Bytes>
707where
708 C: Client + Sync + Send,
709{
710 let msg = to_fvm_message(tx.into())?;
711 let is_create = msg.to == EAM_ACTOR_ADDR;
712 let height = data.query_height(block_id).await?;
713 let response = data.client.call(msg, height).await?;
714 let deliver_tx = response.value;
715
716 // Based on Lotus, we should return the data from the receipt.
717 if deliver_tx.code.is_err() {
718 // There might be some revert data encoded as ABI in the response.
719 let (msg, data) = match decode_fevm_invoke(&deliver_tx) {
720 Ok(h) => (deliver_tx.info, Some(h)),
721 Err(e) => (
722 format!("{}\nfailed to decode return data: {:#}", deliver_tx.info, e),
723 None,
724 ),
725 };
726 error_with_revert(ExitCode::new(deliver_tx.code.value()), msg, data)
727 } else if is_create {
728 let decoded = Vec::<u8>::from(decode_data(&deliver_tx.data)?);
729 Ok(decoded.into())
730 } else {
731 let return_data = decode_fevm_invoke(&deliver_tx)
732 .context("error decoding data from deliver_tx in query")?;
733 Ok(return_data.into())
734 }
735}
736
737/// Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.
738/// The transaction will not be added to the blockchain.

Callers

nothing calls this directly

Calls 8

to_fvm_messageFunction · 0.85
decode_fevm_invokeFunction · 0.85
error_with_revertFunction · 0.85
decode_dataFunction · 0.85
query_heightMethod · 0.80
contextMethod · 0.80
intoMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected