Skip to content

Commit

Permalink
Added changeTrustAsset arg to ChangeTrustOperation constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jopmiddelkamp committed Sep 5, 2024
1 parent a04f9f7 commit 8e80e10
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions StellarDotnetSdk/Operations/ChangeTrustOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,35 @@ public ChangeTrustOperation(Asset asset, string? limit = null, IAccountId? sourc
/// </summary>
/// <param name="assetA">Asset A.</param>
/// <param name="assetB">Asset B.</param>
/// <param name="liquidityPoolFee">The fee for the liquidity pool</param>
/// <param name="limit">
/// The limit of the trustline.
/// <p>Leave empty to default to the max int64.</p>
/// <p>Set to 0 to remove the trust line.</p>
/// </param>
public ChangeTrustOperation(Asset assetA, Asset assetB, string? limit = null, IAccountId? sourceAccount = null) :
/// <param name="sourceAccount">(Optional) Source account of the operation.</param>
[Obsolete("Use the constructor with the ChangeTrustAsset parameter instead.")]
public ChangeTrustOperation(Asset assetA, Asset assetB, int? liquidityPoolFee = null, string? limit = null, IAccountId? sourceAccount = null) :
base(sourceAccount)
{
Asset = ChangeTrustAsset.Create(assetA, assetB, liquidityPoolFee ?? LiquidityPoolParameters.Fee);
Limit = limit ?? MaxLimit;
}

/// <summary>
/// Constructs a new <c>ChangeTrustOperation</c> for Liquidity pool shares type with the default fee.
/// </summary>
/// <param name="changeTrustAsset">The Change Trust Asset</param>
/// <param name="limit">
/// The limit of the trustline.
/// <p>Leave empty to default to the max int64.</p>
/// <p>Set to 0 to remove the trust line.</p>
/// </param>
/// <param name="sourceAccount">(Optional) Source account of the operation.</param>
public ChangeTrustOperation(ChangeTrustAsset changeTrustAsset, string? limit = null, IAccountId? sourceAccount = null) :
base(sourceAccount)
{
Asset = ChangeTrustAsset.Create(assetA, assetB, LiquidityPoolParameters.Fee);
Asset = changeTrustAsset;
Limit = limit ?? MaxLimit;
}

Expand Down Expand Up @@ -99,7 +119,7 @@ public static ChangeTrustOperation FromXdr(ChangeTrustOp changeTrustOp)
var parameters =
(LiquidityPoolConstantProductParameters)liquidityPoolShareChangeTrustAsset.Parameters;
return new ChangeTrustOperation(
parameters.AssetA, parameters.AssetB, Amount.FromXdr(changeTrustOp.Limit.InnerValue)
parameters.AssetA, parameters.AssetB, parameters.Fee, Amount.FromXdr(changeTrustOp.Limit.InnerValue)
);
default:
throw new ArgumentOutOfRangeException();
Expand Down

0 comments on commit 8e80e10

Please sign in to comment.