MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / get_code

Function get_code

fendermint/eth/api/src/apis/eth.rs:814–847  ·  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

812
813/// Returns code at a given address.
814pub async fn get_code<C>(
815 data: JsonRpcData<C>,
816 Params((address, block_id)): Params<(et::H160, et::BlockId)>,
817) -> JsonRpcResult<et::Bytes>
818where
819 C: Client + Sync + Send,
820{
821 let height = data.query_height(block_id).await?;
822
823 // Return empty if not an EVM actor.
824 if data.get_actor_type(&address, height).await? != ActorType::EVM {
825 return Ok(Default::default());
826 }
827
828 // This method has no input parameters.
829 let params = RawBytes::default();
830
831 let ret = data
832 .read_evm_actor::<evm::BytecodeReturn>(address, evm::Method::GetBytecode, params, height)
833 .await?;
834
835 match ret.and_then(|r| r.code) {
836 None => Ok(et::Bytes::default()),
837 Some(cid) => {
838 let code = data
839 .client
840 .ipld(&cid, height)
841 .await
842 .context("failed to fetch bytecode")?;
843
844 Ok(code.map(et::Bytes::from).unwrap_or_default())
845 }
846 }
847}
848
849/// Returns an object with data about the sync status or false.
850pub 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