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

Contract Spec: add download Wasm button + handle network error for better UX #1267

Open
wants to merge 5 commits into
base: sc-contract-spec
Choose a base branch
from

Conversation

quietbits
Copy link
Contributor

@quietbits quietbits commented Mar 6, 2025

Download WASM button

image

Warning when there is a network error

image

Comment on lines +81 to +89
useEffect(() => {
if (wasmBinaryError) {
// Automatically clear error message after 5 sec
delayedAction({
action: resetWasmBlob,
delay: 5000,
});
}
}, [resetWasmBlob, wasmBinaryError]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a way to clear this on specific events (unmount, inActive, etc.), so I opted to clear the message after 5 seconds. The UX seemed okay to me.

@stellar-jenkins
Copy link

@@ -15,13 +16,12 @@ export const useSEContractInfo = ({
const query = useQuery<ContractInfoApiResponse>({
queryKey: ["useSEContractInfo", networkId, contractId],
queryFn: async () => {
// Not supported networks
if (["futurenet", "custom"].includes(networkId)) {
const network = getStellarExpertNetwork(networkId);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small refactor to use a helper since we have this check in multiple places.

@stellar-jenkins
Copy link

@quietbits quietbits requested a review from jeesunikim March 6, 2025 15:20
@janewang
Copy link
Contributor

janewang commented Mar 6, 2025

Hi @quietbits What do you think having a download button also for contract spec and be able to download into a json file?
Screenshot 2025-03-06 at 10 24 00 AM

Also I realized there is not a really good docs on contract spec in dev docs. I will write one by EOW.

});
}, [networkId, queryClient, wasmHash]);

useEffect(() => {
Copy link
Contributor

@jeesunikim jeesunikim Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this onClick instead of lifecycle? like we already do with downloadFile in onClick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The click triggers React Query to download the wasm binary, so we need to do something after this step happens. The other option would be to put this inside the React Query, but that would limit the usage of that query to just this.

I'm not a huge fan of this approach, but I couldn't come up with something better. I'm open to suggestions! 🙏

@stellar-jenkins
Copy link

@quietbits quietbits requested a review from jeesunikim March 6, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

Successfully merging this pull request may close these issues.

Contract Spec: add download Wasm button + handle network error for better UX
4 participants