Skip to content

Commit

Permalink
deposit&balance in peer
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Apr 29, 2024
1 parent e5f160c commit c78c648
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions crates/peer/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
Box::pin(stream)
}

pub async fn stake<S>(
pub async fn deposit<S>(
&self,
amount: FieldElement,
account: SingleOwnerAccount<P, S>,
Expand All @@ -90,14 +90,36 @@ where
let result = account
.execute(vec![Call {
to: self.registry_address,
selector: get_selector_from_name("stake").unwrap(),
selector: get_selector_from_name("deposit").unwrap(),
calldata: vec![amount],
}])
.send()
.await
.unwrap();

trace!("Stake result: {:?}", result);
trace!("Deposit result: {:?}", result);
Ok(())
}

pub async fn balance<S>(
&self,
target: FieldElement,
account: SingleOwnerAccount<P, S>,
) -> Result<(), Box<dyn Error>>
where
S: Signer + Sync + Send + 'static,
{
let result = account
.execute(vec![Call {
to: self.registry_address,
selector: get_selector_from_name("balance").unwrap(),
calldata: vec![target],
}])
.send()
.await
.unwrap();

trace!("Balance result: {:?}", result);
Ok(())
}
}

0 comments on commit c78c648

Please sign in to comment.