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

Refund if sign() failed #708

Closed
Tracked by #663
volovyks opened this issue Jul 22, 2024 · 4 comments · Fixed by #781
Closed
Tracked by #663

Refund if sign() failed #708

volovyks opened this issue Jul 22, 2024 · 4 comments · Fixed by #781
Assignees

Comments

@volovyks
Copy link
Collaborator

volovyks commented Jul 22, 2024

We need to refund the user's deposit if the sign() call fails for any reason. But let's ensure it is impossible to drain funds from our contract with bad requests.
Proposed by @gagdiez here.

@ailisp
Copy link
Member

ailisp commented Jul 30, 2024

There are three cases to consider:

  1. when the sign call fails (not the cross contract call invoked by sign), near will automatically return attached deposit back to the caller: https://docs.near.org/build/smart-contracts/anatomy/environment#attached-deposit
  2. when the sign call succeed, we should refund the difference, this is the proposal by @gagdiez
  3. when the sign call success, but the cross contract call invoked by sign, i.e., sign_helper, clear_state_on_finish, return_signature_on_finish fails, we should refund the remaining over required_deposit

@ailisp ailisp moved this from Backlog to In Progress in Emerging Technologies Jul 30, 2024
@volovyks
Copy link
Collaborator Author

@ailisp

  1. Ok
  2. Agree
  3. Why not all? It is not the user's fault that one of our functions failed.

@volovyks
Copy link
Collaborator Author

@volovyks
Copy link
Collaborator Author

We will push back with near/transfer#40 for now.

@volovyks volovyks linked a pull request Jul 31, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from In Progress to Done in Emerging Technologies Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants