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

[FEATURE] Account storage alert #484

Open
lmcmz opened this issue Nov 4, 2024 · 4 comments · May be fixed by #525
Open

[FEATURE] Account storage alert #484

lmcmz opened this issue Nov 4, 2024 · 4 comments · May be fixed by #525
Assignees

Comments

@lmcmz
Copy link
Member

lmcmz commented Nov 4, 2024

Issue to be solved

Background:
Outblock/FRW#61

Suggest A Solution

Get Storage and Available Balance Info

Our script API returns getAccountInfo cadence, which allow wallet to get the storage info under an account.

access(all) struct Result {
  access(all) let address: Address
  access(all) let balance: UFix64
  access(all) let availableBalance: UFix64
  access(all) let storageUsed: UInt64
  access(all) let storageCapacity: UInt64
  access(all) let storageFlow: UFix64,
}

If storageCapacity - storageUsed < 10000 then it's insufficient storage

Notification

Currently, we use firebase remote config to control the notification messages. It use news at the moment.
For insufficient storage alert, we gonna add a new condition flag insufficientStorage, which user reach storage limit.

Onchain Interaction

Any onchain Interaction, wallet need do a async check whether the storage is sufficient or not.

If it's send Flow Token or move action ( move fee ), the balance will be affected we need take count of the sending or move fee balance. ( availableBalance - sent amount ) < 0.001
Other onchain Interaction, we only do the availableBalance check.

Following is the list of storage warning in action button:

  1. Move token
  2. Move NFT
  3. Send Token
  4. Send NFT
  5. Sign Transaction on browser
  6. Sign Transaction on WalletConnect

Transaction Listener

Every transaction submitted to the chain, the wallet will listen the callback. So when there is storageCapacityExceeded.
we need show an global alert telling user that the last transaction was failing due to storage.

Storage Usage Card

Storage info card need to be displayed only under FLOW token detail page.

Figma:
https://www.figma.com/design/mSr5uIApRJNrpkmN0YNuD6/FLOW-REF-Mobile-Design-v2.0.0?node-id=35558-33202&t=eegpA2haFKcXcypT-1

@lmcmz lmcmz moved this to Todo in Flow Wallet Nov 4, 2024
@lmcmz lmcmz added this to Flow Wallet Nov 4, 2024
@lmcmz lmcmz changed the title [FEATURE] <title> [FEATURE] Account storage alert Nov 4, 2024
@jeden
Copy link
Collaborator

jeden commented Nov 11, 2024

@lmcmz where does this 10,000 value come from?

If storageCapacity - storageUsed < 10,000 then it's insufficient storage

If 1 FLOW = 100MB, then 0.001 FLOW = 0.1MB = 100KB = 102,400 bytes. Unless that's an arbitrary value, or calculated in some other way that I am not aware of. Could you clarify?

@lmcmz
Copy link
Member Author

lmcmz commented Nov 11, 2024

Yes, you are right. Base on the average storage will use per transaction.

@jeden
Copy link
Collaborator

jeden commented Nov 11, 2024

So you mean it's an arbitrary value not depending from total and used storage, right?

What if I have to do the same calc with an additional amount (to check if the stoage is insufficient after the transaction).
The way I was calculating that is accountInfo.availableBalance.doubleValue - amount < 0.001, but not sure how to translate that in storage terms.

@lmcmz
Copy link
Member Author

lmcmz commented Nov 11, 2024

Yeah, it's very average presumption, it's 10KB = 10000 Bytes = 0.0001 FLOW.
Your equation looks right to me.

Just a reminder, if it's move action between EVM account and flow account, there is an 0.001 fixed fee.

So it will become accountInfo.availableBalance - amount - 0.001 < 0.001

@jeden jeden linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants