diff --git a/stellar-dotnet-sdk-test/AccountFlagTest.cs b/stellar-dotnet-sdk-test/AccountFlagTest.cs index 289af704..33e066ff 100644 --- a/stellar-dotnet-sdk-test/AccountFlagTest.cs +++ b/stellar-dotnet-sdk-test/AccountFlagTest.cs @@ -12,6 +12,7 @@ public void TestValues() Assert.AreEqual(1, (int)AccountFlag.AuthRequiredFlag); Assert.AreEqual(2, (int)AccountFlag.AuthRevocableFlag); Assert.AreEqual(4, (int)AccountFlag.AuthImmutableFlag); + Assert.AreEqual(8, (int)AccountFlag.AuthClawbackFlag); } } } \ No newline at end of file diff --git a/stellar-dotnet-sdk-test/ServerCheckMemoRequiredTest.cs b/stellar-dotnet-sdk-test/ServerCheckMemoRequiredTest.cs index 44aeec78..1d646f28 100644 --- a/stellar-dotnet-sdk-test/ServerCheckMemoRequiredTest.cs +++ b/stellar-dotnet-sdk-test/ServerCheckMemoRequiredTest.cs @@ -189,10 +189,10 @@ private string BuildAccountResponse(string accountId, Dictionary { Balances = new[] { - new Balance("native", null, null, "12345.6789", null, "0.0", "0.0", false, true), + new Balance("native", null, null, "12345.6789", null, "0.0", "0.0", false, true, "1c80ecd9cc567ef5301683af3ca7c2deeba7d519275325549f22514076396469"), }, Data = accountData, - Flags = new Flags(false, false, false), + Flags = new Flags(false, false, false, false), HomeDomain = null, InflationDestination = null, Signers = new[] diff --git a/stellar-dotnet-sdk-test/responses/AccountDeserializerTest.cs b/stellar-dotnet-sdk-test/responses/AccountDeserializerTest.cs index 88f86d2c..17559f03 100644 --- a/stellar-dotnet-sdk-test/responses/AccountDeserializerTest.cs +++ b/stellar-dotnet-sdk-test/responses/AccountDeserializerTest.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using stellar_dotnet_sdk; @@ -74,6 +75,7 @@ public static void AssertTestData(AccountResponse account) Assert.AreEqual(account.Flags.AuthRequired, false); Assert.AreEqual(account.Flags.AuthRevocable, true); Assert.AreEqual(account.Flags.AuthImmutable, true); + Assert.AreEqual(account.Flags.AuthClawback, true); Assert.AreEqual(account.Balances[0].AssetType, "credit_alphanum4"); Assert.AreEqual(account.Balances[0].AssetCode, "ABC"); @@ -83,6 +85,9 @@ public static void AssertTestData(AccountResponse account) Assert.AreEqual(asset.Code, "ABC"); Assert.AreEqual(asset.Issuer, "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU"); + account.Balances + .Should().HaveCount(3); + Assert.AreEqual(account.Balances[0].BalanceString, "1001.0000000"); Assert.AreEqual(account.Balances[0].Limit, "12000.4775807"); Assert.AreEqual(account.Balances[0].BuyingLiabilities, "100.1234567"); @@ -98,6 +103,25 @@ public static void AssertTestData(AccountResponse account) Assert.AreEqual(account.Balances[1].SellingLiabilities, "1.7654321"); Assert.AreEqual(account.Balances[1].Limit, null); + // liquidity pool balance + account.Balances[2].AssetType + .Should().Be("liquidity_pool_shares"); + + account.Balances[2].BalanceString + .Should().Be("500.0000400"); + + account.Balances[2].Limit + .Should().Be("922337203685.4775807"); + + account.Balances[2].IsAuthorized + .Should().BeFalse(); + + account.Balances[2].IsAuthorizedToMaintainLiabilities + .Should().BeFalse(); + + account.Balances[2].LiquidityPoolId + .Should().Be("1c80ecd9cc567ef5301683af3ca7c2deeba7d519275325549f22514076396469"); + Assert.AreEqual(account.Signers[0].Key, "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); Assert.AreEqual(account.Signers[0].Weight, 0); Assert.AreEqual(account.Signers[0].Type, "ed25519_public_key"); diff --git a/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj b/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj index e0c3bfe9..1a23de8f 100644 --- a/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj +++ b/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj @@ -16,6 +16,7 @@ runtime; build; native; contentfiles; analyzers + diff --git a/stellar-dotnet-sdk-test/testdata/account.json b/stellar-dotnet-sdk-test/testdata/account.json index a1bed7d4..d8a4ca2c 100644 --- a/stellar-dotnet-sdk-test/testdata/account.json +++ b/stellar-dotnet-sdk-test/testdata/account.json @@ -34,7 +34,8 @@ "flags": { "auth_required": false, "auth_revocable": true, - "auth_immutable": true + "auth_immutable": true, + "auth_clawback_enabled": true }, "balances": [ { @@ -53,6 +54,15 @@ "balance": "20.0000300", "buying_liabilities": "5.1234567", "selling_liabilities": "1.7654321" + }, + { + "balance": "500.0000400", + "liquidity_pool_id": "1c80ecd9cc567ef5301683af3ca7c2deeba7d519275325549f22514076396469", + "limit": "922337203685.4775807", + "last_modified_ledger": 975243, + "is_authorized": false, + "is_authorized_to_maintain_liabilities": false, + "asset_type": "liquidity_pool_shares" } ], "signers": [ diff --git a/stellar-dotnet-sdk/AccountFlag.cs b/stellar-dotnet-sdk/AccountFlag.cs index b29cd5bf..568d2254 100644 --- a/stellar-dotnet-sdk/AccountFlag.cs +++ b/stellar-dotnet-sdk/AccountFlag.cs @@ -18,8 +18,13 @@ public enum AccountFlag AuthRevocableFlag = AccountFlags.AccountFlagsEnum.AUTH_REVOCABLE_FLAG, /// - /// With this setting, none of the following authorization flags can be changed. + /// With this setting, none of the other authorization flags can be changed. /// - AuthImmutableFlag = AccountFlags.AccountFlagsEnum.AUTH_IMMUTABLE_FLAG + AuthImmutableFlag = AccountFlags.AccountFlagsEnum.AUTH_IMMUTABLE_FLAG, + + /// + /// With this setting, an anchor can unilaterally take away any portion of its issued asset(s) from any asset holder. + /// + AuthClawbackFlag = AccountFlags.AccountFlagsEnum.AUTH_CLAWBACK_ENABLED_FLAG } } \ No newline at end of file diff --git a/stellar-dotnet-sdk/responses/Balance.cs b/stellar-dotnet-sdk/responses/Balance.cs index 4c664c3c..24f44191 100644 --- a/stellar-dotnet-sdk/responses/Balance.cs +++ b/stellar-dotnet-sdk/responses/Balance.cs @@ -8,17 +8,27 @@ namespace stellar_dotnet_sdk.responses /// public class Balance { - public Balance(string assetType, string assetCode, string assetIssuer, string balance, string limit, string buyingLiabilities, string sellingLiabilities, bool isAuthorized, bool isAuthorizedToMaintainLiabilities) + public Balance(string assetType, string assetCode, string assetIssuer, string balance, string limit, string buyingLiabilities, string sellingLiabilities, bool isAuthorized, bool isAuthorizedToMaintainLiabilities, string liquidityPoolId) { AssetType = assetType ?? throw new ArgumentNullException(nameof(assetType), "assertType cannot be null"); BalanceString = balance ?? throw new ArgumentNullException(nameof(balance), "balance cannot be null"); Limit = limit; AssetCode = assetCode; AssetIssuer = assetIssuer; - BuyingLiabilities = buyingLiabilities ?? throw new ArgumentNullException(nameof(buyingLiabilities), "buyingLiabilities cannot be null"); - SellingLiabilities = sellingLiabilities ?? throw new ArgumentNullException(nameof(sellingLiabilities), "sellingLiabilities cannot be null"); + + if (assetType != "liquidity_pool_shares") + { + BuyingLiabilities = buyingLiabilities ?? throw new ArgumentNullException(nameof(buyingLiabilities), "buyingLiabilities cannot be null"); + SellingLiabilities = sellingLiabilities ?? throw new ArgumentNullException(nameof(sellingLiabilities), "sellingLiabilities cannot be null"); + } + IsAuthorized = isAuthorized; IsAuthorizedToMaintainLiabilities = isAuthorizedToMaintainLiabilities; + + if (assetType == "liquidity_pool_shares") + { + LiquidityPoolId = liquidityPoolId ?? throw new ArgumentNullException(nameof(liquidityPoolId)); + } } [JsonProperty(PropertyName = "asset_type")] @@ -50,5 +60,8 @@ public Balance(string assetType, string assetCode, string assetIssuer, string ba [JsonProperty(PropertyName = "is_authorized_to_maintain_liabilities")] public bool IsAuthorizedToMaintainLiabilities { get; private set; } + + [JsonProperty(PropertyName = "liquidity_pool_id")] + public string LiquidityPoolId { get; private set; } } } diff --git a/stellar-dotnet-sdk/responses/Flags.cs b/stellar-dotnet-sdk/responses/Flags.cs index 61399920..dbfed2d9 100644 --- a/stellar-dotnet-sdk/responses/Flags.cs +++ b/stellar-dotnet-sdk/responses/Flags.cs @@ -7,20 +7,36 @@ namespace stellar_dotnet_sdk.responses /// public class Flags { - public Flags(bool authRequired, bool authRevocable, bool authImmutable) + public Flags(bool authRequired, bool authRevocable, bool authImmutable, bool authClawback) { AuthRequired = authRequired; AuthRevocable = authRevocable; AuthImmutable = authImmutable; + AuthClawback = authClawback; } + /// + /// This account must approve anyone who wants to hold its asset. + /// [JsonProperty(PropertyName = "auth_required")] public bool AuthRequired { get; private set; } + /// + /// This account can set the authorize flag of an existing trustline to freeze the assets held by an asset holder. + /// [JsonProperty(PropertyName = "auth_revocable")] public bool AuthRevocable { get; private set; } + /// + /// This account cannot change any of the authorization flags. + /// [JsonProperty(PropertyName = "auth_immutable")] public bool AuthImmutable { get; private set; } + + /// + /// This account can unilaterally take away any portion of its issued asset(s) from any asset holders. + /// + [JsonProperty(PropertyName = "auth_clawback_enabled")] + public bool AuthClawback { get; private set; } } } \ No newline at end of file