Skip to content

Commit f9fa790

Browse files
committed
fix withdraw/transfer
1 parent 3bb95fd commit f9fa790

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/Traits/HasWallet.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,16 @@ public function safeTransfer(Wallet $wallet, $amount, ?array $meta = null): ?Tra
146146
public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
147147
{
148148
/** @var Wallet $this */
149-
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
149+
return app(AtomicServiceInterface::class)->block(
150+
$this,
151+
function () use ($wallet, $amount, $meta) {
152+
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
150153

151-
return $this->forceTransfer($wallet, $amount, $meta);
154+
return app(CommonServiceLegacy::class)
155+
->forceTransfer($this, $wallet, $amount, $meta)
156+
;
157+
},
158+
);
152159
}
153160

154161
/**
@@ -167,9 +174,16 @@ public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
167174
public function withdraw($amount, ?array $meta = null, bool $confirmed = true): Transaction
168175
{
169176
/** @var Wallet $this */
170-
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
177+
return app(AtomicServiceInterface::class)->block(
178+
$this,
179+
function () use ($amount, $meta, $confirmed) {
180+
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
171181

172-
return $this->forceWithdraw($amount, $meta, $confirmed);
182+
return app(CommonServiceLegacy::class)
183+
->makeTransaction($this, Transaction::TYPE_WITHDRAW, $amount, $meta, $confirmed)
184+
;
185+
},
186+
);
173187
}
174188

175189
/**

0 commit comments

Comments
 (0)