From 3c50551ce62820a408ba8f18b707d1fd1127b469 Mon Sep 17 00:00:00 2001 From: Don Hardman Date: Thu, 8 Jul 2021 18:22:23 +0700 Subject: [PATCH] Fix issue when buying byself and watermark in preview mode --- src/CreatorCoin.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/CreatorCoin.php b/src/CreatorCoin.php index 3d3ec5f..7e19338 100644 --- a/src/CreatorCoin.php +++ b/src/CreatorCoin.php @@ -144,12 +144,14 @@ public function buy(int $amount, bool $preview = false): static { $reward = ['amount' => $reward_amount, 'coin' => 0]; $watermark = max($this->supply, $this->watermark); - if ($this->strategy === 'watermark' && $watermark > $this->watermark) { + if ($this->strategy === 'watermark' && !$this->is_creator && $watermark > $this->watermark) { $reward['coin'] = intval((($watermark - $this->watermark) * $this->reward) / (100 * 100)); } - $this->watermark = $watermark; + if (!$preview) { + $this->watermark = $watermark; + } - if ($this->strategy === 'minting') { + if ($this->strategy === 'minting' && !$this->is_creator) { $reward['coin'] = intval(($minted * $this->reward) / (100 * 100)); } $received = $this->is_creator ? $minted : intval($minted - $reward['coin']);