Skip to content

Commit 77a6bc1

Browse files
committed
fix withdraw/transfer
1 parent 6f8640e commit 77a6bc1

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
},
8585
"config": {
8686
"process-timeout":0,
87-
"sort-packages": true
87+
"sort-packages": true,
88+
"allow-plugins": {
89+
"infection/extension-installer": true
90+
}
8891
}
8992
}

src/Traits/HasWallet.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,16 @@ public function safeTransfer(Wallet $wallet, $amount, ?array $meta = null): ?Tra
128128
public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
129129
{
130130
/** @var Wallet $this */
131-
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
131+
return app(AtomicServiceInterface::class)->block(
132+
$this,
133+
function () use ($wallet, $amount, $meta) {
134+
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
132135

133-
return $this->forceTransfer($wallet, $amount, $meta);
136+
return app(CommonServiceLegacy::class)
137+
->forceTransfer($this, $wallet, $amount, $meta)
138+
;
139+
},
140+
);
134141
}
135142

136143
/**
@@ -149,9 +156,16 @@ public function transfer(Wallet $wallet, $amount, ?array $meta = null): Transfer
149156
public function withdraw($amount, ?array $meta = null, bool $confirmed = true): Transaction
150157
{
151158
/** @var Wallet $this */
152-
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
159+
return app(AtomicServiceInterface::class)->block(
160+
$this,
161+
function () use ($amount, $meta, $confirmed) {
162+
app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
153163

154-
return $this->forceWithdraw($amount, $meta, $confirmed);
164+
return app(CommonServiceLegacy::class)
165+
->makeTransaction($this, Transaction::TYPE_WITHDRAW, $amount, $meta, $confirmed)
166+
;
167+
},
168+
);
155169
}
156170

157171
/**

0 commit comments

Comments
 (0)