/// <summary> /// ToModifyAccountPropertyTransaction /// </summary> /// <param name="tx"></param> /// <param name="txInfo"></param> /// <returns></returns> private static ModifyAccountPropertyTransaction <IUInt64Id> ToModifyAccountPropertyTransaction(JObject tx, TransactionInfo txInfo) { var transaction = tx["transaction"].ToObject <JObject>(); var version = transaction["version"]; //Bug - It seems the dotnetcore does not //understand the Integer. //The workaround it to double cast the version int versionValue; try { versionValue = (int)((uint)version); } catch (Exception) { versionValue = (int)version; } var network = TransactionMappingUtils.ExtractNetworkType(versionValue); var txVersion = TransactionMappingUtils.ExtractTransactionVersion(versionValue); var deadline = new Deadline(transaction["deadline"].ToObject <UInt64DTO>().ToUInt64()); var maxFee = transaction["maxFee"]?.ToObject <UInt64DTO>().ToUInt64(); var signature = transaction["signature"].ToObject <string>(); var signer = new PublicAccount(transaction["signer"].ToObject <string>(), network); var type = EntityTypeExtension.GetRawValue(transaction["type"].ToObject <int>()); var propertyType = PropertyTypeExtension.GetRawValue(transaction["propertyType"].ToObject <int>()); var modifications = transaction["modifications"]; var modificationList = modifications == null ? new List <AccountPropertyModification <IUInt64Id> >() : modifications.Select(e => { var mt = e["modificationType"] ?? e["type"]; var modificationType = PropertyModificationTypeExtension.GetRawValue(mt.ToObject <int>()); var mosaicId = new MosaicId(e["value"].ToObject <UInt64DTO>().ToUInt64()); var modification = new AccountPropertyModification <IUInt64Id>(modificationType, mosaicId); return(modification); }).ToList(); if (type == EntityType.MODIFY_ACCOUNT_PROPERTY_MOSAIC) { return(new MosaicModification( network, txVersion, deadline, propertyType, modificationList, maxFee, signature, signer, txInfo )); } throw new Exception("Unsupported transaction type"); }
/// <summary> /// GetValueBytesFromModification /// </summary> /// <param name="mod">The modification property</param> /// <returns>byte[]</returns> protected override byte[] GetValueBytesFromModification(AccountPropertyModification <IUInt64Id> mod) { var byteValues = BitConverter.GetBytes(mod.Value.Id); Guard.NotEqualTo(byteValues.Length, VALUE_BYTES_LENGTH, new ArgumentException( $"MosaicId should be serialized to {VALUE_BYTES_LENGTH} bytes but was {byteValues.Length} from {mod.Value}")); return(byteValues); }
protected abstract byte[] GetValueBytesFromModification(AccountPropertyModification <T> mod);