generated from CareBoo/UPMTemplate-2020
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(signer): update
ISigner
interface to be closer to signer inter…
…face in other SDKs See https://github.com/algorand/py-algorand-sdk/blob/aba9f4ccf87d4e7f7d5d6d4826e38463b76da9b8/algosdk/atomic_transaction_composer.py#L558 for an example. BREAKING CHANGE: Remove `ISigner` interfaces from `AlgoSdk.Account` and completely change the signer API. re #131
- Loading branch information
1 parent
dd0837e
commit a8fbe0b
Showing
2 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,43 +1,66 @@ | ||
using System; | ||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
|
||
namespace AlgoSdk | ||
{ | ||
public interface ISigner | ||
{ | ||
/// <summary> | ||
/// Sign a single transaction. | ||
/// </summary> | ||
/// <param name="txn">The transaction to sign.</param> | ||
/// <typeparam name="T">The type of the transaction.</typeparam> | ||
/// <returns>Transaction with signature if it was signed.</returns> | ||
SignedTxn<T> SignTxn<T>(T txn) where T : ITransaction, IEquatable<T>; | ||
|
||
/// <summary> | ||
/// Sign a group of transactions. | ||
/// </summary> | ||
/// <remarks> | ||
/// Each transaction is expected to have a valid group id already set. | ||
/// </remarks> | ||
/// <param name="txns">The transactions to sign.</param> | ||
/// <param name="txnsToSign">Indexes of the transactions this signer should sign.</param> | ||
/// <typeparam name="T">The type of the transactions.</typeparam> | ||
/// <returns>An array of transactions with signatures. If the transaction at a given index was not signed, that signed transaction will have no signature.</returns> | ||
SignedTxn<T>[] SignTxns<T>(T[] txns) where T : ITransaction, IEquatable<T>; | ||
SignedTxn<T>[] SignTxns<T>(T[] txns, int[] txnsToSign) where T : ITransaction, IEquatable<T>; | ||
} | ||
|
||
public interface IAsyncSigner | ||
{ | ||
/// <summary> | ||
/// Sign a single transaction. | ||
/// Sign a group of transactions. | ||
/// </summary> | ||
/// <param name="txn">The transaction to sign.</param> | ||
/// <typeparam name="T">The type of the transaction.</typeparam> | ||
/// <returns>Transaction with signature if it was signed.</returns> | ||
UniTask<SignedTxn<T>> SignTxnAsync<T>(T txn) where T : ITransaction, IEquatable<T>; | ||
/// <remarks> | ||
/// Each transaction is expected to have a valid group id already set. | ||
/// </remarks> | ||
/// <param name="txns">The transactions to sign.</param> | ||
/// <param name="txnsToSign">Indexes of the transactions this signer should sign.</param> | ||
/// <param name="cancellationToken">Provide an optional cancellation token to interrupt signing.</param> | ||
/// <typeparam name="T">The type of the transactions.</typeparam> | ||
/// <returns>An array of transactions with signatures. If the transaction at a given index was not signed, that signed transaction will have no signature.</returns> | ||
UniTask<SignedTxn<T>[]> SignTxnsAsync<T>( | ||
T[] txns, | ||
int[] txnsToSign, | ||
CancellationToken cancellationToken = default | ||
) | ||
where T : ITransaction, IEquatable<T>; | ||
} | ||
|
||
public interface IAsyncSignerWithProgress : IAsyncSigner | ||
{ | ||
/// <summary> | ||
/// Sign a group of transactions. | ||
/// </summary> | ||
/// <remarks> | ||
/// Each transaction is expected to have a valid group id already set. | ||
/// </remarks> | ||
/// <param name="txns">The transactions to sign.</param> | ||
/// <param name="txnsToSign">Indexes of the transactions this signer should sign.</param> | ||
/// <param name="progress">A progress token that can be used to periodically check the progress.</param> | ||
/// <param name="cancellationToken">Provide an optional cancellation token to interrupt signing.</param> | ||
/// <typeparam name="T">The type of the transactions.</typeparam> | ||
/// <returns>An array of transactions with signatures. If the transaction at a given index was not signed, that signed transaction will have no signature.</returns> | ||
UniTask<SignedTxn<T>[]> SignTxnsAsync<T>(T[] txns) where T : ITransaction, IEquatable<T>; | ||
UniTask<SignedTxn<T>[]> SignTxnsAsync<T, TProgress>( | ||
T[] txns, | ||
int[] txnsToSign, | ||
TProgress progress, | ||
CancellationToken cancellationToken = default | ||
) | ||
where T : ITransaction, IEquatable<T> | ||
where TProgress : IProgress<T>; | ||
} | ||
} |