mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 12:08:32 +00:00
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using System.Globalization;
|
|
using NftFaucetRadzen.Components;
|
|
using NftFaucetRadzen.Components.CardList;
|
|
using NftFaucetRadzen.Plugins.NetworkPlugins;
|
|
using Radzen;
|
|
|
|
namespace NftFaucetRadzen.Pages;
|
|
|
|
public partial class ContractsPage : BasicComponent
|
|
{
|
|
protected override void OnInitialized()
|
|
{
|
|
Contracts = AppState.SelectedNetwork?.DeployedContracts?.ToArray() ?? Array.Empty<IContract>();
|
|
RefreshCards();
|
|
}
|
|
|
|
private IContract[] Contracts { get; set; }
|
|
private CardListItem[] ContractCards { get; set; }
|
|
|
|
private void RefreshCards()
|
|
{
|
|
ContractCards = Contracts.Select(MapCardListItem).ToArray();
|
|
}
|
|
|
|
private CardListItem MapCardListItem(IContract contract)
|
|
=> new CardListItem
|
|
{
|
|
Id = contract.Id,
|
|
Header = contract.Name,
|
|
Properties = new[]
|
|
{
|
|
new CardListItemProperty
|
|
{
|
|
Name = "Symbol",
|
|
Value = contract.Symbol,
|
|
},
|
|
new CardListItemProperty
|
|
{
|
|
Name = "Address",
|
|
Value = contract.Address,
|
|
},
|
|
new CardListItemProperty
|
|
{
|
|
Name = "TxHash",
|
|
Value = contract.DeploymentTxHash ?? "<unknown>",
|
|
},
|
|
new CardListItemProperty
|
|
{
|
|
Name = "DeployedAt",
|
|
Value = contract.DeployedAt?.ToString(CultureInfo.InvariantCulture) ?? "<unknown>",
|
|
},
|
|
},
|
|
Badges = new[]
|
|
{
|
|
contract.IsVerified
|
|
? new CardListItemBadge {Style = BadgeStyle.Success, Text = "Verified"}
|
|
: null,
|
|
new CardListItemBadge {Style = BadgeStyle.Light, Text = contract.Type.ToString()},
|
|
}.Where(x => x != null).ToArray(),
|
|
};
|
|
}
|