Skip to content

Commit

Permalink
fix withdraw/transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Dec 29, 2022
1 parent 3bb95fd commit f9fa790
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Traits/HasWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,16 @@ public function safeTransfer(Wallet $wallet, $amount, ?array $meta = null): ?Tra
public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
{
/** @var Wallet $this */
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
return app(AtomicServiceInterface::class)->block(
$this,
function () use ($wallet, $amount, $meta) {
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);

return $this->forceTransfer($wallet, $amount, $meta);
return app(CommonServiceLegacy::class)
->forceTransfer($this, $wallet, $amount, $meta)
;
},
);
}

/**
Expand All @@ -167,9 +174,16 @@ public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
public function withdraw($amount, ?array $meta = null, bool $confirmed = true): Transaction
{
/** @var Wallet $this */
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
return app(AtomicServiceInterface::class)->block(
$this,
function () use ($amount, $meta, $confirmed) {
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);

return $this->forceWithdraw($amount, $meta, $confirmed);
return app(CommonServiceLegacy::class)
->makeTransaction($this, Transaction::TYPE_WITHDRAW, $amount, $meta, $confirmed)
;
},
);
}

/**
Expand Down

0 comments on commit f9fa790

Please sign in to comment.