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

feat: support onCancel #122

Merged
merged 1 commit into from May 25, 2021
Merged

feat: support onCancel #122

merged 1 commit into from May 25, 2021

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented May 17, 2021

Description

This PR adds an onCancel callback function to a transaction. It also adds a boolean on the tx payload to check if the callback function should be run.

Ex. onCancel will be called when a user closes/cancels a transaction window.

stacks-web-wallet:
Issue: leather-wallet/extension#959
PR: leather-wallet/extension#1175

Type of Change

  • New feature
  • Bug fix
  • API reference/documentation update
  • Other

Does this introduce a breaking change?

No.

Are documentation updates required?

No.

Testing information

TBD.

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • yarn lerna run test passes
  • Changelog is updated
  • Tag 1 of @hstove or @kyranjamie or @aulneau for review

@changeset-bot
Copy link

changeset-bot bot commented May 17, 2021

🦋 Changeset detected

Latest commit: 456b2bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@stacks/connect Minor
@stacks/connect-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 106 to 108
if (data.cancel) {
options.onCancel?.();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation works, altering the value of what data and conditionally handling whether the cancel prop is there.

Given we're handling success/fail states, however, maybe we could consider cancel the error state of a the promise?

packages/connect/src/transactions/index.ts Show resolved Hide resolved
@markmhendrickson
Copy link
Contributor

Please add all PRs under review to the Kanban board so we can track them more effectively 🙏

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants