From e2c32233f4653dd77006d3b20ef5f8cd093d1b52 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 18 Feb 2024 17:30:21 +0200 Subject: [PATCH] add accountBalance filter --- src/Twig/AppExtension.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index ea43d34..db4235a 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -52,6 +52,13 @@ class AppExtension extends AbstractExtension 'formatKVA' ] ), + new TwigFilter( + 'account_balance', + [ + $this, + 'accountBalance' + ] + ), new TwigFilter( 'message_to_markdown', [ @@ -270,6 +277,24 @@ class AppExtension extends AbstractExtension ); } + public function accountBalance( + string $account + ): ?float + { + // Connect kevacoin + $client = new \Kevachat\Kevacoin\Client( + $this->container->getParameter('app.kevacoin.protocol'), + $this->container->getParameter('app.kevacoin.host'), + $this->container->getParameter('app.kevacoin.port'), + $this->container->getParameter('app.kevacoin.username'), + $this->container->getParameter('app.kevacoin.password') + ); + + return $client->getAccountAddress( + $account + ); + } + public function messageToMarkdown( string $text ): string