Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions TonSdk.Client/src/Client/ITonClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public interface ITonClient
Task<TransactionsInformationResult[]> GetTransactions(Address address, uint limit = 10,
ulong? lt = null, string hash = null, ulong? to_lt = null, bool? archival = null);

/// <summary>
/// Retrieves transaction information for the specified parameters.
/// </summary>
/// <param name="msgHash">Message hash of transaction.</param>
/// <param name="bodyHash">Body hash of transaction.</param>
/// <param name="opcode">Opcode of message in hex or signed 32-bit decimal form.</param>
/// <param name="direction">Direction of message.</param>
/// <param name="offset">Skip first N rows. Use with limit to batch read.</param>
/// <param name="count">Limit number of queried rows. Use with offset to batch read.</param>
/// <returns>An array of transaction information results.</returns>
Task<TransactionsInformationResultExtended[]> GetTransactionsByMessage(string msgHash = null, string bodyHash = null, string opcode = null, MessageDirection? direction = null, int? offset = null, int? count = 10);

/// <summary>
/// Executes a specific method on the specified address.
/// </summary>
Expand Down Expand Up @@ -150,5 +162,12 @@ Task<TransactionsInformationResult[]> GetTransactions(Address address, uint limi
/// <param name="message">The message for which you need to calculate the fees</param>
/// <returns>The result of estimation fees.</returns>
Task<IEstimateFeeResult> EstimateFee(MessageX message, bool ignoreChksig = true);

/// <summary>
/// Sends a Bag of Cells (BoC) to the network.
/// </summary>
/// <param name="boc">The Cell object representing the Bag of Cells.</param>
/// <returns>The result of sending the Bag of Cells.</returns>
Task<SendBocResult?> SendBocReturnHash(Cell boc);
}
}
39 changes: 39 additions & 0 deletions TonSdk.Client/src/Client/TonClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,31 @@ public async Task<bool> IsContractDeployed(Address address, BlockIdExtended? blo
_ => null
};
}

/// <summary>
/// Retrieves transaction information for the specified parameters.
/// </summary>
/// <param name="msgHash">Message hash of transaction.</param>
/// <param name="bodyHash">Body hash of transaction.</param>
/// <param name="opcode">Opcode of message in hex or signed 32-bit decimal form.</param>
/// <param name="direction">Direction of message.</param>
/// <param name="offset">Skip first N rows. Use with limit to batch read.</param>
/// <param name="count">Limit number of queried rows. Use with offset to batch read.</param>
/// <returns>An array of transaction information results.</returns>
public Task<TransactionsInformationResultExtended[]> GetTransactionsByMessage(string msgHash = null, string bodyHash = null, string opcode = null, MessageDirection? direction = null, int? offset = null, int? count = 10)
{
if (string.IsNullOrEmpty(msgHash) && string.IsNullOrEmpty(bodyHash) && string.IsNullOrEmpty(opcode))
throw new ArgumentException("At least one of msgHash, bodyHash, opcode should be specified");

if(_type != TonClientType.HTTP_TONCENTERAPIV3)
throw new NotSupportedException($"Method not supported for type {_type}");

return _type switch
{
TonClientType.HTTP_TONCENTERAPIV3 => _httpApiV3.GetTransactionsByMessage(msgHash, bodyHash, opcode, direction, offset, count),
_ => null
};
}

/// <summary>
/// Executes a specific method on the specified address.
Expand Down Expand Up @@ -326,6 +351,20 @@ public async Task<bool> IsContractDeployed(Address address, BlockIdExtended? blo
};
}

/// <summary>
/// Sends a Bag of Cells (BoC) to the network.
/// </summary>
/// <param name="boc">The Cell object representing the Bag of Cells.</param>
/// <returns>The result of sending the Bag of Cells.</returns>
public async Task<SendBocResult?> SendBocReturnHash(Cell boc)
{
return _type switch
{
TonClientType.HTTP_TONCENTERAPIV2 => await _httpApi.SendBocReturnHash(boc),
_ => null
};
}

/// <summary>
/// Retrieves a configuration parameter by its ID.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions TonSdk.Client/src/HttpApi/HttpsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ internal async Task<SendBocResult> SendBoc(Cell boc)
return outSendBoc;
}

internal async Task<SendBocResult> SendBocReturnHash(Cell boc)
{
InSendBocBody requestBody = new InSendBocBody()
{
boc = boc.ToString("base64")
};
var result = await new TonRequest(new RequestParameters("sendBocReturnHash", requestBody), _httpClient).Call();
RootSendBoc resultRoot = JsonConvert.DeserializeObject<RootSendBoc>(result);
return resultRoot.Result;
}

internal async Task<EstimateFeeResult> EstimateFee(MessageX message, bool ignoreChksig = true)
{
Cell body = message.SignedCell;
Expand Down
31 changes: 31 additions & 0 deletions TonSdk.Client/src/HttpApi/HttpsApiV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ internal async Task<BlockTransactionsResult> GetBlockTransactions(

}

internal async Task<TransactionsInformationResultExtended[]> GetTransactionsByMessage(string msgHash, string bodyHash, string opcode, MessageDirection? direction = null, int? offset = null, int? count = null)
{
var dict = new Dictionary<string, object>();

if (!string.IsNullOrEmpty(msgHash))
dict.Add("msg_hash", msgHash);

if (!string.IsNullOrEmpty(bodyHash))
dict.Add("body_hash", bodyHash);

if (!string.IsNullOrEmpty(opcode))
dict.Add("opcode", opcode);

if (direction.HasValue)
dict.Add("direction", direction.Value.ToString().ToLower());

if (offset.HasValue)
dict.Add("offset", offset);

if (count.HasValue)
dict.Add("limit", count);

string result = await new TonRequestV3(new RequestParametersV3("transactionsByMessage", dict), _httpClient).CallGet();

var data = JsonConvert.DeserializeObject<RootTransactionsV3>(result, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
}).Transactions;
return data.Select(x => new TransactionsInformationResultExtended(x)).ToArray();
}

internal async Task<SendBocResult> SendBoc(Cell boc)
{
string result = await new TonRequestV3(new RequestParametersV3("message", new Dictionary<string, object>()
Expand Down
Loading