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

storage_withdraw is not refunding storage balance #46

Closed
andy-haynes opened this issue Jul 23, 2024 · 2 comments · Fixed by #48
Closed

storage_withdraw is not refunding storage balance #46

andy-haynes opened this issue Jul 23, 2024 · 2 comments · Fixed by #48

Comments

@andy-haynes
Copy link
Contributor

I’m not getting refunded after calling storage_withdraw but I can’t tell where things are going wrong :thinking_face:

When deploying, I call storage_deposit on the file contract. When deleting the app, I delete storage to the point where the available balance is nearly equal to the total:

withdrawing balance {
  'gornt.testnet balance': '105.677779',
  'pfs1.testnet balance': '131.932608',
  'pfs1.testnet storage balance for gornt.testnet': '3.36484/3.36694'
}

Then I call storage_withdraw and see that only a fraction of the available balance (0.18665N vs ~3.6N) is refunded. After this call, the deployer account actually loses Near instead of getting the original storage refunded:

balance withdrawn {
  'gornt.testnet balance': '105.676335',
  'gornt.testnet balance diff': '-0.001444',
  'pfs1.testnet balance': '131.933006',
  'pfs1.testnet balance diff': '0.000397',
  'pfs1.testnet storage balance for gornt.testnet': '0/0.0021'
}

Nothing sticks out as problematic in the method source, though it is worth mentioning I added a null check so that passing a null amount refunds the available funds. However, I was seeing the same behavior when specifying the amount when calling.

I think the key is understanding why storage_withdraw refunded 0.18665N; the transaction clearly went through but why is that the amount being refunded when the ~3.6 was being correctly deducted from the balance?

@mpeterdev
Copy link
Collaborator

NearPromise instances must either be returned or have .build() called to execute. For now, we will use .build() since we must return the appropriate data for the StorageManagement NEP

@mpeterdev
Copy link
Collaborator

follow up in #47

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 a pull request may close this issue.

2 participants