File tree Expand file tree Collapse file tree 4 files changed +6
-25
lines changed Expand file tree Collapse file tree 4 files changed +6
-25
lines changed Original file line number Diff line number Diff line change 66
77use Bavix \Wallet \Exceptions \UnconfirmedInvalid ;
88use Bavix \Wallet \Exceptions \WalletOwnerInvalid ;
9- use Bavix \Wallet \Interfaces \Wallet ;
109use Bavix \Wallet \Internal \Exceptions \ExceptionInterface ;
1110use Bavix \Wallet \Internal \Exceptions \RecordNotFoundException ;
1211use Bavix \Wallet \Internal \Exceptions \TransactionFailedException ;
@@ -25,15 +24,6 @@ final class TransactionObserver
2524 */
2625 public function deleting (Transaction $ model ): bool
2726 {
28- return $ this ->safeResetConfirm ($ model ->wallet , $ model );
29- }
30-
31- private function safeResetConfirm (Wallet $ model , Transaction $ transaction ): bool
32- {
33- try {
34- return $ model ->resetConfirm ($ transaction );
35- } catch (UnconfirmedInvalid ) {
36- return true ;
37- }
27+ return $ model ->wallet ->safeResetConfirm ($ model );
3828 }
3929}
Original file line number Diff line number Diff line change 66
77use Bavix \Wallet \Exceptions \UnconfirmedInvalid ;
88use Bavix \Wallet \Exceptions \WalletOwnerInvalid ;
9- use Bavix \Wallet \Interfaces \Wallet ;
109use Bavix \Wallet \Internal \Exceptions \ExceptionInterface ;
1110use Bavix \Wallet \Internal \Exceptions \RecordNotFoundException ;
1211use Bavix \Wallet \Internal \Exceptions \TransactionFailedException ;
13- use Bavix \Wallet \Models \Transaction ;
1412use Bavix \Wallet \Models \Transfer ;
1513use Bavix \Wallet \Services \AtomicServiceInterface ;
1614use Illuminate \Database \RecordsNotFoundException ;
@@ -33,17 +31,8 @@ public function __construct(
3331 public function deleting (Transfer $ model ): bool
3432 {
3533 return $ this ->atomicService ->blocks ([$ model ->from , $ model ->to ], function () use ($ model ) {
36- return $ this -> safeResetConfirm ( $ model ->from , $ model ->withdraw )
37- && $ this -> safeResetConfirm ( $ model ->to , $ model ->deposit );
34+ return $ model ->from -> safeResetConfirm ( $ model ->withdraw )
35+ && $ model ->to -> safeResetConfirm ( $ model ->deposit );
3836 });
3937 }
40-
41- private function safeResetConfirm (Wallet $ model , Transaction $ transaction ): bool
42- {
43- try {
44- return $ model ->resetConfirm ($ transaction );
45- } catch (UnconfirmedInvalid ) {
46- return true ;
47- }
48- }
4938}
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ public function safeResetConfirm(Transaction $transaction): bool
9999 {
100100 try {
101101 return $ this ->resetConfirm ($ transaction );
102+ } catch (UnconfirmedInvalid ) {
103+ return true ;
102104 } catch (ExceptionInterface ) {
103105 return false ;
104106 }
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ public function testSafeUnconfirmed(): void
195195 $ transaction = $ wallet ->deposit (1000 , null , false );
196196 self ::assertSame (0 , $ wallet ->balanceInt );
197197 self ::assertFalse ($ transaction ->confirmed );
198- self ::assertFalse ($ wallet ->safeResetConfirm ($ transaction ));
198+ self ::assertTrue ($ wallet ->safeResetConfirm ($ transaction ));
199199 }
200200
201201 public function testWalletOwnerInvalid (): void
You can’t perform that action at this time.
0 commit comments