Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantk committed Oct 16, 2023
1 parent a608e91 commit e174147
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyth-rng/src/api/revelation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub async fn revelation(
.await
.map_err(|e| RestError::TemporarilyUnavailable)?;

// sequence_number == 0 means the request does not exist.
if r.sequence_number != 0 {
let value = &state
.state
Expand Down
10 changes: 10 additions & 0 deletions pyth-rng/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ abigen!(PythRandom, "src/abi.json");
pub type PythContract = PythRandom<SignerMiddleware<Provider<Http>, LocalWallet>>;

impl PythContract {
// TODO: this method requires a private key to instantiate the contract. This key
// shouldn't be required for read-only uses (e.g., when the server is running).
pub async fn from_opts(opts: &EthereumOptions) -> Result<PythContract, Box<dyn Error>> {
let provider = Provider::<Http>::try_from(&opts.geth_rpc_addr)?;
let chain_id = provider.get_chainid().await?;
Expand All @@ -52,6 +54,10 @@ impl PythContract {
))
}

/// Submit a request for a random number to the contract.
///
/// This method is a version of the autogenned `request` method that parses the emitted logs
/// to return the sequence number of the created Request.
pub async fn request_wrapper(
&self,
provider: &Address,
Expand Down Expand Up @@ -79,6 +85,10 @@ impl PythContract {
}
}

/// Reveal the generated random number to the contract.
///
/// This method is a version of the autogenned `reveal` method that parses the emitted logs
/// to return the generated random number.
pub async fn reveal_wrapper(
&self,
provider: &Address,
Expand Down
2 changes: 0 additions & 2 deletions pyth-rng/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
#![feature(slice_flatten)]

use {
crate::state::PebbleHashChain,
anyhow::Result,
clap::Parser,
std::error::Error,
utoipa::OpenApi,
};

pub mod api;
Expand Down

0 comments on commit e174147

Please sign in to comment.