Skip to content

Commit 819a3a6

Browse files
committed
+ ITonClient.OptionsInfo (saved result from InitIfNeeded)
+ ITonClient.EncodeStringAsBase64
1 parent 470e2fb commit 819a3a6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

TonLibDotNet/ITonClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace TonLibDotNet
66
{
77
public interface ITonClient
88
{
9+
OptionsInfo OptionsInfo { get; }
10+
911
Task<OptionsInfo?> InitIfNeeded();
1012

1113
Task<OptionsInfo?> Reinit();
@@ -17,6 +19,9 @@ Task<TResponse> Execute<TResponse>(RequestBase<TResponse> request)
1719

1820
long ConvertToNanoTon(decimal ton);
1921

22+
[return: NotNullIfNotNull("source")]
23+
string? EncodeStringAsBase64(string? source);
24+
2025
bool TryDecodeBase64AsString(string? source, [NotNullWhen(true)] out string? result);
2126
}
2227
}

TonLibDotNet/TonClient.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public TonClient(ILogger<TonClient> logger, Microsoft.Extensions.Options.IOption
4848
[DllImport(TonLibResolver.DllNamePlaceholder)]
4949
private static extern IntPtr tonlib_client_json_receive(IntPtr client, double timeout);
5050

51+
public OptionsInfo OptionsInfo { get; private set; }
52+
5153
public async Task<OptionsInfo?> InitIfNeeded()
5254
{
5355
if (needReinit)
@@ -86,7 +88,8 @@ public TonClient(ILogger<TonClient> logger, Microsoft.Extensions.Options.IOption
8688

8789
tonOptions.Options.Config.ConfigJson = jdoc.ToJsonString();
8890

89-
return await Execute(new Init(tonOptions.Options));
91+
OptionsInfo = await Execute(new Init(tonOptions.Options));
92+
return OptionsInfo;
9093
}
9194

9295
public Task<OptionsInfo?> Reinit()
@@ -155,6 +158,17 @@ public long ConvertToNanoTon(decimal ton)
155158
return Convert.ToInt64(ton * 1_000_000_000M);
156159
}
157160

161+
[return: NotNullIfNotNull("source")]
162+
public string? EncodeStringAsBase64(string? source)
163+
{
164+
if (string.IsNullOrEmpty(source))
165+
{
166+
return source;
167+
}
168+
169+
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(source));
170+
}
171+
158172
public bool TryDecodeBase64AsString(string? source, [NotNullWhen(true)] out string? result)
159173
{
160174
if (string.IsNullOrEmpty(source))

0 commit comments

Comments
 (0)