From 78cadd2565758f3ad73273113dc33ae63bb03d19 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Wed, 26 Apr 2023 22:01:52 +0200 Subject: [PATCH 01/14] Add STPF support. Remove Account requirement from Transactions API. Bump to dotnet 6. Bump version. --- dotnet-algorand-sdk/Account.cs | 4 +- .../Algod/Model/AssetParams.cs | 28 ++-- .../Algod/Model/TransactionParams.cs | 18 +-- dotnet-algorand-sdk/Transaction.cs | 5 +- dotnet-algorand-sdk/Util/Utils.cs | 136 +++++++++--------- dotnet-algorand-sdk/V2/Indexer/LookupApi.cs | 3 - dotnet-algorand-sdk/V2/Indexer/Model/Model.cs | 10 +- .../dotnet-algorand-sdk.csproj | 8 +- sdk-examples/sdk-examples.csproj | 2 +- test/test.csproj | 2 +- 10 files changed, 110 insertions(+), 106 deletions(-) diff --git a/dotnet-algorand-sdk/Account.cs b/dotnet-algorand-sdk/Account.cs index 7b025d93..cc2c0d9d 100644 --- a/dotnet-algorand-sdk/Account.cs +++ b/dotnet-algorand-sdk/Account.cs @@ -34,9 +34,9 @@ public class Account /// the rebuilded account public static Account AccountFromPrivateKey(byte[] privateKey) { - if(privateKey.Length != SK_SIZE) + if(privateKey.Length != SK_SIZE) throw new ArgumentException("Incorrect private key length"); - + var privateKeyRebuild = new Ed25519PrivateKeyParameters(privateKey, 0); var publicKeyRebuild = privateKeyRebuild.GeneratePublicKey(); var act = new Account diff --git a/dotnet-algorand-sdk/Algod/Model/AssetParams.cs b/dotnet-algorand-sdk/Algod/Model/AssetParams.cs index 2c6b9aa0..3ba3b84b 100644 --- a/dotnet-algorand-sdk/Algod/Model/AssetParams.cs +++ b/dotnet-algorand-sdk/Algod/Model/AssetParams.cs @@ -1,4 +1,4 @@ -/* +/* * Algod REST API. * * API Endpoint for AlgoD Operations. @@ -73,7 +73,7 @@ public partial class AssetParams : IEquatable, IValidatableObject this.Unitname = unitname; this.Url = url; } - + /// /// AssetName specifies the name of this asset, as supplied by the creator. /// @@ -173,7 +173,7 @@ public override string ToString() sb.Append("}\n"); return sb.ToString(); } - + /// /// Returns the JSON string presentation of the object /// @@ -203,57 +203,57 @@ public bool Equals(AssetParams input) if (input == null) return false; - return + return ( this.Assetname == input.Assetname || (this.Assetname != null && this.Assetname.Equals(input.Assetname)) - ) && + ) && ( this.Clawbackaddr == input.Clawbackaddr || (this.Clawbackaddr != null && this.Clawbackaddr.Equals(input.Clawbackaddr)) - ) && + ) && ( this.Creator == input.Creator || (this.Creator != null && this.Creator.Equals(input.Creator)) - ) && + ) && ( this.Defaultfrozen == input.Defaultfrozen || (this.Defaultfrozen != null && this.Defaultfrozen.Equals(input.Defaultfrozen)) - ) && + ) && ( this.Freezeaddr == input.Freezeaddr || (this.Freezeaddr != null && this.Freezeaddr.Equals(input.Freezeaddr)) - ) && + ) && ( this.Managerkey == input.Managerkey || (this.Managerkey != null && this.Managerkey.Equals(input.Managerkey)) - ) && + ) && ( this.Metadatahash == input.Metadatahash || (this.Metadatahash != null && this.Metadatahash.Equals(input.Metadatahash)) - ) && + ) && ( this.Reserveaddr == input.Reserveaddr || (this.Reserveaddr != null && this.Reserveaddr.Equals(input.Reserveaddr)) - ) && + ) && ( this.Total == input.Total || (this.Total != null && this.Total.Equals(input.Total)) - ) && + ) && ( this.Unitname == input.Unitname || (this.Unitname != null && this.Unitname.Equals(input.Unitname)) - ) && + ) && ( this.Url == input.Url || (this.Url != null && diff --git a/dotnet-algorand-sdk/Algod/Model/TransactionParams.cs b/dotnet-algorand-sdk/Algod/Model/TransactionParams.cs index 16f407d3..ef0d8d27 100644 --- a/dotnet-algorand-sdk/Algod/Model/TransactionParams.cs +++ b/dotnet-algorand-sdk/Algod/Model/TransactionParams.cs @@ -1,4 +1,4 @@ -/* +/* * Algod REST API. * * API Endpoint for AlgoD Operations. @@ -87,7 +87,7 @@ public partial class TransactionParams : IEquatable, IValida } this.MinFee = minFee; } - + /// /// ConsensusVersion indicates the consensus protocol version as of LastRound. /// @@ -147,7 +147,7 @@ public override string ToString() sb.Append("}\n"); return sb.ToString(); } - + /// /// Returns the JSON string presentation of the object /// @@ -177,32 +177,32 @@ public bool Equals(TransactionParams input) if (input == null) return false; - return + return ( this.ConsensusVersion == input.ConsensusVersion || (this.ConsensusVersion != null && this.ConsensusVersion.Equals(input.ConsensusVersion)) - ) && + ) && ( this.Fee == input.Fee || (this.Fee != null && this.Fee.Equals(input.Fee)) - ) && + ) && ( this.GenesisID == input.GenesisID || (this.GenesisID != null && this.GenesisID.Equals(input.GenesisID)) - ) && + ) && ( this.Genesishashb64 == input.Genesishashb64 || (this.Genesishashb64 != null && this.Genesishashb64.Equals(input.Genesishashb64)) - ) && + ) && ( this.LastRound == input.LastRound || (this.LastRound != null && this.LastRound.Equals(input.LastRound)) - ) && + ) && ( this.MinFee == input.MinFee || (this.MinFee != null && diff --git a/dotnet-algorand-sdk/Transaction.cs b/dotnet-algorand-sdk/Transaction.cs index 29586a8b..3e2510c9 100644 --- a/dotnet-algorand-sdk/Transaction.cs +++ b/dotnet-algorand-sdk/Transaction.cs @@ -799,7 +799,7 @@ public static Transaction CreateAssetRevokeTransaction(// AssetTransaction genesisHash) { assetReceiver = assetReceiver, //arcv - assetSender = assetRevokedFrom, //asnd + assetSender = assetRevokedFrom, //asnd assetAmount = assetAmount, // aamt sender = transactionSender // snd }; // gh @@ -919,10 +919,11 @@ public class Type public static readonly Type AssetTransfer = new Type(4); public static readonly Type AssetFreeze = new Type(5); public static readonly Type ApplicationCall = new Type(6); + public static readonly Type StateProof = new Type(7); private static Dictionary namesMap = new Dictionary { {"", 0 }, {"pay", 1}, {"keyreg", 2}, - { "acfg", 3}, {"axfer", 4}, { "afrz", 5}, { "appl", 6} + { "acfg", 3}, {"axfer", 4}, { "afrz", 5}, { "appl", 6}, { "sptf", 7} }; /// /// Return the enumeration for the given string value. Required for JSON serialization. diff --git a/dotnet-algorand-sdk/Util/Utils.cs b/dotnet-algorand-sdk/Util/Utils.cs index be4fb443..bfa3e577 100644 --- a/dotnet-algorand-sdk/Util/Utils.cs +++ b/dotnet-algorand-sdk/Util/Utils.cs @@ -31,10 +31,10 @@ public static string WaitTransactionToComplete(AlgodApi instance, string txID) { return "Transaction " + b3.Tx + " confirmed in round " + b3.Round; } - // loops 4 times per second, > 5 times per second will fail using TestNet Purestake Free verison - // also blocks are created in under 5 seconds so no real need to poll constantly - + // loops 4 times per second, > 5 times per second will fail using TestNet Purestake Free verison + // also blocks are created in under 5 seconds so no real need to poll constantly - // a few times per second should be fine - System.Threading.Thread.Sleep(250); + System.Threading.Thread.Sleep(250); } } /// @@ -44,14 +44,14 @@ public static string WaitTransactionToComplete(AlgodApi instance, string txID) /// transaction ID /// how many rounds do you wish to check pending transactions for /// The pending transaction response - public static async Task WaitTransactionToComplete(V2.Algod.DefaultApi instance, string txID, ulong timeout = 3) + public static async Task WaitTransactionToComplete(V2.Algod.DefaultApi instance, string txID, ulong timeout = 3) { if (instance == null || txID == null || txID.Length == 0 || timeout < 0) { throw new ArgumentException("Bad arguments for waitForConfirmation."); } - V2.Algod.Model.NodeStatusResponse nodeStatusResponse = await instance.StatusAsync(); + V2.Algod.Model.NodeStatusResponse nodeStatusResponse = await instance.StatusAsync(); var startRound = nodeStatusResponse.LastRound + 1; var currentRound = startRound; while (currentRound < (startRound + timeout)) @@ -84,7 +84,7 @@ public static string WaitTransactionToComplete(AlgodApi instance, string txID) /// public static TransactionID SubmitTransaction(AlgodApi instance, SignedTransaction signedTx) //throws Exception { - byte[] encodedTxBytes = Encoder.EncodeToMsgPack(signedTx); + byte[] encodedTxBytes = Encoder.EncodeToMsgPack(signedTx); return instance.RawTransaction(encodedTxBytes); } /// @@ -100,7 +100,7 @@ public static TransactionID SubmitTransaction(AlgodApi instance, SignedTransacti { return await instance.TransactionsAsync(ms); } - } + } /// /// encode and submit signed transactions using algod v2 api /// @@ -143,7 +143,7 @@ public static Transaction GetPaymentTransaction(Address from, Address to, ulong? return GetPaymentTransactionWithInfo(from, to, amount, message, trans.Fee, trans.LastRound, trans.GenesisID, trans.Genesishashb64); } /// - /// + /// /// /// /// @@ -154,7 +154,7 @@ public static Transaction GetPaymentTransaction(Address from, Address to, ulong? /// /// /// - public static Transaction GetPaymentTransactionWithInfo(Address from, Address to, ulong? amount, string message, + public static Transaction GetPaymentTransactionWithInfo(Address from, Address to, ulong? amount, string message, ulong? fee, ulong? lastRound, string genesisId, string genesishashb64) { var tx = GetPaymentTransactionWithFlatFee(from, to, amount, message, fee, lastRound, genesisId, genesishashb64); @@ -162,7 +162,7 @@ public static Transaction GetPaymentTransactionWithInfo(Address from, Address to return tx; } /// - /// + /// /// /// /// @@ -191,7 +191,7 @@ public static Transaction GetPaymentTransactionWithFlatFee(Address from, Address /// message /// Transaction Params(use AlgodApi.TransactionParams() function to get the params) /// payment transaction - public static Transaction GetPaymentTransaction(Address from, Address to, ulong? amount, string message, + public static Transaction GetPaymentTransaction(Address from, Address to, ulong? amount, string message, TransactionParametersResponse trans) { if (trans is null) @@ -217,9 +217,9 @@ public static string GetRandomAssetMetaHash() /// The asset infomation /// The blockchain infomation /// The message for the transaction(have no affect to the assect) - /// A value of 0 represents an asset that is not divisible, - /// while a value of 1 represents an asset that is divisible into tenths and so on, i.e, - /// the number of digits to display after the decimal place when displaying the asset. + /// A value of 0 represents an asset that is not divisible, + /// while a value of 1 represents an asset that is divisible into tenths and so on, i.e, + /// the number of digits to display after the decimal place when displaying the asset. /// This value must be between 0 and 19 /// transaction public static Transaction GetCreateAssetTransaction(AssetParams asset, TransactionParams trans, string message = "", int decimals = 0, ulong? flatFee = null) @@ -261,7 +261,7 @@ public static Transaction GetCreateAssetTransaction(AssetParams asset, Transacti } return tx; - } + } /// /// Generate a create asset transaction V2 @@ -269,9 +269,9 @@ public static Transaction GetCreateAssetTransaction(AssetParams asset, Transacti /// The asset infomation /// The blockchain infomation /// The message for the transaction(have no affect to the assect) - /// A value of 0 represents an asset that is not divisible, - /// while a value of 1 represents an asset that is divisible into tenths and so on, i.e, - /// the number of digits to display after the decimal place when displaying the asset. + /// A value of 0 represents an asset that is not divisible, + /// while a value of 1 represents an asset that is divisible into tenths and so on, i.e, + /// the number of digits to display after the decimal place when displaying the asset. /// This value must be between 0 and 19 /// transaction public static Transaction GetCreateAssetTransaction(V2.Algod.Model.AssetParams asset, V2.Algod.Model.TransactionParametersResponse trans, string message = "", ulong? flatFee = null) @@ -281,10 +281,10 @@ public static Transaction GetCreateAssetTransaction(V2.Algod.Model.AssetParams a var tx = Transaction.CreateAssetCreateTransaction(new Address(asset.Creator), (ulong?)trans.Fee, (ulong?)trans.LastRound, (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisId, new Digest(trans.GenesisHash), asset.Total, (int)asset.Decimals, (bool)asset.DefaultFrozen, asset.UnitName, asset.Name, asset.Url, - asset.MetadataHash, - asset.Manager==""||asset.Manager==null ? null : new Address(asset.Manager), + asset.MetadataHash, + asset.Manager==""||asset.Manager==null ? null : new Address(asset.Manager), asset.Reserve==""||asset.Reserve==null ? null : new Address(asset.Reserve), - asset.Freeze==""||asset.Freeze==null ? null : new Address(asset.Freeze), + asset.Freeze==""||asset.Freeze==null ? null : new Address(asset.Freeze), asset.Clawback==""||asset.Clawback==null ? null : new Address(asset.Clawback)); if (flatFee is null || flatFee == 0) @@ -294,7 +294,7 @@ public static Transaction GetCreateAssetTransaction(V2.Algod.Model.AssetParams a else { tx.fee = flatFee; - } + } return tx; } /// @@ -312,7 +312,7 @@ public static Transaction GetConfigAssetTransaction(Address sender, ulong? asset //sender must be manager var tx = Transaction.CreateAssetConfigureTransaction(sender, 1, trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, - new Digest(trans.Genesishashb64), assetId, new Address(asset.Managerkey), + new Digest(trans.Genesishashb64), assetId, new Address(asset.Managerkey), new Address(asset.Reserveaddr), new Address(asset.Freezeaddr), new Address(asset.Clawbackaddr), false); if (flatFee is null || flatFee == 0) { @@ -325,7 +325,7 @@ public static Transaction GetConfigAssetTransaction(Address sender, ulong? asset return tx; } - public static Transaction GetConfigAssetTransaction(Address sender, V2.Algod.Model.Asset asset, TransactionParametersResponse trans, + public static Transaction GetConfigAssetTransaction(Address sender, V2.Algod.Model.Asset asset, TransactionParametersResponse trans, string message = "", ulong? flatFee = null) { ValidateAsset(asset.Params); @@ -357,9 +357,9 @@ public static Transaction GetConfigAssetTransaction(Address sender, V2.Algod.Mod /// The blockchain infomation /// The message for the transaction(have no affect to the assect) /// transaction - public static Transaction GetActivateAssetTransaction(Address sender, ulong? assetId, TransactionParams trans, + public static Transaction GetActivateAssetTransaction(Address sender, ulong? assetId, TransactionParams trans, string message = "", ulong? flatFee = null) - { + { return GetAssetOptingInTransaction(sender, assetId, trans, message, flatFee); } /// @@ -371,7 +371,7 @@ public static Transaction GetActivateAssetTransaction(Address sender, ulong? ass /// The blockchain infomation /// The message for the transaction(have no affect to the assect) /// transaction - public static Transaction GetAssetOptingInTransaction(Address sender, ulong? assetId, TransactionParams trans, + public static Transaction GetAssetOptingInTransaction(Address sender, ulong? assetId, TransactionParams trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetAcceptTransaction(sender, 1, trans.LastRound, @@ -388,7 +388,7 @@ public static Transaction GetAssetOptingInTransaction(Address sender, ulong? ass //Account.SetFeeByFeePerByte(tx, trans.Fee); return tx; } - public static Transaction GetAssetOptingInTransaction(Address sender, ulong? assetID, TransactionParametersResponse trans, + public static Transaction GetAssetOptingInTransaction(Address sender, ulong? assetID, TransactionParametersResponse trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetAcceptTransaction(sender, 1, (ulong?)trans.LastRound, @@ -406,10 +406,10 @@ public static Transaction GetAssetOptingInTransaction(Address sender, ulong? ass return tx; } - public static Transaction GetTransferAssetTransaction(Address from, Address to, ulong? assetId, ulong amount, TransactionParams trans, + public static Transaction GetTransferAssetTransaction(Address from, Address to, ulong? assetId, ulong amount, TransactionParams trans, Address closeTo = null, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetTransferTransaction(from, to, closeTo, amount, 1, - trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, + trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, new Digest(trans.Genesishashb64), assetId); if (flatFee is null || flatFee == 0) { @@ -422,7 +422,7 @@ public static Transaction GetTransferAssetTransaction(Address from, Address to, //Account.SetFeeByFeePerByte(tx, trans.Fee); return tx; } - public static Transaction GetTransferAssetTransaction(Address from, Address to, ulong? assetId, ulong amount, + public static Transaction GetTransferAssetTransaction(Address from, Address to, ulong? assetId, ulong amount, TransactionParametersResponse trans, Address closeTo = null, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetTransferTransaction(from, to, closeTo, amount, 1, @@ -450,7 +450,7 @@ public static Transaction GetTransferAssetTransaction(Address from, Address to, /// The blockchain infomation /// The message for the transaction(have no affect to the assect) /// transaction - public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, ulong? assetId, bool freezeState, + public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, ulong? assetId, bool freezeState, TransactionParams trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetFreezeTransaction(sender, toFreeze, freezeState, 1, trans.LastRound, @@ -467,7 +467,7 @@ public static Transaction GetFreezeAssetTransaction(Address sender, Address toFr return tx; } - public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, ulong? assetId, bool freezeState, + public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, ulong? assetId, bool freezeState, TransactionParametersResponse trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetFreezeTransaction(sender, toFreeze, freezeState, 1, (ulong?)trans.LastRound, @@ -484,7 +484,7 @@ public static Transaction GetFreezeAssetTransaction(Address sender, Address toFr return tx; } /// - /// + /// /// /// /// @@ -494,11 +494,11 @@ public static Transaction GetFreezeAssetTransaction(Address sender, Address toFr /// /// /// - public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, ulong? assetId, + public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, ulong? assetId, ulong amount, TransactionParams trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetRevokeTransaction(reserve, revokedFrom, receiver, amount, 1, trans.LastRound, - trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, + trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, new Digest(trans.Genesishashb64), assetId); if (flatFee is null || flatFee == 0) { @@ -512,7 +512,7 @@ public static Transaction GetRevokeAssetTransaction(Address reserve, Address rev return tx; } /// - /// + /// /// /// /// @@ -523,7 +523,7 @@ public static Transaction GetRevokeAssetTransaction(Address reserve, Address rev /// /// /// - public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, ulong? assetId, + public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, ulong? assetId, ulong amount, TransactionParametersResponse trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetRevokeTransaction(reserve, revokedFrom, receiver, amount, 1, (ulong?)trans.LastRound, @@ -542,17 +542,17 @@ public static Transaction GetRevokeAssetTransaction(Address reserve, Address rev } /// - /// + /// /// /// /// /// /// /// - public static Transaction GetDestroyAssetTransaction(Address manager, ulong? assetId, TransactionParams trans, + public static Transaction GetDestroyAssetTransaction(Address manager, ulong? assetId, TransactionParams trans, string message = "", ulong? flatFee = null) { - var tx = Transaction.CreateAssetDestroyTransaction(manager, 1, trans.LastRound, trans.LastRound + 1000, + var tx = Transaction.CreateAssetDestroyTransaction(manager, 1, trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), new Digest(trans.Genesishashb64), assetId); if (flatFee is null || flatFee == 0) { @@ -565,7 +565,7 @@ public static Transaction GetDestroyAssetTransaction(Address manager, ulong? ass //Account.SetFeeByFeePerByte(tx, trans.Fee); return tx; } - public static Transaction GetDestroyAssetTransaction(Address manager, ulong? assetId, TransactionParametersResponse trans, + public static Transaction GetDestroyAssetTransaction(Address manager, ulong? assetId, TransactionParametersResponse trans, string message = "", ulong? flatFee = null) { var tx = Transaction.CreateAssetDestroyTransaction(manager, 1, (ulong?)trans.LastRound, (ulong?)trans.LastRound + 1000, @@ -585,26 +585,26 @@ private static void ValidateAsset(AssetParams asset) { if (asset.Creator is null || asset.Creator == "") throw new ArgumentException("The sender must be specified."); else if (!Address.IsValid(asset.Creator)) throw new ArgumentException("The sender address is not valid."); - + if (asset.Assetname is null || asset.Assetname == "") throw new ArgumentException("The asset name must be specified."); - + if (asset.Unitname is null || asset.Unitname == "") throw new ArgumentException("The unit name must be specified."); else if (asset.Unitname.Length > 8) throw new ArgumentException(string.Format("The length of unit name is {0} > 8.", asset.Unitname.Length)); - + if (asset.Total is null || asset.Total < 1) throw new ArgumentException("The total number of the asset must be specified and bigger than zero."); - + if (asset.Managerkey is null) asset.Managerkey = asset.Creator; else if (asset.Managerkey != "" && !Address.IsValid(asset.Managerkey)) throw new ArgumentException("The manager address is not valid."); - + if (asset.Reserveaddr is null) asset.Reserveaddr = asset.Managerkey; else if (asset.Reserveaddr != "" && !Address.IsValid(asset.Reserveaddr)) throw new ArgumentException("The reserve address is not valid."); - + if (asset.Freezeaddr is null) asset.Freezeaddr = asset.Managerkey; else if (asset.Freezeaddr != "" && !Address.IsValid(asset.Freezeaddr)) throw new ArgumentException("The freeze address is not valid."); - + if (asset.Clawbackaddr is null) asset.Clawbackaddr = asset.Managerkey; else if (asset.Clawbackaddr != "" && !Address.IsValid(asset.Clawbackaddr)) throw new ArgumentException("The clawback address is not valid."); - + if (asset.Metadatahash is null || asset.Metadatahash == "") asset.Metadatahash = GetRandomAssetMetaHash();//auto generate metahash by sdk else if (Convert.FromBase64String(asset.Metadatahash).Length != 32) @@ -615,26 +615,26 @@ private static void ValidateAsset(V2.Algod.Model.AssetParams asset) { if (asset.Creator is null || asset.Creator == "") throw new ArgumentException("The sender must be specified."); else if (!Address.IsValid(asset.Creator)) throw new ArgumentException("The sender address is not valid."); - + if (asset.Name is null || asset.Name == "") throw new ArgumentException("The asset name must be specified."); - + if (asset.UnitName is null || asset.UnitName == "") throw new ArgumentException("The unit name must be specified."); else if (asset.UnitName.Length > 8) throw new ArgumentException(string.Format("The length of unit name is {0} > 8.", asset.UnitName.Length)); - + if (asset.Total is null || asset.Total < 1) throw new ArgumentException("The total number of the asset must be specified and bigger than zero."); - + if (asset.Manager is null) asset.Manager = asset.Creator; else if (asset.Manager != "" && !Address.IsValid(asset.Manager)) throw new ArgumentException("The manager address is not valid."); - + if (asset.Reserve is null) asset.Reserve = asset.Manager; else if (asset.Reserve != "" && !Address.IsValid(asset.Reserve)) throw new ArgumentException("The reserve address is not valid."); - + if (asset.Freeze is null) asset.Freeze = asset.Manager; else if (asset.Freeze != "" && !Address.IsValid(asset.Freeze)) throw new ArgumentException("The freeze address is not valid."); - + if (asset.Clawback is null) asset.Clawback = asset.Manager; else if (asset.Clawback != "" && !Address.IsValid(asset.Clawback)) throw new ArgumentException("The clawback address is not valid."); - + if (asset.MetadataHash is null || asset.MetadataHash.Length == 0) asset.MetadataHash = Encoding.UTF8.GetBytes(GetRandomAssetMetaHash());//auto generate metahash by sdk else if (asset.MetadataHash.Length != 32) @@ -643,7 +643,7 @@ private static void ValidateAsset(V2.Algod.Model.AssetParams asset) if (asset.DefaultFrozen is null) asset.DefaultFrozen = false; } /// - /// + /// /// /// /// @@ -669,7 +669,7 @@ public static Transaction GetBidTransaction(Address bidder, Address auction, Sig return tx; } ///// - ///// + ///// ///// ///// ///// @@ -682,7 +682,7 @@ public static Transaction GetBidTransaction(Address bidder, Address auction, Sig ///// ///// ///// - //public static Transaction GetApplicationTransaction(Address sender, long firstValid, long lastValid, string genesishashb64, + //public static Transaction GetApplicationTransaction(Address sender, long firstValid, long lastValid, string genesishashb64, // OnCompletion onCompletion, long applicationId, List applicationArgs, List
accounts, List foreignApps, List foreignAssets) //{ // var txn = new Transaction @@ -701,7 +701,7 @@ public static Transaction GetBidTransaction(Address bidder, Address auction, Sig // if (applicationId >= 0) txn.applicationId = (ulong?)applicationId; // else throw new ArgumentException("Please set right application Id."); - // //if (onCompletion != new OnCompletion()) + // //if (onCompletion != new OnCompletion()) // txn.onCompletion = onCompletion; // //else throw new ArgumentException("OnCompletion is required, please file a bug report."); // if (applicationArgs != null) txn.applicationArgs = applicationArgs; @@ -799,7 +799,7 @@ public static Transaction GetApplicationCallTransaction(Address sender, ulong? a /// clear program /// suggested transaction params /// update application transaction - public static Transaction GetApplicationUpdateTransaction(Address sender, ulong? applicationId, + public static Transaction GetApplicationUpdateTransaction(Address sender, ulong? applicationId, TEALProgram approvalProgram, TEALProgram clearProgram, TransactionParametersResponse trans) { var fee = (ulong?)trans.Fee; @@ -892,7 +892,7 @@ public static Transaction GetApplicationCloseTransaction(Address sender, ulong? return txn; } ///// - ///// + ///// ///// ///// ///// @@ -909,10 +909,10 @@ public static Transaction GetApplicationCloseTransaction(Address sender, ulong? // Account.SetFeeByFeePerByte(tx, trans.Fee); // return tx; //} - //public static Transaction GetLogicSignatureTransaction(LogicsigSignature lsig, Address receiver, + //public static Transaction GetLogicSignatureTransaction(LogicsigSignature lsig, Address receiver, // TransactionParametersResponse trans, string message = "") //{ - // var tx = new Transaction(lsig.ToAddress(), receiver, 1, (ulong?)trans.LastRound, + // var tx = new Transaction(lsig.ToAddress(), receiver, 1, (ulong?)trans.LastRound, // (ulong?)trans.LastRound + 1000, trans.GenesisId, new Digest(trans.GenesisHash)) // { // note = Encoding.UTF8.GetBytes(message) @@ -932,7 +932,7 @@ public static Transaction GetApplicationCloseTransaction(Address sender, ulong? // return tx; //} /// - /// + /// /// /// /// @@ -942,7 +942,7 @@ public static Transaction GetApplicationCloseTransaction(Address sender, ulong? { List sources = new List(); List stxns = new List(); - //compiled + //compiled if (source is null) { stxns.Add(stxn); diff --git a/dotnet-algorand-sdk/V2/Indexer/LookupApi.cs b/dotnet-algorand-sdk/V2/Indexer/LookupApi.cs index 30462562..f504a0fe 100644 --- a/dotnet-algorand-sdk/V2/Indexer/LookupApi.cs +++ b/dotnet-algorand-sdk/V2/Indexer/LookupApi.cs @@ -419,9 +419,6 @@ public System.Threading.Tasks.Task TransactionsGetAsync(int? limit, s /// A server side error occurred. public async System.Threading.Tasks.Task TransactionsGetAsync(int? limit, string next, string note_prefix, TxType? tx_type, SigType? sig_type, string txid, ulong? round, ulong? min_round, ulong? max_round, int? asset_id, System.DateTimeOffset? before_time, System.DateTimeOffset? after_time, ulong? currency_greater_than, ulong? currency_less_than, string account_id, bool? rekey_to, System.Threading.CancellationToken cancellationToken) { - if (account_id == null) - throw new System.ArgumentNullException("account_id"); - var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/v2/accounts/{account-id}/transactions?"); urlBuilder_.Replace("{account-id}", System.Uri.EscapeDataString(ConvertToString(account_id, System.Globalization.CultureInfo.InvariantCulture))); diff --git a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs index bc21e519..c6eecd16 100644 --- a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs @@ -994,7 +994,9 @@ public partial class Transaction ///
* \[acfg\] asset-config-transaction ///
* \[axfer\] asset-transfer-transaction ///
* \[afrz\] asset-freeze-transaction - ///
* \[appl\] application-transaction
+ ///
* \[appl\] application-transaction + ///
* \[stpf\] state-proof-transaction + ///
[Newtonsoft.Json.JsonProperty("tx-type")] //, Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] @@ -1311,7 +1313,9 @@ public enum TxType [System.Runtime.Serialization.EnumMember(Value = @"appl")] Appl = 5, - + + [System.Runtime.Serialization.EnumMember(Value = @"stpf")] + Stpf = 6 } /// SigType filters just results using the specified type of signature: @@ -1619,6 +1623,8 @@ public enum TransactionTxType [System.Runtime.Serialization.EnumMember(Value = @"appl")] Appl = 5, + [System.Runtime.Serialization.EnumMember(Value = @"stpf")] + Stpf = 6 } [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0))")] diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index 319d576b..276714f0 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -1,12 +1,12 @@  - netstandard2.0 + net6.0 Algorand Algorand true true - 0.2.1.0 + 0.2.2.0-beta6 Riley Ge Tson Tec Algorand .NET SDK @@ -16,8 +16,8 @@ The Algorand SDK. AVM 1.0 , Indexer 2.8 branch and Algo rel/stable branch (Nov 2021) true - 0.2.1.0 - 0.2.1.0 + 0.2.2.0 + 0.2.2.0 LICENSE diff --git a/sdk-examples/sdk-examples.csproj b/sdk-examples/sdk-examples.csproj index 688a785b..8b7c2bbf 100644 --- a/sdk-examples/sdk-examples.csproj +++ b/sdk-examples/sdk-examples.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + net6.0 sdk_examples sdk_examples.Program diff --git a/test/test.csproj b/test/test.csproj index c29272af..1232016e 100644 --- a/test/test.csproj +++ b/test/test.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false From 613ed12ee292df850149afe904c906c71cf48d29 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Wed, 26 Apr 2023 23:11:41 +0200 Subject: [PATCH 02/14] Use bigint for indexer props --- dotnet-algorand-sdk/V2/Indexer/Model/Model.cs | 29 ++++++++++--------- .../dotnet-algorand-sdk.csproj | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs index c6eecd16..76a17358 100644 --- a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs @@ -15,11 +15,14 @@ namespace Algorand.V2.Indexer.Model { using Newtonsoft.Json; + using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.IO; + using System.Numerics; + using System.Runtime.Serialization; using System = global::System; @@ -38,11 +41,11 @@ public partial class Account /// \[algo\] total number of MicroAlgos in the account [Newtonsoft.Json.JsonProperty("amount")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } /// specifies the amount of MicroAlgos in the account, without the pending rewards. [Newtonsoft.Json.JsonProperty("amount-without-pending-rewards")]//)] //)] //, Required = Newtonsoft.Json.Required.Always)] - public ulong AmountWithoutPendingRewards { get; set; } + public BigInteger AmountWithoutPendingRewards { get; set; } /// \[appl\] applications local data stored in this account. ///
@@ -369,7 +372,7 @@ public partial class AssetHolding { /// \[a\] number of units held. [Newtonsoft.Json.JsonProperty("amount")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } /// Asset ID of the holding. [Newtonsoft.Json.JsonProperty("asset-id")] //, Required = Newtonsoft.Json.Required.Always)] @@ -452,7 +455,7 @@ public partial class AssetParams /// \[t\] The total number of units of this asset. [Newtonsoft.Json.JsonProperty("total")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Total { get; set; } + public BigInteger Total { get; set; } /// \[un\] Name of a unit of this asset, as supplied by the creator. Included only when the name of a unit of this asset is composed of printable utf-8 characters. [Newtonsoft.Json.JsonProperty("unit-name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -469,8 +472,6 @@ public partial class AssetParams /// Base64 encoded URL where more information about the asset can be retrieved. [Newtonsoft.Json.JsonProperty("url-b64", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public byte[] UrlB64 { get; set; } - - } /// Block information. @@ -663,7 +664,7 @@ public partial class MiniAssetHolding public string Address { get; set; } [Newtonsoft.Json.JsonProperty("amount")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } [Newtonsoft.Json.JsonProperty("is-frozen")] //, Required = Newtonsoft.Json.Required.Always)] public bool IsFrozen { get; set; } @@ -898,11 +899,11 @@ public partial class Transaction /// \[rc\] rewards applied to close-remainder-to account. [Newtonsoft.Json.JsonProperty("close-rewards", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? CloseRewards { get; set; } + public BigInteger? CloseRewards { get; set; } /// \[ca\] closing amount for transaction. [Newtonsoft.Json.JsonProperty("closing-amount", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? ClosingAmount { get; set; } + public BigInteger? ClosingAmount { get; set; } /// Round when the transaction was confirmed. [Newtonsoft.Json.JsonProperty("confirmed-round", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -1127,15 +1128,15 @@ public partial class TransactionAssetTransfer { /// \[aamt\] Amount of asset to transfer. A zero amount transferred to self allocates that asset in the account's Assets map. [Newtonsoft.Json.JsonProperty("amount")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } /// \[xaid\] ID of the asset being transferred. [Newtonsoft.Json.JsonProperty("asset-id")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong AssetId { get; set; } + public BigInteger AssetId { get; set; } /// Number of assets transfered to the close-to account as part of the transaction. [Newtonsoft.Json.JsonProperty("close-amount", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ulong? CloseAmount { get; set; } + public BigInteger? CloseAmount { get; set; } /// \[aclose\] Indicates that the asset should be removed from the account's Assets map, and specifies where the remaining asset holdings should be transferred. It's always valid to transfer remaining asset holdings to the creator account. [Newtonsoft.Json.JsonProperty("close-to", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -1196,11 +1197,11 @@ public partial class TransactionPayment { /// \[amt\] number of MicroAlgos intended to be transferred. [Newtonsoft.Json.JsonProperty("amount")] //, Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } /// Number of MicroAlgos that were sent to the close-remainder-to address when closing the sender account. [Newtonsoft.Json.JsonProperty("close-amount", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? CloseAmount { get; set; } + public BigInteger? CloseAmount { get; set; } /// \[close\] when set, indicates that the sending account should be closed and all remaining funds be transferred to this address. [Newtonsoft.Json.JsonProperty("close-remainder-to", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index 276714f0..a61d2599 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta6 + 0.2.2.0-beta8 Riley Ge Tson Tec Algorand .NET SDK From ea1457e2cc52b504017813fbd49f88bb6dac40c9 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Mon, 1 May 2023 09:58:37 +0200 Subject: [PATCH 03/14] Update version --- dotnet-algorand-sdk/dotnet-algorand-sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index a61d2599..f88058f5 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta8 + 0.2.2.0-beta9 Riley Ge Tson Tec Algorand .NET SDK From 778befa752a514c2e9e0b5b70858931137b407f4 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Thu, 4 May 2023 14:00:51 +0200 Subject: [PATCH 04/14] Disable state delta on TX due to overflow issues --- dotnet-algorand-sdk/V2/Indexer/Model/Model.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs index 76a17358..e8e8c2a7 100644 --- a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs @@ -1004,12 +1004,12 @@ public partial class Transaction public TransactionTxType TxType { get; set; } /// \[ld\] Local state key/value changes for the application being executed by this transaction. - [Newtonsoft.Json.JsonProperty("local-state-delta", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection LocalStateDelta { get; set; } + //[Newtonsoft.Json.JsonProperty("local-state-delta", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + //public System.Collections.Generic.ICollection LocalStateDelta { get; set; } /// \[gd\] Global state key/value changes for the application being executed by this transaction. - [Newtonsoft.Json.JsonProperty("global-state-delta", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public StateDelta GlobalStateDelta { get; set; } + //[Newtonsoft.Json.JsonProperty("global-state-delta", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + //public StateDelta GlobalStateDelta { get; set; } /// \[lg\] Logs for the application being executed by this transaction. [Newtonsoft.Json.JsonProperty("logs", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] From 8ac96abc460080672de7c08c5d9bf53a40834c69 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Mon, 8 May 2023 10:20:41 +0200 Subject: [PATCH 05/14] Push beta version --- dotnet-algorand-sdk/dotnet-algorand-sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index f88058f5..fbcbad64 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta9 + 0.2.2.0-beta10 Riley Ge Tson Tec Algorand .NET SDK From 0f35c59ca7b6af1c88105e0771f38cc440a5fa97 Mon Sep 17 00:00:00 2001 From: Paul van Grol Date: Tue, 31 Oct 2023 15:03:57 +0100 Subject: [PATCH 06/14] Remove Creator from AssetHolding --- dotnet-algorand-sdk/V2/Algod/Model/Model.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs index e3f1c7ea..210c819f 100644 --- a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs @@ -172,11 +172,6 @@ public partial class AssetHolding [Newtonsoft.Json.JsonProperty("asset-id", Required = Newtonsoft.Json.Required.Always)] public ulong AssetId { get; set; } - /// Address that created this asset. This is the address where the parameters for this asset can be found, and also the address where unwanted asset units can be sent in the worst case. - [Newtonsoft.Json.JsonProperty("creator", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Creator { get; set; } - /// \[f\] whether or not the holding is frozen. [Newtonsoft.Json.JsonProperty("is-frozen", Required = Newtonsoft.Json.Required.Always)] public bool IsFrozen { get; set; } From 7fad863355ac394a2dbc54f98bacf5efebdfd197 Mon Sep 17 00:00:00 2001 From: Paul van Grol Date: Mon, 8 Jan 2024 16:19:06 +0100 Subject: [PATCH 07/14] Update AssetParams total to be BigInteger --- dotnet-algorand-sdk/V2/Algod/Model/Model.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs index 210c819f..a0adc1a0 100644 --- a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs @@ -14,6 +14,7 @@ namespace Algorand.V2.Algod.Model { + using System.Numerics; using System = global::System; /// Account information at a given round. @@ -232,7 +233,7 @@ public partial class AssetParams /// \[t\] The total number of units of this asset. [Newtonsoft.Json.JsonProperty("total", Required = Newtonsoft.Json.Required.Always)] - public ulong? Total { get; set; } + public BigInteger? Total { get; set; } /// \[un\] Name of a unit of this asset, as supplied by the creator. Included only when the name of a unit of this asset is composed of printable utf-8 characters. [Newtonsoft.Json.JsonProperty("unit-name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] From 782721388ae5d82c28d4f22cfe8c38ba042ef83f Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Tue, 9 Jan 2024 10:55:36 +0100 Subject: [PATCH 08/14] Use bigint instead of ulong --- dotnet-algorand-sdk/Transaction.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dotnet-algorand-sdk/Transaction.cs b/dotnet-algorand-sdk/Transaction.cs index 3e2510c9..c9881b69 100644 --- a/dotnet-algorand-sdk/Transaction.cs +++ b/dotnet-algorand-sdk/Transaction.cs @@ -4,6 +4,7 @@ using System.Text; using System.Linq; using System.Collections.Generic; +using System.Numerics; using System.Threading; using Algorand.V2.Algod.Model; @@ -313,7 +314,7 @@ public Transaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastVal /// account which can freeze or unfreeze holder accounts /// account which can issue clawbacks against holder accounts private Transaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastValid, byte[] note, - string genesisID, Digest genesisHash, ulong? assetTotal, int assetDecimals, bool defaultFrozen, + string genesisID, Digest genesisHash, BigInteger? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, string assetName, string url, byte[] metadataHash, Address manager, Address reserve, Address freeze, Address clawback) { @@ -580,7 +581,7 @@ private Transaction(Type type, /// account which can issue clawbacks against holder accounts /// public static Transaction CreateAssetCreateTransaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastValid, byte[] note, - string genesisID, Digest genesisHash, ulong? assetTotal, int assetDecimals, bool defaultFrozen, + string genesisID, Digest genesisHash, BigInteger? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, string assetName, string url, byte[] metadataHash, Address manager, Address reserve, Address freeze, Address clawback) { @@ -1061,7 +1062,7 @@ public class AssetParams /// [JsonProperty(PropertyName = "t")] [DefaultValue(0)] - public ulong? assetTotal = 0; + public BigInteger? assetTotal = 0; /// /// Decimals specifies the number of digits to display after the decimal @@ -1133,7 +1134,7 @@ public class AssetParams public Address assetClawback = new Address(); public AssetParams( - ulong? assetTotal, + BigInteger? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, From 8f6f2e74ea5606b36d56ada1388293b695809316 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Mon, 29 Apr 2024 23:15:18 +0200 Subject: [PATCH 09/14] Increase usage of biginteger --- dotnet-algorand-sdk/V2/Algod/Model/Model.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs index a0adc1a0..682479a2 100644 --- a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs @@ -149,7 +149,7 @@ public partial class Asset { /// unique asset identifier [Newtonsoft.Json.JsonProperty("index", Required = Newtonsoft.Json.Required.Always)] - public int Index { get; set; } + public BigInteger Index { get; set; } [Newtonsoft.Json.JsonProperty("params", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] @@ -167,11 +167,11 @@ public partial class AssetHolding { /// \[a\] number of units held. [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.Always)] - public ulong Amount { get; set; } + public BigInteger Amount { get; set; } /// Asset ID of the holding. [Newtonsoft.Json.JsonProperty("asset-id", Required = Newtonsoft.Json.Required.Always)] - public ulong AssetId { get; set; } + public BigInteger AssetId { get; set; } /// \[f\] whether or not the holding is frozen. [Newtonsoft.Json.JsonProperty("is-frozen", Required = Newtonsoft.Json.Required.Always)] From 7f8478bab0403afaa57ac968166d337df0878463 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Mon, 29 Apr 2024 23:17:00 +0200 Subject: [PATCH 10/14] Bump version to beta13 --- dotnet-algorand-sdk/dotnet-algorand-sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index fbcbad64..4a72c335 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta10 + 0.2.2.0-beta13 Riley Ge Tson Tec Algorand .NET SDK From 6a55e7a4c83558df0c0431cb1308c78c27dde0f9 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Fri, 12 Jul 2024 20:59:45 +0200 Subject: [PATCH 11/14] Refactor code and optimize asset total type - Removed unused namespaces (`System.Numerics`, `System.Threading`, `Algorand.V2.Algod.Model`) from `Transaction.cs` to clean up the codebase. - Changed `assetTotal` type from `BigInteger?` to `ulong?` in `Transaction` constructor, `CreateAssetCreateTransaction` method, `AssetParams` constructor, and `Total` property in `Model.cs`. This standardizes asset total representation and optimizes memory usage. - Ensured API consistency by applying the `assetTotal` type change across relevant methods and properties, facilitating easier use and understanding of the API. - Improved JSON serialization compatibility for asset totals by using `ulong?`, simplifying data interchange with other systems and services. --- dotnet-algorand-sdk/Transaction.cs | 11 ++++------- dotnet-algorand-sdk/V2/Algod/Model/Model.cs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/dotnet-algorand-sdk/Transaction.cs b/dotnet-algorand-sdk/Transaction.cs index c9881b69..92e582df 100644 --- a/dotnet-algorand-sdk/Transaction.cs +++ b/dotnet-algorand-sdk/Transaction.cs @@ -4,9 +4,6 @@ using System.Text; using System.Linq; using System.Collections.Generic; -using System.Numerics; -using System.Threading; -using Algorand.V2.Algod.Model; namespace Algorand { @@ -314,7 +311,7 @@ public Transaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastVal /// account which can freeze or unfreeze holder accounts /// account which can issue clawbacks against holder accounts private Transaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastValid, byte[] note, - string genesisID, Digest genesisHash, BigInteger? assetTotal, int assetDecimals, bool defaultFrozen, + string genesisID, Digest genesisHash, ulong? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, string assetName, string url, byte[] metadataHash, Address manager, Address reserve, Address freeze, Address clawback) { @@ -581,7 +578,7 @@ private Transaction(Type type, /// account which can issue clawbacks against holder accounts /// public static Transaction CreateAssetCreateTransaction(Address sender, ulong? fee, ulong? firstValid, ulong? lastValid, byte[] note, - string genesisID, Digest genesisHash, BigInteger? assetTotal, int assetDecimals, bool defaultFrozen, + string genesisID, Digest genesisHash, ulong? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, string assetName, string url, byte[] metadataHash, Address manager, Address reserve, Address freeze, Address clawback) { @@ -1062,7 +1059,7 @@ public class AssetParams /// [JsonProperty(PropertyName = "t")] [DefaultValue(0)] - public BigInteger? assetTotal = 0; + public ulong? assetTotal = 0; /// /// Decimals specifies the number of digits to display after the decimal @@ -1134,7 +1131,7 @@ public class AssetParams public Address assetClawback = new Address(); public AssetParams( - BigInteger? assetTotal, + ulong? assetTotal, int assetDecimals, bool defaultFrozen, string assetUnitName, diff --git a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs index 682479a2..f7c420cd 100644 --- a/dotnet-algorand-sdk/V2/Algod/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Algod/Model/Model.cs @@ -233,7 +233,7 @@ public partial class AssetParams /// \[t\] The total number of units of this asset. [Newtonsoft.Json.JsonProperty("total", Required = Newtonsoft.Json.Required.Always)] - public BigInteger? Total { get; set; } + public ulong? Total { get; set; } /// \[un\] Name of a unit of this asset, as supplied by the creator. Included only when the name of a unit of this asset is composed of printable utf-8 characters. [Newtonsoft.Json.JsonProperty("unit-name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] From 0e46d50f5f1e241bbf068371aaf3564ab6a79c90 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Thu, 23 Jan 2025 21:46:49 +0100 Subject: [PATCH 12/14] Add Hb support --- dotnet-algorand-sdk/V2/Indexer/Model/Model.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs index e8e8c2a7..f30eece9 100644 --- a/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs +++ b/dotnet-algorand-sdk/V2/Indexer/Model/Model.cs @@ -15,6 +15,7 @@ namespace Algorand.V2.Indexer.Model { using Newtonsoft.Json; + using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; @@ -1316,7 +1317,10 @@ public enum TxType Appl = 5, [System.Runtime.Serialization.EnumMember(Value = @"stpf")] - Stpf = 6 + Stpf = 6, + + [System.Runtime.Serialization.EnumMember(Value = @"hb")] + Hb = 7 } /// SigType filters just results using the specified type of signature: @@ -1625,7 +1629,10 @@ public enum TransactionTxType Appl = 5, [System.Runtime.Serialization.EnumMember(Value = @"stpf")] - Stpf = 6 + Stpf = 6, + + [System.Runtime.Serialization.EnumMember(Value = @"hb")] + Hb = 7 } [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0))")] From b1de7e7820e0b131d6b4a96628515cc1d0b8d7cc Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Thu, 23 Jan 2025 21:47:24 +0100 Subject: [PATCH 13/14] Bump to beta14 --- dotnet-algorand-sdk/dotnet-algorand-sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index 4a72c335..b880816e 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta13 + 0.2.2.0-beta14 Riley Ge Tson Tec Algorand .NET SDK From 3722ea538ade4f41d1606043254752d0c426efd7 Mon Sep 17 00:00:00 2001 From: Raymen Scholten Date: Thu, 23 Jan 2025 21:50:46 +0100 Subject: [PATCH 14/14] Bump to beta 19 --- dotnet-algorand-sdk/dotnet-algorand-sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj index b880816e..90ee523a 100644 --- a/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj +++ b/dotnet-algorand-sdk/dotnet-algorand-sdk.csproj @@ -6,7 +6,7 @@ Algorand true true - 0.2.2.0-beta14 + 0.2.2.0-beta19 Riley Ge Tson Tec Algorand .NET SDK