File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
libs/ledger-live-common/src/families/filecoin/bridge Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @ledgerhq/live-common " : major
3
+ ---
4
+
5
+ fix useAllAmount usage when fees are higher than balance
Original file line number Diff line number Diff line change @@ -82,12 +82,19 @@ const getTransactionStatus = async (
82
82
// This is the worst case scenario (the tx won't cost more than this value)
83
83
const estimatedFees = calculateEstimatedFees ( gasFeeCap , gasLimit ) ;
84
84
85
- const totalSpent = useAllAmount ? balance : amount . plus ( estimatedFees ) ;
86
- if ( totalSpent . gt ( a . spendableBalance ) ) {
87
- errors . amount = new NotEnoughBalance ( ) ;
85
+ let totalSpent ;
86
+ if ( useAllAmount ) {
87
+ totalSpent = a . spendableBalance ;
88
+ amount = totalSpent . minus ( estimatedFees ) ;
89
+ if ( amount . lte ( 0 ) || totalSpent . gt ( balance ) ) {
90
+ errors . amount = new NotEnoughBalance ( ) ;
91
+ }
88
92
} else {
89
- amount = useAllAmount ? balance . minus ( estimatedFees ) : amount ;
90
- if ( amount . lte ( 0 ) ) errors . amount = new AmountRequired ( ) ;
93
+ totalSpent = amount . plus ( estimatedFees ) ;
94
+ if ( amount . eq ( 0 ) ) {
95
+ errors . amount = new AmountRequired ( ) ;
96
+ } else if ( totalSpent . gt ( a . spendableBalance ) )
97
+ errors . amount = new NotEnoughBalance ( ) ;
91
98
}
92
99
93
100
// log("debug", "[getTransactionStatus] finish fn");
You can’t perform that action at this time.
0 commit comments