Skip to content

Commit

Permalink
add better error message for PDA & enforce mainnet check on url
Browse files Browse the repository at this point in the history
  • Loading branch information
ngundotra committed Dec 3, 2024
1 parent 3a0e292 commit c6b0406
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::api::models::{
VerifyResponse,
};
use crate::solana_program::get_program_pda;
use crate::{get_genesis_hash, MAINNET_GENESIS_HASH};

// URL for the remote server
pub const REMOTE_SERVER_URL: &str = "https://verify.osec.io";
Expand Down Expand Up @@ -120,6 +121,10 @@ pub async fn send_job_with_uploader_to_remote(
uploader: &Pubkey,
) -> anyhow::Result<()> {
// Check that PDA exists before sending job
let genesis_hash = get_genesis_hash(connection)?;
if genesis_hash != MAINNET_GENESIS_HASH {
return Err(anyhow!("Remote verification only works with mainnet. Please omit the --remote flag to verify locally."));
}
get_program_pda(connection, program_id, Some(uploader.to_string())).await?;

let client = Client::builder()
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ async fn main() -> anyhow::Result<()> {
)
.subcommand(SubCommand::with_name("remote")
.about("Send a command to a remote machine")
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(SubCommand::with_name("get-status")
.about("Get the verification status of a program")
.arg(Arg::with_name("program-id")
Expand Down
2 changes: 1 addition & 1 deletion src/solana_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub async fn get_program_pda(
))
} else {
Err(anyhow!(
"PDA not found for {:?} and uploader {:?}",
"PDA not found for {:?} and uploader {:?}. Make sure you've uploaded the PDA to mainnet.",
program_id,
signer_pubkey
))
Expand Down

0 comments on commit c6b0406

Please sign in to comment.