-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DX-392] Add support for BatchTransferBalance. (#23)
- Loading branch information
1 parent
1be6cc7
commit b5747dc
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/Enjin.Platform.Sdk/Enjin.Platform.Sdk/Model/TransferBalanceParams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Numerics; | ||
using System.Text.Json.Serialization; | ||
using JetBrains.Annotations; | ||
|
||
namespace Enjin.Platform.Sdk; | ||
|
||
/// <summary> | ||
/// This model encapsulates the required parameters for a balance transfer. | ||
/// </summary> | ||
[JsonConverter(typeof(GraphQlParameterJsonConverter<SimpleTransferParams>))] | ||
[PublicAPI] | ||
public class TransferBalanceParams : GraphQlParameter<TransferBalanceParams>, | ||
IHasEncodableTokenId<TransferBalanceParams> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TransferBalanceParams"/> class. | ||
/// </summary> | ||
public TransferBalanceParams() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Sets the value to transfer. | ||
/// </summary> | ||
/// <param name="value">The value.</param> | ||
/// <returns>This parameter for chaining.</returns> | ||
public TransferBalanceParams SetValue(BigInteger value) | ||
{ | ||
return SetParameter("value", value); | ||
} | ||
|
||
/// <summary> | ||
/// Sets whether the transaction will be kept from failing if the balance drops below the minimum requirement. | ||
/// </summary> | ||
/// <param name="keepAlive">Whether the transaction will be kept from failing.</param> | ||
/// <returns>This parameter for chaining.</returns> | ||
public TransferBalanceParams SetKeepAlive(bool? keepAlive) | ||
{ | ||
return SetParameter("keepAlive", keepAlive); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Enjin.Platform.Sdk/Enjin.Platform.Sdk/Schema/Mutations/BatchTransferBalance.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Numerics; | ||
using JetBrains.Annotations; | ||
|
||
namespace Enjin.Platform.Sdk; | ||
|
||
/// <summary> | ||
/// A request to act as a mutation for transferring multiple balances in one transaction. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// Up to 250 different transfers per batch may be included. | ||
/// </para> | ||
/// <para> | ||
/// The <c>continueOnFailure</c> flag may be used to allow all valid transfers to complete while skipping transfers | ||
/// which would fail so that they may be fixed and attempted again in another transaction. | ||
/// </para> | ||
/// </remarks> | ||
/// <seealso cref="Transaction"/> | ||
[PublicAPI] | ||
public class BatchTransferBalance : GraphQlRequest<BatchTransferBalance, TransactionFragment>, | ||
IHasContinueOnFailure<BatchTransferBalance>, | ||
IHasIdempotencyKey<BatchTransferBalance>, | ||
IHasSkipValidation<BatchTransferBalance>, | ||
IHasSigningAccount<BatchTransferBalance> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BatchTransferBalance"/> class. | ||
/// </summary> | ||
public BatchTransferBalance() : base("BatchTransferBalance", GraphQlRequestType.Mutation) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Sets the recipients for the transfer. | ||
/// </summary> | ||
/// <param name="recipients">The recipients.</param> | ||
/// <returns>This request for chaining.</returns> | ||
public BatchTransferBalance SetRecipients(params TransferRecipient[]? recipients) | ||
{ | ||
return SetVariable("recipients", CoreTypes.TransferRecipientArray, recipients); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the signing wallet for the transaction. | ||
/// </summary> | ||
/// <param name="signingAccount">The signing wallet account.</param> | ||
/// <returns>This request for chaining.</returns> | ||
/// <remarks> | ||
/// The account defaults to wallet daemon if not specified. | ||
/// </remarks> | ||
public BatchTransferBalance SetSigningAccount(string? signingAccount) | ||
{ | ||
return SetVariable("signingAccount", CoreTypes.String, signingAccount); | ||
} | ||
} |