Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongph87 committed Jan 22, 2025
1 parent 057fa33 commit bf35d05
Show file tree
Hide file tree
Showing 94 changed files with 214 additions and 485 deletions.
65 changes: 35 additions & 30 deletions StellarDotnetSdk.Tests/SorobanServerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -44,7 +45,7 @@ public async Task TestGetHealth()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"status": "healthy",
"latestLedger": 453892,
Expand All @@ -70,7 +71,7 @@ public async Task TestGetNetwork()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"friendbotUrl": "https://friendbot.stellar.org/",
"passphrase": "Test SDF Network ; September 2015",
Expand All @@ -94,7 +95,7 @@ public async Task TestGetLatestLedger()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"id": "6bdb3e5cd5dcbf53df4b67dd56f892d0134c5abfb659234a83778af0b85620fe",
"protocolVersion": 21,
Expand Down Expand Up @@ -344,7 +345,7 @@ public async Task TestGetEvents()
}
],
"latestLedger": 913609,
"cursor": "0003920046715838464-0000000001",
"cursor": "0003920046715838464-0000000001"
}
}
""";
Expand Down Expand Up @@ -431,7 +432,7 @@ public async Task TestGetAccountNotFound()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [],
"latestLedger": 458234
Expand All @@ -450,7 +451,7 @@ public async Task TestGetAccount()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand All @@ -476,7 +477,7 @@ public async Task TestGetLedgerEntriesOfTypeContractData()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -530,7 +531,7 @@ public async Task TestGetLedgerEntriesOfTypeContractCode()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -653,7 +654,7 @@ public async Task TestGetLedgerEntriesOfTypeData()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -697,7 +698,7 @@ public async Task TestGetLedgerEntriesOfTypeOffer()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -746,7 +747,7 @@ public async Task TestGetLedgerEntriesOfTypeClaimableBalance()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -792,7 +793,7 @@ public async Task TestGetLedgerEntriesOfTypeLiquidityPool()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -845,7 +846,7 @@ public async Task TestGetLedgerEntriesOfTypeTrustline()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"entries": [
{
Expand Down Expand Up @@ -890,7 +891,7 @@ public async Task TestGetTransactionNotFound()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"status": "NOT_FOUND",
"latestLedger": 456220,
Expand Down Expand Up @@ -1051,7 +1052,7 @@ public async Task TestGetFeeStats()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"inclusionFee": {
"max": "210",
Expand Down Expand Up @@ -1146,24 +1147,28 @@ public async Task TestGetVersionInfoProtocol22()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"version": "21.1.0",
"commitHash": "fcd2f0523f04279bae4502f3e3fa00ca627e6f6a",
"buildTimestamp": "2024-05-10T11:18:38",
"captiveCoreVersion": "stellar-core 21.0.0.rc2 (c6f474133738ae5f6d11b07963ca841909210273)",
"protocolVersion": 22
}
"version": "22.1.0-c7e9737b54913f5a33f29decdb0c9f6101dc1cfc",
"commitHash": "c7e9737b54913f5a33f29decdb0c9f6101dc1cfc",
"buildTimestamp": "2024-11-13T21:20:45",
"captiveCoreVersion": "stellar-core 22.0.0 (721fd0a654d5e82d38c748a91053e530a475193d)",
"protocolVersion": 22,
"commit_hash": "c7e9737b54913f5a33f29decdb0c9f6101dc1cfc",
"build_time_stamp": "2024-11-13T21:20:45",
"captive_core_version": "stellar-core 22.0.0 (721fd0a654d5e82d38c748a91053e530a475193d)",
"protocol_version": 22
}
}
""";
using var sorobanServer = Utils.CreateTestSorobanServerWithContent(json);
var response = await sorobanServer.GetVersionInfo();

