Skip to content

Commit

Permalink
Merge pull request #2351 from joske/fix/network-version-match
Browse files Browse the repository at this point in the history
fix: don't use 3 for mainnet
  • Loading branch information
howardwu authored Feb 12, 2024
2 parents 5daa1ab + b4abfd3 commit 276597b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ledger/query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
match self {
Self::VM(block_store) => Ok(block_store.current_state_root()),
Self::REST(url) => match N::ID {
3 => Ok(Self::get_request(&format!("{url}/mainnet/latest/stateRoot"))?.into_json()?),
console::network::MainnetV0::ID => {
Ok(Self::get_request(&format!("{url}/mainnet/latest/stateRoot"))?.into_json()?)
}
_ => bail!("Unsupported network ID in inclusion query"),
},
}
Expand All @@ -78,7 +80,9 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
match self {
Self::VM(block_store) => Ok(block_store.current_state_root()),
Self::REST(url) => match N::ID {
3 => Ok(Self::get_request_async(&format!("{url}/mainnet/latest/stateRoot")).await?.json().await?),
console::network::MainnetV0::ID => {
Ok(Self::get_request_async(&format!("{url}/mainnet/latest/stateRoot")).await?.json().await?)
}
_ => bail!("Unsupported network ID in inclusion query"),
},
}
Expand All @@ -89,7 +93,9 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
match self {
Self::VM(block_store) => block_store.get_state_path_for_commitment(commitment),
Self::REST(url) => match N::ID {
3 => Ok(Self::get_request(&format!("{url}/mainnet/statePath/{commitment}"))?.into_json()?),
console::network::MainnetV0::ID => {
Ok(Self::get_request(&format!("{url}/mainnet/statePath/{commitment}"))?.into_json()?)
}
_ => bail!("Unsupported network ID in inclusion query"),
},
}
Expand All @@ -101,7 +107,7 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
match self {
Self::VM(block_store) => block_store.get_state_path_for_commitment(commitment),
Self::REST(url) => match N::ID {
3 => {
console::network::MainnetV0::ID => {
Ok(Self::get_request_async(&format!("{url}/mainnet/statePath/{commitment}")).await?.json().await?)
}
_ => bail!("Unsupported network ID in inclusion query"),
Expand All @@ -118,7 +124,9 @@ impl<N: Network, B: BlockStorage<N>> Query<N, B> {
block_store.get_program(program_id)?.ok_or_else(|| anyhow!("Program {program_id} not found in storage"))
}
Self::REST(url) => match N::ID {
3 => Ok(Self::get_request(&format!("{url}/mainnet/program/{program_id}"))?.into_json()?),
console::network::MainnetV0::ID => {
Ok(Self::get_request(&format!("{url}/mainnet/program/{program_id}"))?.into_json()?)
}
_ => bail!("Unsupported network ID in inclusion query"),
},
}
Expand All @@ -132,7 +140,9 @@ impl<N: Network, B: BlockStorage<N>> Query<N, B> {
block_store.get_program(program_id)?.ok_or_else(|| anyhow!("Program {program_id} not found in storage"))
}
Self::REST(url) => match N::ID {
3 => Ok(Self::get_request_async(&format!("{url}/mainnet/program/{program_id}")).await?.json().await?),
console::network::MainnetV0::ID => {
Ok(Self::get_request_async(&format!("{url}/mainnet/program/{program_id}")).await?.json().await?)
}
_ => bail!("Unsupported network ID in inclusion query"),
},
}
Expand Down

0 comments on commit 276597b

Please sign in to comment.