Zilliqa / zilliqa-rs

Zilliqa rust SDK
5 stars 1 forks source link

Add rust binding for smart contract fields #8

Closed its-saeed closed 10 months ago

its-saeed commented 11 months ago

If a smart contract contains a field named field1 we should be able to get its value like contract.field1()

its-saeed commented 10 months ago

This is fixed. Code sample:

async fn deploy_a_one_param_contract_through_the_rust_binding() -> Result<()> {
    const END_POINT: &str = "http://localhost:5555";

    let wallet = "d96e9eb5b782a80ea153c937fa83e5948485fbfc8b7e7c069d7b914dbc350aba".parse::<LocalWallet>()?;

    let provider = Provider::<Http>::try_from(END_POINT)?
        .with_chain_id(1)
        .with_signer(wallet.clone());

    let contract = contract::HelloWorld::deploy(Arc::new(provider), wallet.address.to_string()).await?;

    let response = contract.get_hello().await?;

    println!("{response:?}");

    let state = contract.get_state().await?;
    let hello = contract.welcome_msg().await?;
    assert_eq!(hello, state.welcome_msg);

    Ok(())
}