Skip to content
Commits on Source (7)
......@@ -50,7 +50,10 @@ class wallet implements Interfaces\Api
$offChainBalanceVal = BigNumber::_($offChainBalance->get());
$offchainAvailableVal = BigNumber::_($offChainBalance->getAvailable());
$balance = $onChainBalanceVal->add($offChainBalanceVal);
$balance = $onChainBalanceVal
? $onChainBalanceVal->add($offChainBalanceVal)
: $offChainBalanceVal;
$wireCap = Di::_()->get('Blockchain\Wallets\OffChain\Cap')
->setUser(Session::getLoggedinUser())
......
......@@ -31,6 +31,10 @@ class pro implements Interfaces\FS
$contents = $file->read();
if (!$contents) {
$this->fallback($pages);
}
header(sprintf("Content-Type: %s", $asset->getMimeType()));
header(sprintf("Expires: %s", date('r', time() + 864000)));
header('Pragma: public');
......@@ -39,4 +43,25 @@ class pro implements Interfaces\FS
echo $contents;
exit;
}
/**
* Fallback
* @param array $pages
* @return void
*/
private function fallback($pages): void
{
switch ($pages[1]) {
case "background":
$bannersFs = new banners();
$bannersFs->get([ $pages[0] ]);
exit;
break;
case "logo":
$avatarsFs = new avatars();
$avatarsFs->get([ $pages[0], 'large' ]);
exit;
break;
}
}
}
......@@ -60,6 +60,11 @@ class Balance
}
$balance = $this->token->balanceOf($address);
if ($balance === null) {
return null;
}
$this->cache->set($cacheKey, serialize($balance), 60);
return $balance;
......
......@@ -24,10 +24,16 @@ class Homepage121119 implements HypothesisInterface
return [
(new Bucket)
->setId('base')
->setWeight(50),
->setWeight(25),
(new Bucket)
->setId('form')
->setWeight(50),
->setWeight(25),
(new Bucket)
->setId('base-take-back-control')
->setWeight(25),
(new Bucket)
->setId('form-take-back-control')
->setWeight(25),
];
}
}
......@@ -327,6 +327,10 @@ class Manager
->save();
}
if (isset($values['payout_method'])) {
$settings->setPayoutMethod($values['payout_method']);
}
$settings->setTimeUpdated(time());
$this->setupRoutingDelegate
......
......@@ -101,6 +101,7 @@ class Repository
->setHasCustomLogo($data['has_custom_logo'] ?? false)
->setHasCustomBackground($data['has_custom_background'] ?? false)
->setTimeUpdated($data['time_updated'] ?? 0)
->setPayoutMethod($data['payout_method'] ?? 'usd')
;
$response[] = $settings;
......@@ -150,6 +151,7 @@ class Repository
'has_custom_logo' => $settings->hasCustomLogo(),
'has_custom_background' => $settings->hasCustomBackground(),
'time_updated' => $settings->getTimeUpdated(),
'payout_method' => $settings->getPayoutMethod(),
]),
];
......
......@@ -52,6 +52,8 @@ use Minds\Traits\MagicAttributes;
* @method Settings setHasCustomBackground(bool $customBackground)
* @method int getTimeUpdated()
* @method Settings setTimeUpdated(int $timeUpdated)
* @method string getPayoutMethod()
* @method Settings setPayoutMethod(string $method)
*/
class Settings implements JsonSerializable
{
......@@ -135,6 +137,9 @@ class Settings implements JsonSerializable
/** @var int */
protected $timeUpdated;
/** @var string */
protected $payoutMethod = 'usd';
/**
* @return string
*/
......@@ -176,6 +181,7 @@ class Settings implements JsonSerializable
'styles' => $this->buildStyles(),
'published' => $this->published,
'time_updated' => $this->timeUpdated,
'payout_method' => $this->payoutMethod,
];
}
......
......@@ -70,4 +70,26 @@ class BalanceSpec extends ObjectBehavior
$this->setUser($user);
$this->get()->shouldReturn(0);
}
public function it_should_not_store_null_values_in_cache(User $user)
{
$user->getEthWallet()
->shouldBeCalled()
->willReturn('0x123');
$this->cache->get('blockchain:balance:0x123')
->shouldBeCalled()
->willReturn(null);
$this->token->balanceOf('0x123')
->shouldBeCalled()
->willReturn(null);
$this->cache->set('blockchain:balance:0x123', null, 60)
->shouldBeCalledTimes(0);
$this->setUser($user);
$this->get()->shouldReturn(null);
}
}