Meshbits / pirate-chain-ios-wallet

iOS version of the Pirate Wallet
MIT License
3 stars 2 forks source link

Adjust sending transaction amount based on wallet balance #30

Closed satindergrewal closed 2 years ago

satindergrewal commented 2 years ago

User had 1.00 ARRR in wallet. Sent a transaction which errored because wallet tried sending amount + fee (1.00 + 0.0001) which is 1.0001 ARRR.

In such case if it's found that user doesn't has the fee amount to create this transaction the transaction MUST be adjusted accordingly.

In this case, it'll be: 1 ARRR wallet balance - 0.0001 tx fee = 0.9999 ARRR

So, let the user show a dialog box confirming these adjustment with a message:

We found your wallet didn't had enough funds for fees, so the transaction has been adjusted as follows:
Wallet Balance: 1 ARRR
Transaction Fess: 0.0001 ARRR

The receiver <ADDRESS_HERE> will be receiving 0.9999 ARRR.
Please CONFIRM to send this transaction or cancel to adjust sending amount.
lastw0nd3r commented 2 years ago

Implemented this flow, and also connected the confirm transaction UI to this. Simulator Screen Shot - iPhone 12 mini - 2021-10-23 at 16 47 53

Simulator Screen Shot - iPhone 12 mini - 2021-10-23 at 16 48 02