pub async fn parse_account_from_str(
    godwoken: &mut GodwokenRpcClient,
    account: &str,
) -> Result<H256> {
    // if match script hash
    if account.starts_with("0x") && account.len() == 66 {
        let r = H256::from_slice(&hex::decode(&account[2..].as_bytes())?)?;
        return Ok(r);
    }

    // if match id
    let account_id: u32 = match account.parse() {
        Ok(a) => a,
        Err(_) => return Err(anyhow!("account id parse error!")),
    };
    let script_hash = godwoken.get_script_hash(account_id).await?;
    Ok(script_hash)
}
/// return script hash of an account
return script hash of an account
return script hash of an account
pub async fn parse_account_from_str(
    godwoken: &mut GodwokenRpcClient,
    account: &str,
) -> Result<H256> {
    // if match script hash
    if account.starts_with("0x") && account.len() == 66 {
        let r = H256::from_slice(&hex::decode(&account[2..].as_bytes())?)?;
        return Ok(r);
    }
    // if match id
    let account_id: u32 = match account.parse() {
        Ok(a) => a,
        Err(_) => return Err(anyhow!("account id parse error!")),
    };
    let script_hash = godwoken.get_script_hash(account_id).await?;
    Ok(script_hash)
}
pub async fn parse_account_from_str ( godwoken : & mut GodwokenRpcClient , account : & str , ) -> Result < H256 > { // if match script hash if account . starts_with ( " " ) && account . len ( ) == 66 { let r = H256 :: from_slice ( & hex :: decode ( & account [ 2 .. ] . as_bytes ( ) ) ? ) ? ; return Ok ( r ) ; } // if match id let account_id : u32 = match account . parse ( ) { Ok ( a ) => a , Err ( _ ) => return Err ( anyhow ! ( " " ) ) , } ; let script_hash = godwoken . get_script_hash ( account_id ) . await ? ; Ok ( script_hash ) }
return script hash of an account
return script hash of an account
godwoken
&mut GodwokenRpcClient
account
&str
godwoken
&mut GodwokenRpcClient
account
&str