/// <summary> /// Gets the mosaic levy. /// </summary> /// <param name="mosaicId">The mosaicId</param> /// <returns>IObservable<MosaicLevy></returns> /// <exception cref="ArgumentNullException">mosaicId</exception> public IObservable <MosaicLevy> GetMosaicLevyInfo(MosaicId mosaicId) { if (mosaicId == null) { throw new ArgumentNullException(nameof(mosaicId.HexId)); } var route = $"{BasePath}/mosaic/{mosaicId.HexId}/levy"; var networkType = GetNetworkTypeObservable().Take(1); return(Observable.FromAsync(async ar => await route.GetJsonAsync <MosaicLevyInfoDTO>()) .Select(info => new MosaicLevy( MosaicLevyTypeExtension.GetRawValue((int)info.Type), new Recipient(new Address(info.Recipient, networkType.Wait())), new MosaicId(info.mosaic.FromUInt8Array()), info.Fee.ToUInt64() ))); }
/// <summary> /// Converts to AccountLinkTransactionMapping /// </summary> /// <param name="tx"></param> /// <param name="txInfo"></param> /// <returns></returns> private static ModifyMosaicLevyTransaction ToMosaicModifyLevyTransaction(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 mosaicId = new MosaicId(transaction["mosaicId"].ToObject <UInt64DTO>().ToUInt64()); var levy = transaction["levy"].ToObject <JObject>(); var fee = levy["fee"].ToObject <UInt64DTO>().ToUInt64(); var type = MosaicLevyTypeExtension.GetRawValue(levy["type"].ToObject <int>()); var levy_mosaicId = new MosaicId(levy["mosaicId"].ToObject <UInt64DTO>().ToUInt64()); var recipient = levy["recipient"].ToObject <string>(); var modifyMosaicLevyTransaction = new ModifyMosaicLevyTransaction(network, txVersion, deadline, mosaicId, new MosaicLevy(type, Recipient.From(Address.CreateFromHex(recipient)), levy_mosaicId, fee), maxFee, signature, signer, txInfo); return(modifyMosaicLevyTransaction); }