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

[docs] [sdk] Update e2e counter docs and template #20044

Merged

Conversation

dantheman8300
Copy link
Contributor

This PR fixes an issue with the e2e counter template where sometimes the data is refetched too soon after a transaction is executed.

Copy link

vercel bot commented Oct 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 1, 2024 9:47pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 9:47pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 9:47pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 9:47pm

@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label Oct 25, 2024
@dantheman8300 dantheman8300 marked this pull request as ready for review October 25, 2024 21:12
@dantheman8300 dantheman8300 requested a review from a team as a code owner October 25, 2024 21:12
@ronny-mysten
Copy link
Contributor

Dan already knows, but doc changes lg

@dantheman8300 dantheman8300 changed the title [docs] [sdk] [docs] [sdk] Update e2e counter docs and template Oct 31, 2024
</Container>
);
const { mutate: signAndExecute } = useSignAndExecuteTransaction();
const [waitingForTxn, setWaitingForTxn] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

The useSignAndExecuteTransaction already has state for this, and returns the following properties that can be used:

isIdle, isPending, isSuccess, isError, and status.

You probably want isPending

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried this. The issue is that waitingForTxn is true until after the transaction is waited for. isPending becomes false after the transaction is executed, not waited for though.

with waitingForTxn

Screen.Recording.2024-11-01.at.9.32.48.AM.mov

with isPending

Screen.Recording.2024-11-01.at.9.34.10.AM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isSuccess should work though

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 ended up using isSuccess and isPending since when I just used isSuccess, the spinner won't show after the button is pressed but before the user accepts the transaction.

if (objectId) {
onCreated(objectId);
}
onSuccess: ({ digest }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you make this an async function, and await the waitForTransaction, you should be able to uses the isPending status from the useSignAndExecuteTransaction hook, rather than tracking your own state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed. Had to use isSuccess as well as isPending. Mentioned in previous comment

Copy link
Contributor Author

@dantheman8300 dantheman8300 left a comment

Choose a reason for hiding this comment

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

Just a few things. Everything else looks good to me!

@ronny-mysten ronny-mysten temporarily deployed to sui-typescript-aws-kms-test-env November 1, 2024 21:46 — with GitHub Actions Inactive
@ronny-mysten ronny-mysten merged commit 325955b into MystenLabs:main Nov 4, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants