-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
42 lines (35 loc) · 1.02 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Hexarc.Borsh;
namespace Namada
{
public sealed class Utils
{
public static string HexEncode(byte[] data)
{
return Convert.ToHexString(data);
}
public static byte[] HexDecode(string data)
{
return Convert.FromHexString(data);
}
public static string HexEncode(Namada.Transaction.Hash data)
{
return HexEncode(data.Value);
}
public static TValue DecodeFromBorsh<TValue>(byte[] data)
{
return BorshSerializer.Deserialize<TValue>(data);
}
public static TValue DecodeFromBorshHexStr<TValue>(string data)
{
return DecodeFromBorsh<TValue>(HexDecode(data));
}
public static byte[] EncodeWithBorsh<TValue>(TValue data)
{
return BorshSerializer.Serialize(data);
}
public static string EncodeWithBorshThenHex<TValue>(TValue data)
{
return HexEncode(EncodeWithBorsh(data));
}
}
}