Assert.IsNotNull(response);
Assert.AreEqual("21.1.0", response.Version);
Assert.AreEqual("fcd2f0523f04279bae4502f3e3fa00ca627e6f6a", response.CommitHash);
Assert.AreEqual("2024-05-10T11:18:38", response.BuildTimeStamp);
Assert.AreEqual("stellar-core 21.0.0.rc2 (c6f474133738ae5f6d11b07963ca841909210273)",
Assert.AreEqual("22.1.0-c7e9737b54913f5a33f29decdb0c9f6101dc1cfc", response.Version);
Assert.AreEqual("c7e9737b54913f5a33f29decdb0c9f6101dc1cfc", response.CommitHash);
Assert.AreEqual("2024-11-13T21:20:45", response.BuildTimeStamp);
Assert.AreEqual("stellar-core 22.0.0 (721fd0a654d5e82d38c748a91053e530a475193d)",
response.CaptiveCoreVersion);
Assert.AreEqual(22, response.ProtocolVersion);
}
Expand All @@ -1175,7 +1180,7 @@ public async Task TestGetVersionInfoPriorToProtocol22()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"version": "21.1.0",
"commit_hash": "fcd2f0523f04279bae4502f3e3fa00ca627e6f6a",
Expand Down Expand Up @@ -1204,7 +1209,7 @@ public async Task TestGetTransactionSuccess()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"status": "SUCCESS",
"txHash": "89ed109b74a65e28f6771b78ca70c6aa937792eea16506eb359cb58cc94e5db0",
Expand Down Expand Up @@ -1251,7 +1256,7 @@ public async Task TestGetTransactions()
"""
{
"jsonrpc": "2.0",
"id": 8675309,
"id": "8675309",
"result": {
"transactions": [
{
Expand Down Expand Up @@ -1762,4 +1767,4 @@ private Transaction CreateDummyTransaction(bool sign = true)
}
return transaction;
}
}
}
3 changes: 1 addition & 2 deletions StellarDotnetSdk/Assets/AssetAmount.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using StellarDotnetSdk.Converters;

namespace StellarDotnetSdk.Assets;
Expand Down

This file was deleted.

32 changes: 16 additions & 16 deletions StellarDotnetSdk/Converters/JsonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ namespace StellarDotnetSdk.Converters;

public static class JsonOptions
{
public static JsonSerializerOptions DefaultOptions =>
new()
public static JsonSerializerOptions DefaultOptions { get; } = new()
{
// This allows to deserialize a number property from either a numeric string or a number
NumberHandling = JsonNumberHandling.AllowReadingFromString,
WriteIndented = true,
// This allows to deserialize the json even if the properties are not in the same case, meaning we don't have to specify the JsonPropertyName attribute for every property
PropertyNameCaseInsensitive = true,
Converters =
{
// This allows to deserialize a number property from either a numeric string or a number
NumberHandling = JsonNumberHandling.AllowReadingFromString,
WriteIndented = true,
// This allows to deserialize the json even if the properties are not in the same case, meaning we don't have to specify the JsonPropertyName attribute for every property
PropertyNameCaseInsensitive = true,
Converters =
{
new OperationResponseJsonConverter(),
new AssetJsonConverter(),
new KeyPairJsonConverter(),
new LinkJsonConverter<EffectResponse>(),
new LinkJsonConverter<Response>()
}
};
new OperationResponseJsonConverter(),
new AssetJsonConverter(),
new KeyPairJsonConverter(),
new LinkJsonConverter<EffectResponse>(),
new LinkJsonConverter<Response>(),
new JsonStringEnumConverter(),
},
};
}
3 changes: 1 addition & 2 deletions StellarDotnetSdk/Federation/FederationResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace StellarDotnetSdk.Federation;
#nullable disable
Expand Down
5 changes: 2 additions & 3 deletions StellarDotnetSdk/LiquidityPool/LiquidityPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ public LiquidityPool(LiquidityPoolId id,
Reserves = reserves;
}

[JsonProperty(PropertyName = "id")] public LiquidityPoolId Id { get; }
[JsonPropertyName("id")] public LiquidityPoolId Id { get; }

[JsonProperty(PropertyName = "fee_bp")]
[JsonPropertyName("fee_bp")]
public int FeeBp { get; }

[JsonConverter(typeof(LiquidityPoolTypeEnumJsonConverter))]
[JsonPropertyName("type")]
public LiquidityPoolType.LiquidityPoolTypeEnum Type { get; }

[JsonPropertyName("total_trustlines")]
Expand Down
5 changes: 3 additions & 2 deletions StellarDotnetSdk/Price.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json.Serialization;
using Int32 = StellarDotnetSdk.Xdr.Int32;

namespace StellarDotnetSdk;

Expand Down Expand Up @@ -81,8 +82,8 @@ public xdr_Price ToXdr()
{
return new xdr_Price
{
D = new Xdr.Int32(Denominator),
N = new Xdr.Int32(Numerator)
D = new Int32(Denominator),
N = new Int32(Numerator)
};
}

Expand Down
3 changes: 1 addition & 2 deletions StellarDotnetSdk/Requests/SorobanRpc/GetEventsRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace StellarDotnetSdk.Requests.SorobanRpc;

Expand Down
3 changes: 1 addition & 2 deletions StellarDotnetSdk/Requests/SorobanRpc/SorobanRpcRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace StellarDotnetSdk.Requests.SorobanRpc;

Expand Down
2 changes: 0 additions & 2 deletions StellarDotnetSdk/Responses/AccountResponse.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System.Text.Json;
using StellarDotnetSdk.Accounts;
using StellarDotnetSdk.Converters;
using StellarDotnetSdk.Responses.Effects;
using StellarDotnetSdk.Responses.Operations;

Expand Down
4 changes: 2 additions & 2 deletions StellarDotnetSdk/Responses/AssetResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class AssetResponse : Response, IPagingToken
[JsonPropertyName("balances")]
public AssetBalances Balances { get; init; }

[JsonProperty(PropertyName = "claimable_balances_amount")]
[JsonPropertyName("claimable_balances_amount")]
public string ClaimableBalancesAmount { get; init; }

[JsonProperty(PropertyName = "num_claimable_balances")]
[JsonPropertyName("num_claimable_balances")]
public int NumClaimableBalances { get; init; }

[JsonPropertyName("flags")] public AssetResponseFlags Flags { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace StellarDotnetSdk.Responses.Effects;
#nullable disable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using StellarDotnetSdk.Assets;

namespace StellarDotnetSdk.Responses.Effects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using StellarDotnetSdk.Assets;

namespace StellarDotnetSdk.Responses.Effects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace StellarDotnetSdk.Responses.Effects;

Expand Down
Loading

0 comments on commit bf35d05

Please sign in to comment.