Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use blob_exists endpoint before uploading contract blob #1573

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading