Skip to content

Commit

Permalink
[fortuna] add uri to chain configs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfirefist committed Jan 25, 2024
1 parent 3e762aa commit 93566f2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion fortuna/src/command/register_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn register_provider(opts: &RegisterProviderOptions) -> Result<()> {
commitment,
bincode::serialize(&commitment_metadata)?.into(),
commitment_length,
bincode::serialize(&opts.uri)?.into(),
bincode::serialize(&chain_config.provider_uri)?.into(),
)
.send()
.await?
Expand Down
5 changes: 2 additions & 3 deletions fortuna/src/command/setup_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub async fn setup_provider(opts: &SetupProviderOptions) -> Result<()> {
private_key: private_key.clone(),
randomness: opts.randomness.clone(),
fee: opts.fee,
uri: opts.uri.clone(),
})
.await?;
} else {
Expand All @@ -100,9 +99,9 @@ pub async fn setup_provider(opts: &SetupProviderOptions) -> Result<()> {
}
}

if bincode::deserialize::<String>(&provider_info.uri)? != opts.uri {
if bincode::deserialize::<String>(&provider_info.uri)? != chain_config.provider_uri {
if let Some(receipt) = contract
.set_provider_uri(bincode::serialize(&opts.uri)?.into())
.set_provider_uri(bincode::serialize(&chain_config.provider_uri)?.into())
.send()
.await?
.log_msg("Pending transfer hash")
Expand Down
4 changes: 4 additions & 0 deletions fortuna/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ pub struct EthereumConfig {
/// How many blocks to wait before revealing the random number.
pub reveal_delay_blocks: BlockNumber,

/// The provider uri to register on chain.
#[serde(default)]
pub provider_uri: String,

/// Use the legacy transaction format (for networks without EIP 1559)
#[serde(default)]
pub legacy_tx: bool,
Expand Down
6 changes: 0 additions & 6 deletions fortuna/src/config/register_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,4 @@ pub struct RegisterProviderOptions {
#[arg(long = "pyth-contract-fee")]
#[arg(default_value = "100")]
pub fee: u128,

/// The URI where clients can retrieve random values from this provider,
/// i.e., wherever fortuna for this provider will be hosted.
#[arg(long = "uri")]
#[arg(default_value = "")]
pub uri: String,
}
6 changes: 0 additions & 6 deletions fortuna/src/config/setup_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ pub struct SetupProviderOptions {
#[arg(long = "pyth-contract-fee")]
#[arg(default_value = "100")]
pub fee: u128,

/// The URI where clients can retrieve random values from this provider,
/// i.e., wherever fortuna for this provider will be hosted.
#[arg(long = "uri")]
#[arg(default_value = "")]
pub uri: String,
}

impl SetupProviderOptions {
Expand Down

0 comments on commit 93566f2

Please sign in to comment.