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

Function get_code

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

Returns code at a given address.

(
    data: JsonRpcData<C>,
    Params((address, block_id)): Params<(et::H160, et::BlockId)>,
)

Source from the content-addressed store, hash-verified

834
835/// Returns code at a given address.
836pub async fn get_code<C>(
837 data: JsonRpcData<C>,
838 Params((address, block_id)): Params<(et::H160, et::BlockId)>,
839) -> JsonRpcResult<et::Bytes>
840where
841 C: Client + Sync + Send,
842{
843 let height = data.query_height(block_id).await?;
844
845 // Return empty if not an EVM actor.
846 if data.get_actor_type(&address, height).await? != ActorType::EVM {
847 return Ok(Default::default());
848 }
849
850 // This method has no input parameters.
851 let params = RawBytes::default();
852
853 let ret = data
854 .read_evm_actor::<evm::BytecodeReturn>(address, evm::Method::GetBytecode, params, height)
855 .await?;
856
857 match ret.and_then(|r| r.code) {
858 None => Ok(et::Bytes::default()),
859 Some(cid) => {
860 let code = data
861 .client
862 .ipld(&cid, height)
863 .await
864 .context("failed to fetch bytecode")?;
865
866 Ok(code.map(et::Bytes::from).unwrap_or_default())
867 }
868 }
869}
870
871/// Returns an object with data about the sync status or false.
872pub async fn syncing<C>(data: JsonRpcData<C>) -> JsonRpcResult<et::SyncingStatus>

Callers

nothing calls this directly

Calls 4

query_heightMethod · 0.80
get_actor_typeMethod · 0.80
contextMethod · 0.80
ipldMethod · 0.80

Tested by

no test coverage detected