Skip to content

Commit

Permalink
feat: use blob_exists endpoint before uploading contract blob
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3e committed Jan 14, 2025
1 parent 19d32bc commit 8875ab6
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/fuels-programs/src/contract/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ impl Contract<Loader<BlobsNotUploaded>> {
continue;
}

if provider.blob_exists(id).await? {
already_uploaded.insert(id);
continue;
}

let mut tb = BlobTransactionBuilder::default()
.with_blob(blob)
.with_tx_policies(tx_policies)
Expand All @@ -141,20 +146,7 @@ impl Contract<Loader<BlobsNotUploaded>> {
let tx = tb.build(provider).await?;

let tx_status_response = provider.send_transaction_and_await_commit(tx).await;

match tx_status_response {
Ok(tx_status_response) => {
tx_status_response.check(None)?;
}
Err(err) => {
if !err
.to_string()
.contains("Execution error: BlobIdAlreadyUploaded")
{
return Err(err);
}
}
}
tx_status_response.and_then(|response| response.check(None))?;

already_uploaded.insert(id);
}
Expand Down

0 comments on commit 8875ab6

Please sign in to comment.