Skip to content

Commit

Permalink
chore: add one retry condition
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Nov 29, 2024
1 parent 0f28ebd commit 64a7323
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/contract/src/contract-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export default class ContractFactory<TContract extends Contract = Contract> {
// Deploy the chunks as blob txs
for (const { blobId, transactionRequest } of chunks) {
if (!uploadedBlobs.includes(blobId) && blobIdsToUpload.includes(blobId)) {
const fundedBlobRequest = await this.fundTransactionRequest(
let fundedBlobRequest = await this.fundTransactionRequest(
transactionRequest,
deployOptions
);
Expand All @@ -368,6 +368,18 @@ export default class ContractFactory<TContract extends Contract = Contract> {
if ((<Error>err).message.indexOf(`BlobId is already taken ${blobId}`) > -1) {
uploadedBlobs.push(blobId);
continue;
} else if ((<Error>err).message.indexOf('InsufficientMaxFee') > -1) {
const newMaxFee = fundedBlobRequest.maxFee.mul(1.5);
if (newMaxFee.gt(balance)) {
throw new FuelError(
ErrorCode.FUNDS_TOO_LOW,
'Insufficient balance to deploy contract.'
);
}
fundedBlobRequest = await this.fundTransactionRequest(
new BlobTransactionRequest({ ...transactionRequest, maxFee: newMaxFee }),
deployOptions
);
}

throw new FuelError(ErrorCode.TRANSACTION_FAILED, 'Failed to deploy contract chunk');
Expand Down

0 comments on commit 64a7323

Please sign in to comment.