File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
target_chains/near/receiver/src Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -589,7 +589,7 @@ impl Pyth {
589
589
/// Checks storage usage invariants and additionally refunds the caller if they overpay.
590
590
fn refund_storage_usage (
591
591
& self ,
592
- refunder : AccountId ,
592
+ recipient : AccountId ,
593
593
before : StorageUsage ,
594
594
after : StorageUsage ,
595
595
deposit : Balance ,
@@ -606,13 +606,15 @@ impl Pyth {
606
606
607
607
// Otherwise we refund whatever is left over.
608
608
if deposit - cost > 0 {
609
- Promise :: new ( refunder ) . transfer ( cost) ;
609
+ Promise :: new ( recipient ) . transfer ( deposit - cost) ;
610
610
}
611
611
} else {
612
- // Handle storage decrease if checked_sub fails. We know storage used now is <=
612
+ // If checked_sub fails we have a storage decrease, we want to refund them the cost of
613
+ // the amount reduced, as well the original deposit they sent.
613
614
let refund = Balance :: from ( before - after) ;
614
615
let refund = refund * env:: storage_byte_cost ( ) ;
615
- Promise :: new ( refunder) . transfer ( refund) ;
616
+ let refund = refund + deposit;
617
+ Promise :: new ( recipient) . transfer ( refund) ;
616
618
}
617
619
618
620
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments