Skip to content

Commit 9070ddf

Browse files
committed
feat: StoreAddressIntStd() accepts nulls and empty strings (and writes two zero bytes)
1 parent ea6b93c commit 9070ddf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

TonLibDotNet.Tests/Cells/CellBuilderTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ public void WritesAddressesOk()
6464
slice.EndRead();
6565
}
6666

67+
[Fact]
68+
public void WritesEmptyAddressesOk()
69+
{
70+
var cell = new CellBuilder()
71+
.StoreAddressIntStd(string.Empty)
72+
.Build();
73+
74+
var slice = cell.BeginRead();
75+
Assert.Null(slice.TryLoadAddressIntStd());
76+
slice.EndRead();
77+
}
78+
6779
[Fact]
6880
public void WritesCoinsOk()
6981
{

TonLibDotNet/Extensions/TonClientCellsAddressExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ public static string LoadAddressIntStd(this Slice slice, bool bounceable = true,
4949
return LoadAddressIntStd(slice, bounceable, testnetOnly, urlSafe);
5050
}
5151

52-
public static CellBuilder StoreAddressIntStd(this CellBuilder builder, string address)
52+
public static CellBuilder StoreAddressIntStd(this CellBuilder builder, string? address)
5353
{
54+
if (string.IsNullOrEmpty(address))
55+
{
56+
builder.StoreBit(false);
57+
builder.StoreBit(false);
58+
return builder;
59+
}
60+
5461
if (!AddressValidator.TryParseAddress(address, out var workchainId, out var accountId, out _, out _, out _))
5562
{
5663
throw new ArgumentException("Not a valid address", nameof(address));

0 commit comments

Comments
 (0)