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

Update retry logic to handle network congestion. #250

Merged
merged 7 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ release:
uri: ./media/release_icon.png
- purpose: screenshot
uri: ./media/app_screenshot.png
- purpose: screenshot
uri: ./media/app_screenshot1.png
- purpose: screenshot
uri: ./media/app_screenshot2.png
files:
- purpose: install
uri: ./files/app-debug.apk
Expand All @@ -37,7 +41,4 @@ release:
saga_features: Some information about saga specific features
solana_mobile_dapp_publisher_portal:
google_store_package: com.company.dapp.otherpkg
testing_instructions: >-
Here are some steps informing Solana Mobile of how to test this dapp. You
can specify multiple lines of instructions. For example, if a login is
needed, you would add those details here.
testing_instructions: Here are some steps informing Solana Mobile of how to test this dapp. You can specify multiple lines of instructions. For example, if a login is needed, you would add those details here.
Binary file added example/media/app_screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/media/app_screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion packages/cli/src/CliSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function resolveBuildToolsPath(buildToolsPath: string | undefined) {
function latestReleaseMessage() {
showMessage(
`Publishing Tools Version ${ Constants.CLI_VERSION }`,
"- short_description value reduced to 30 character limit",
"- priority fee has been updated to handle network congestion\n- short_description value reduced to 30 character limit",
"warning"
);
}
Expand Down Expand Up @@ -108,6 +108,7 @@ export const createPublisherCliCmd = createCliCmd

showMessage("Success", resultText);
}
process.exit()
});
});

Expand Down Expand Up @@ -151,6 +152,7 @@ export const createAppCliCmd = createCliCmd

showMessage("Success", resultText);
}
process.exit()
});
});

Expand Down Expand Up @@ -203,6 +205,7 @@ export const createReleaseCliCmd = createCliCmd

showMessage("Success", resultText);
}
process.exit()
});
}
);
Expand Down Expand Up @@ -235,6 +238,7 @@ mainCli
buildToolsPath: resolvedBuildToolsPath,
});
}
process.exit()
});
});

Expand Down Expand Up @@ -307,6 +311,7 @@ publishCommand
const resultText = "Successfully submitted to the Solana Mobile dApp publisher portal";
showMessage("Success", resultText);
}
process.exit()
});
}
);
Expand Down Expand Up @@ -380,6 +385,7 @@ publishCommand
showMessage("Success", resultText);
}
});
process.exit()
}
);

Expand Down Expand Up @@ -445,6 +451,7 @@ publishCommand
const resultText = "dApp successfully removed from the publisher portal";
showMessage("Success", resultText);
}
process.exit()
})
}
);
Expand Down Expand Up @@ -505,6 +512,7 @@ publishCommand
const resultText = "Support request sent successfully";
showMessage("Success", resultText);
}
process.exit()
});
}
);
45 changes: 29 additions & 16 deletions packages/cli/src/commands/create/CreateCliRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@solana/web3.js";
import {
getMetaplexInstance,
showMessage
} from "../../CliUtils.js";
import { loadPublishDetailsWithChecks, writeToPublishDetails } from "../../config/PublishDetails.js";

Expand Down Expand Up @@ -56,22 +57,34 @@ const createReleaseNft = async ({
{ metaplex, publisher }
);

const blockhash = await connection.getLatestBlockhashAndContext();
const tx = txBuilder.toTransaction(blockhash.value);
tx.sign(releaseMintAddress, publisher);

const txSig = await sendAndConfirmTransaction(connection, tx, [
publisher,
releaseMintAddress,
], {
minContextSlot: blockhash.context.slot
});
console.info({
txSig,
releaseMintAddress: releaseMintAddress.publicKey.toBase58(),
});

return { releaseAddress: releaseMintAddress.publicKey.toBase58() };
const maxTries = 4;
for (let i = 1; i <= maxTries; i++) {
try {
const blockhash = await connection.getLatestBlockhashAndContext();
const tx = txBuilder.toTransaction(blockhash.value);
tx.sign(releaseMintAddress, publisher);
const txSig = await sendAndConfirmTransaction(connection, tx, [
publisher,
releaseMintAddress,
], {
minContextSlot: blockhash.context.slot,
});
console.info({
txSig,
releaseMintAddress: releaseMintAddress.publicKey.toBase58(),
});
return { releaseAddress: releaseMintAddress.publicKey.toBase58() };
} catch (e) {
const errorMsg = (e as Error | null)?.message ?? "";
if (i == maxTries) {
showMessage("Transaction Failure", errorMsg, "error");
process.exit(-1)
} else {
const retryMsg = errorMsg + "\nWill Retry minting release"
showMessage("Transaction Failure", retryMsg, "standard");
}
}
}
};

export const createReleaseCommand = async ({
Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/CoreUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,18 @@ export const mintNft = async (
});

txBuilder.prepend({
instruction: ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 5000,
}),
signers: [],
});
instruction: ComputeBudgetProgram.setComputeUnitLimit({
units: 250000,
}),
signers: [],
});

txBuilder.prepend({
instruction: ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 2000000,
}),
signers: [],
});

return txBuilder;
};
Loading