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

Payments with balance #768

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Conversation

volovyks
Copy link
Collaborator

No description provided.

@volovyks volovyks linked an issue Jul 30, 2024 that may be closed by this pull request
// withdraw the signature fee
mpc_contract
.balances
.withdraw(&request.account_id, request.signature_fee);
Copy link

Choose a reason for hiding this comment

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

@volovyks the recommended pattern for handling balances is:

  • withdraw on request
  • refund on error

Otherwise, you could get a lot of requests, which you approve since the user has the balance, and then discover during the response that the user actually has no money to pay for them all

So in this case, we would want to use balances.withdraw on sign, and return_signature would refund the user if they never got the signature because of a response timeout

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is true. We can fail in multiple places, so this design seemed simpler and more robust.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will come back to it if we will choose this direction.

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.

Alternative sign() payment design
2 participants