Skip to content

Commit

Permalink
Feature/address label (#44)
Browse files Browse the repository at this point in the history
* Add address label to rich list and address page

* Address label
  • Loading branch information
dantudor authored Dec 11, 2018
1 parent d6d444e commit 5332308
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Navcoin/Address/Entity/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class Address
*/
private $richListPosition;

/**
* @var null|string
*/
private $label;

/**
* Constructor
*
Expand All @@ -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;
Expand All @@ -103,6 +109,7 @@ public function __construct(
$this->balance = $balance;
$this->blockIndex = $blockIndex;
$this->richListPosition = $richListPosition;
$this->label = $label;
}

/**
Expand Down Expand Up @@ -224,4 +231,9 @@ public function getTransactions(): int
{
return $this->sentCount + $this->receivedCount + $this->stakedCount;
}

public function getLabel(): string
{
return $this->label ?: "";
}
}
3 changes: 2 additions & 1 deletion src/Navcoin/Address/Mapper/AddressMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
3 changes: 3 additions & 0 deletions templates/address/components/summary.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<td><strong>Hash</strong></td>
<td class="text-right break-word">
{{ address.hash }}
{% if address.label %}
<br><span class="badge badge-info">{{ address.label }}</span>
{% endif %}
</td>
</tr>
<tr>
Expand Down
3 changes: 3 additions & 0 deletions templates/rich_list/components/top_addresses.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<a href="{{ path('app_address_index', { 'hash': address.hash }) }}" class="break-word">
{{ address.hash }}
</a>
{% if address.label %}
<span class="badge badge-info">{{ address.label }}</span>
{% endif %}
</td>
<td>
{{ address.balance|stake_format(false, 2) }}<br/>
Expand Down

0 comments on commit 5332308

Please sign in to comment.