Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 2b95888

Browse files
committed
🐛 Fix fetch contract
1 parent d0e6536 commit 2b95888

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

crates/server/src/contract.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use anyhow::{bail, Error, Result};
22
use borsh::to_vec;
33
use hyle::{
4+
indexer::model::ContractDb,
45
model::{BlobTransaction, ProofData, ProofTransaction},
56
node_state::model::Contract,
67
rest::client::ApiHttpClient,
78
};
8-
use sdk::{Blob, ContractInput, ContractName, Digestable, HyleOutput, Identity, TxHash};
9+
use sdk::{
10+
Blob, ContractInput, ContractName, Digestable, HyleOutput, Identity, StateDigest, TxHash,
11+
};
912

1013
pub async fn run<State, Builder>(
1114
client: &ApiHttpClient,
@@ -70,10 +73,10 @@ where
7073
let resp = client
7174
.get_indexer_contract(contract_name)
7275
.await?
73-
.json::<Contract>()
76+
.json::<ContractDb>()
7477
.await?;
7578

76-
resp.state.try_into()
79+
StateDigest(resp.state_digest).try_into()
7780
}
7881

7982
fn execute<State>(

crates/ui/src/contracts.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Error;
22
use hyllar::HyllarToken;
3-
use sdk::ContractName;
3+
use sdk::{ContractName, StateDigest};
44
use serde::Deserialize;
55
use yew::{
66
platform::{spawn_local, time::sleep},
@@ -13,10 +13,12 @@ use super::faucet::TEN_SECS;
1313

1414
#[derive(Deserialize, Debug)]
1515
pub struct Contract {
16-
pub name: ContractName,
17-
pub program_id: Vec<u8>,
18-
pub state: sdk::StateDigest,
19-
pub verifier: String,
16+
pub tx_hash: String, // Corresponds to the registration transaction hash
17+
pub owner: String, // Owner of the contract
18+
pub verifier: String, // Verifier of the contract
19+
pub program_id: Vec<u8>, // Program ID
20+
pub state_digest: Vec<u8>, // State digest of the contract
21+
pub contract_name: String, // Contract name
2022
}
2123

2224
pub fn spawn_fetch_state(state_cb: Callback<HyllarToken>) {
@@ -34,7 +36,7 @@ pub fn spawn_fetch_state(state_cb: Callback<HyllarToken>) {
3436
let body = resp.text().await.unwrap();
3537

3638
if let Ok(contract) = serde_json::from_str::<Contract>(&body) {
37-
state_cb.emit(contract.state.try_into().unwrap());
39+
state_cb.emit(StateDigest(contract.state_digest).try_into().unwrap());
3840
}
3941

4042
sleep(TEN_SECS).await;

0 commit comments

Comments
 (0)