using System.Collections.Generic;
namespace Decentralized.Domain
{
/// 资产的性质。新增币种只是往 里加一条。
public sealed class AssetSpec
{
public string Id;
/// 挂钩 1 信用点的稳定币。
public bool Stable;
/// 发行方可以冻结地址(CRC;CRT 只在镇压期间)。
public bool Freezable;
/// 链上可追踪:污点随币传播。Ponero 为 false,换入时污点停止传播。
public bool Traceable = true;
/// 合规交易所可以上架。
public bool Compliant = true;
/// 程序生成或玩家发行的代币。
public bool Issued;
}
/// 资产登记。信用点(游戏现金)不在链上,不登记。
public static class Assets
{
public const string PSC = "PSC";
public const string CRC = "CRC";
public const string CRT = "CRT";
public const string CRA = "CRA";
public const string SPARK = "SPARK";
public const string Ponero = "PONERO";
private static readonly Dictionary Table = new Dictionary();
static Assets()
{
Register(new AssetSpec { Id = PSC });
Register(new AssetSpec { Id = CRC, Stable = true, Freezable = true });
Register(new AssetSpec { Id = CRT, Stable = true, Freezable = true });
Register(new AssetSpec { Id = CRA, Stable = true });
Register(new AssetSpec { Id = SPARK });
Register(new AssetSpec { Id = Ponero, Traceable = false, Compliant = false });
}
public static void Register(AssetSpec spec) => Table[spec.Id] = spec;
public static bool TryGet(string id, out AssetSpec spec) => Table.TryGetValue(id, out spec);
public static AssetSpec Get(string id) => Table.TryGetValue(id, out var s) ? s : null;
public static IEnumerable All => Table.Values;
}
}