From 5332308e66b83cade468aaa9b732eee8437dc35e Mon Sep 17 00:00:00 2001 From: Dan Tudor Date: Tue, 11 Dec 2018 14:18:48 +0000 Subject: [PATCH] Feature/address label (#44) * Add address label to rich list and address page * Address label --- src/Navcoin/Address/Entity/Address.php | 14 +++++++++++++- src/Navcoin/Address/Mapper/AddressMapper.php | 3 ++- templates/address/components/summary.html.twig | 3 +++ .../rich_list/components/top_addresses.html.twig | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Navcoin/Address/Entity/Address.php b/src/Navcoin/Address/Entity/Address.php index 2dc5569..98b9c61 100644 --- a/src/Navcoin/Address/Entity/Address.php +++ b/src/Navcoin/Address/Entity/Address.php @@ -64,6 +64,11 @@ class Address */ private $richListPosition; + /** + * @var null|string + */ + private $label; + /** * Constructor * @@ -90,7 +95,8 @@ public function __construct( float $stakeSent, float $balance, int $blockIndex, - int $richListPosition + int $richListPosition, + ?string $label ) { $this->hash = $hash; $this->received = $received; @@ -103,6 +109,7 @@ public function __construct( $this->balance = $balance; $this->blockIndex = $blockIndex; $this->richListPosition = $richListPosition; + $this->label = $label; } /** @@ -224,4 +231,9 @@ public function getTransactions(): int { return $this->sentCount + $this->receivedCount + $this->stakedCount; } + + public function getLabel(): string + { + return $this->label ?: ""; + } } diff --git a/src/Navcoin/Address/Mapper/AddressMapper.php b/src/Navcoin/Address/Mapper/AddressMapper.php index 5a6f0a9..e67f523 100644 --- a/src/Navcoin/Address/Mapper/AddressMapper.php +++ b/src/Navcoin/Address/Mapper/AddressMapper.php @@ -50,7 +50,8 @@ public function mapEntity(array $data): Address $data['stakedSent'] / 100000000, $data['balance'] / 100000000, $data['blockIndex'], - $data['richListPosition'] + $data['richListPosition'], + array_key_exists('label', $data) ? $data['label'] : null ); } } diff --git a/templates/address/components/summary.html.twig b/templates/address/components/summary.html.twig index 6c4f097..2781f46 100644 --- a/templates/address/components/summary.html.twig +++ b/templates/address/components/summary.html.twig @@ -6,6 +6,9 @@ Hash {{ address.hash }} + {% if address.label %} +
{{ address.label }} + {% endif %} diff --git a/templates/rich_list/components/top_addresses.html.twig b/templates/rich_list/components/top_addresses.html.twig index 80d2fcf..4cb2644 100644 --- a/templates/rich_list/components/top_addresses.html.twig +++ b/templates/rich_list/components/top_addresses.html.twig @@ -19,6 +19,9 @@ {{ address.hash }} + {% if address.label %} + {{ address.label }} + {% endif %} {{ address.balance|stake_format(false, 2) }}