Skip to content

Commit 5e8fe13

Browse files
committed
Update emulation to use Traces API and improve fee checks
Switched transaction emulation from Wallet to Traces API in code and docs. Standardized BOC variable naming. Changed fee access to use GetTotalFees(). Added test assertions to verify emulation success and fee presence.
1 parent 94e48de commit 5e8fe13

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ var messageHash = WalletV5R1Utils.NormalizeHash(externalMsg).ToHex();
313313
var boc = Convert.ToBase64String(Builder.BeginCell().StoreMessage(externalMsg).EndCell().ToBoc());
314314

315315
// Emulate before sending (optional)
316-
var consequences = await client.Wallet.EmulateAsync(boc);
317-
Console.WriteLine($"Estimated fee: {consequences.Event.Fee.Total}");
316+
var consequences = await Client.Traces.EmulateAsync(bocAsString);
317+
Console.WriteLine($"Estimated fee: {consequences.GetTotalFees()}");
318318

319319
// Send transaction
320320
await client.Blockchain.SendBocAsync(boc: boc);

README_RU.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ var messageHash = WalletV5R1Utils.NormalizeHash(externalMsg).ToHex();
313313
var boc = Convert.ToBase64String(Builder.BeginCell().StoreMessage(externalMsg).EndCell().ToBoc());
314314

315315
// Emulate before sending (optional)
316-
var consequences = await client.Wallet.EmulateAsync(boc);
317-
Console.WriteLine($"Estimated fee: {consequences.Event.Fee.Total}");
316+
var consequences = await Client.Traces.EmulateAsync(bocAsString);
317+
Console.WriteLine($"Estimated fee: {consequences.GetTotalFees()}");
318318

319319
// Send transaction
320320
await client.Blockchain.SendBocAsync(boc: boc);

src/TonapiClient.Tests/TracesCategoryTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ public async Task TransferTests()
393393
.EndCell();
394394
byte[] boc = messageCell.ToBoc();
395395
var bocAsString = Convert.ToBase64String(boc);
396+
var consequences = await Client.Traces.EmulateAsync(bocAsString);
397+
Assert.True(!consequences.HasUnsuccessfulTransactions(), "Emulated transaction should be successful");
398+
Assert.True(consequences.GetTotalFees() > 0, "Emulated transaction should have fees");
399+
396400
// await Client.LiteServer.SendMessageAsync(Convert.ToBase64String(boc));
397401
await Client.Blockchain.SendBocAsync(bocAsString);
398402
try

0 commit comments

Comments
 (0)