-
Notifications
You must be signed in to change notification settings - Fork 102
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
base: sc-contract-spec
Are you sure you want to change the base?
Conversation
useEffect(() => { | ||
if (wasmBinaryError) { | ||
// Automatically clear error message after 5 sec | ||
delayedAction({ | ||
action: resetWasmBlob, | ||
delay: 5000, | ||
}); | ||
} | ||
}, [resetWasmBlob, wasmBinaryError]); |
There was a problem hiding this comment.
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.
Preview is available here: |
@@ -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); |
There was a problem hiding this comment.
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.
Preview is available here: |
Hi @quietbits What do you think having a download button also for contract spec and be able to download into a json file? 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(() => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! 🙏
Preview is available here: |
Download WASM button
Warning when there is a network error