/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as TicketNFT; Location = nft.Location; LocationCoordinates = nft.LocationCoordinates; LocationCoordinatesLat = nft.LocationCoordinatesLat; LocationCoordinatesLen = nft.LocationCoordinatesLen; MintAuthorAddress = nft.MintAuthorAddress; VideoLink = nft.VideoLink; AuthorLink = nft.AuthorLink; EventDate = nft.EventDate; TicketClass = nft.TicketClass; TicketDuration = nft.TicketDuration; EventId = nft.EventId; EventAddress = nft.EventAddress; if (!string.IsNullOrEmpty(nft.EventNFTForTheTicket.Utxo)) { EventNFTForTheTicket = nft.EventNFTForTheTicket; } Seat = nft.Seat; MusicInLink = nft.MusicInLink; Used = nft.Used; AddUsedTags(); }
/// <summary> /// TODO /// </summary> /// <param name="nft"></param> /// <param name="categories"></param> /// <param name="quantity"></param> /// <param name="options"></param> /// <returns></returns> public async Task <Product> AddProduct(INFT nft, List <Category> categories, int quantity = 1, Dictionary <string, string> options = null) { try { var prod = await WooCommerceHelpers.AddNewProduct(nft, categories, quantity, WooCommerceHelpers.GetFullAPIUrl($"products", WooCommerceStoreUrl, WooCommerceStoreAPIKey, WooCommerceStoreSecret), options); if (Products.TryGetValue(prod.id, out var prd)) { prd = prod; } else { Products.TryAdd(prod.id, prod); } return(prod); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void LoadNFT(INFT nft) { if (nft != null) { NFT = nft; Utxo = NFT.Utxo; UtxoIndex = NFT.UtxoIndex; StateHasChanged(); } }
public override async Task Fill(INFT NFT) { await FillCommon(NFT); IsReceivedMessage = (NFT as IoTMessageNFT).IsReceivedMessage; Partner = (NFT as IoTMessageNFT).Partner; Encrypt = (NFT as IoTMessageNFT).Encrypt; Decrypted = (NFT as IoTMessageNFT).Decrypted; ImageData = (NFT as IoTMessageNFT).ImageData; }
public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as ProtocolNFT; Version = nft.Version; Rules = nft.Rules; RulesFile = nft.RulesFile; }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var pnft = NFT as ProductNFT; ProducerProfileNFT = pnft.ProducerProfileNFT; Datasheet = pnft.Datasheet; UnitPrice = pnft.UnitPrice; }
public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as SWSrcNFT; Version = nft.Version; Tool = nft.Tool; RepositoryType = nft.RepositoryType; RepositoryLink = nft.RepositoryLink; }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var pnft = NFT as ProfileNFT; Surname = pnft.Surname; Nickname = pnft.Nickname; RelationshipStatus = pnft.RelationshipStatus; Age = pnft.Age; ID = pnft.ID; }
/// <summary> /// Fill the NFT with data /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); if (NFT.Type == NFTTypes.CoruzantArticle) { var nft = NFT as CoruzantArticleNFT; LastComment = nft.LastComment; LastCommentBy = nft.LastCommentBy; FullPostLink = nft.FullPostLink; PodcastLink = nft.PodcastLink; AuthorProfileUtxo = nft.AuthorProfileUtxo; } }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var pnft = NFT as ReceiptNFT; NFTUtxoTxId = pnft.NFTUtxoTxId; NFTUtxoIndex = pnft.NFTUtxoIndex; Sender = pnft.Sender; SoldPrice = pnft.SoldPrice; Buyer = pnft.Buyer; OriginalPaymentTxId = pnft.OriginalPaymentTxId; ReceiptFromPaymentUtxo = pnft.ReceiptFromPaymentUtxo; }
public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as XrayNFT; DeviceName = nft.DeviceName; DetectorName = nft.DetectorName; SourceName = nft.SourceName; PositionerName = nft.PositionerName; DetectorParameters = nft.DetectorParameters; SourceParameters = nft.SourceParameters; PositionerParameters = nft.PositionerParameters; }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var pnft = NFT as PaymentNFT; NFTUtxoTxId = pnft.NFTUtxoTxId; NFTUtxoIndex = pnft.NFTUtxoIndex; Matched = pnft.Matched; Sender = pnft.Sender; AlreadySoldItem = pnft.AlreadySoldItem; Returned = pnft.Returned; OriginalPaymentTxId = pnft.OriginalPaymentTxId; }
/// <summary> /// Fill NFT with data from template /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as DeviceNFT; Version = nft.Version; ProtocolNFTHash = nft.ProtocolNFTHash; HWSrcNFTHash = nft.HWSrcNFTHash; FWSrcNFTHash = nft.FWSrcNFTHash; SWSrcNFTHash = nft.SWSrcNFTHash; MechSrcNFTHash = nft.MechSrcNFTHash; MAC = nft.MAC; UniqueId = nft.UniqueId; }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as XrayImageNFT; XrayParams = nft.XrayParams; IsOriginal = nft.IsOriginal; IsRaw = nft.IsRaw; IsAveraged = nft.IsAveraged; CountOfFrames = nft.CountOfFrames; DetectorParameters = nft.DetectorParameters; ObjectPosition = nft.ObjectPosition; XrayDeviceNFTHash = nft.XrayDeviceNFTHash; XrayDeviceNFT = nft.XrayDeviceNFT; }
public DataItemType ActualFileTypeFromNFT(INFT nft) { if (nft.DataItems != null && nft.DataItems.Count >= 0) { foreach (var item in nft.DataItems) { if (item.IsMain) { return(item.Type); } } if (nft.DataItems.Count > 0) { return(nft.DataItems.FirstOrDefault()?.Type ?? DataItemType.Image); } } return(DataItemType.Image); }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var pnft = NFT as InvoiceNFT; InvoiceItems = pnft.InvoiceItems; SellerProfileNFT = pnft.SellerProfileNFT; TotalPrice = pnft.TotalPrice; BuyerProfileNFT = pnft.BuyerProfileNFT; OriginalPaymentTxId = pnft.OriginalPaymentTxId; OrderTxId = pnft.OrderTxId; AlreadyPaid = pnft.AlreadyPaid; ExposeDate = pnft.ExposeDate; FileLink = pnft.FileLink; MaxCountOfDaysFromExposeToPayment = pnft.MaxCountOfDaysFromExposeToPayment; MaxCountOfDaysAfterPaymentDate = pnft.MaxCountOfDaysAfterPaymentDate; }
/// <summary> /// Load Xray device NFT /// </summary> /// <returns></returns> public async Task LoadXrayNFT() { if (!string.IsNullOrEmpty(XrayDeviceNFTHash)) { try { var nft = await NFTFactory.GetNFT("", XrayDeviceNFTHash, 0, 0, true, true, NFTTypes.Xray); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { XrayDeviceNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the Xray NFT: {XrayDeviceNFTHash} in XrayImageNFT: {Utxo}, exception: {ex.Message}"); } } }
public string ActualImageLinkFromNFT(INFT nft) { if (nft.DataItems != null && nft.DataItems.Count >= 0) { foreach (var item in nft.DataItems) { if (item.IsMain) { return(NFTHelpers.GetIPFSLinkFromHash(item.Hash)); } } if (nft.DataItems.Count > 0) { var il = NFTHelpers.GetIPFSLinkFromHash(nft.DataItems.FirstOrDefault()?.Hash); return(!string.IsNullOrEmpty(il) ? il : GetImageUrl()); } } return(GetImageUrl()); }
/// <summary> /// Fill the data from template /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); if (NFT.Type == NFTTypes.CoruzantProfile) { var pnft = NFT as CoruzantProfileNFT; Surname = pnft.Surname; Nickname = pnft.Nickname; CompanyLink = pnft.CompanyLink; CompanyName = pnft.CompanyName; PodcastLink = pnft.PodcastLink; PodcastId = pnft.PodcastId; PersonalPageLink = pnft.PersonalPageLink; WorkingPosition = pnft.WorkingPosition; Age = pnft.Age; Linkedin = pnft.Linkedin; Twitter = pnft.Twitter; } }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); var nft = NFT as EventNFT; PriceInDoge = nft.PriceInDoge; PriceInDogeActive = nft.PriceInDogeActive; MintAuthorAddress = nft.MintAuthorAddress; Location = nft.Location; LocationCoordinates = nft.LocationCoordinates; LocationCoordinatesLat = nft.LocationCoordinatesLat; LocationCoordinatesLen = nft.LocationCoordinatesLen; VideoLink = nft.VideoLink; AuthorLink = nft.AuthorLink; EventDate = nft.EventDate; EventClass = nft.EventClass; EventId = nft.EventId; MusicInLink = nft.MusicInLink; Used = nft.Used; }
/// <summary> /// Init driver communication - means autorefresh of the messages /// </summary> /// <param name="nft"></param> /// <returns></returns> public override async Task Init(INFT nft) { CancelToken = CancelTokenSource.Token; _ = Task.Run(async() => { IsRunning = true; var quit = false; while (!quit) { if (CancelToken.IsCancellationRequested) { quit = true; } try { var res = await RequestNewMessageFromAPI(); if (res.Item1 && !string.IsNullOrEmpty(res.Item2.id)) { if (res.Item2.id != lastmessageid) { NewDataReceived?.Invoke(this, JsonConvert.SerializeObject(res.Item2)); lastmessageid = res.Item2.id; } } } catch (Exception ex) { Console.WriteLine("Cannot obtain new message from the HARDWARIO Cloud API. " + ex.Message); } await Task.Delay(CommonConnParams.CommonRefreshInterval); } }, CancelToken); IsRunning = false; }
public async Task FillFromEvent(INFT NFT) { await FillCommon(NFT); var nft = NFT as EventNFT; EventId = nft.Utxo; Location = nft.Location; LocationCoordinates = nft.LocationCoordinates; LocationCoordinatesLat = nft.LocationCoordinatesLat; LocationCoordinatesLen = nft.LocationCoordinatesLen; MintAuthorAddress = nft.MintAuthorAddress; VideoLink = nft.VideoLink; AuthorLink = nft.AuthorLink; EventDate = nft.EventDate; MusicInLink = nft.MusicInLink; Used = nft.Used; AddUsedTags(); Type = NFTTypes.Ticket; TypeText = "NFT Ticket"; Utxo = string.Empty; UtxoIndex = 0; }
public async Task FillCommontPropertiesTestCall(INFT nft) { var newnft = await NFTFactory.CloneNFT(nft);; newnft.ImageLink = ""; newnft.Name = ""; newnft.Link = ""; newnft.Description = ""; newnft.Author = ""; nft.ImageLink = "myimagelink"; nft.Name = "mynft"; nft.Link = "mylink"; nft.Description = "mydescription"; nft.Author = "myauthor"; await newnft.Fill(nft); Assert.Equal(nft.ImageLink, newnft.ImageLink); Assert.Equal(nft.Name, newnft.Name); Assert.Equal(nft.Link, newnft.Link); Assert.Equal(nft.Description, newnft.Description); Assert.Equal(nft.Author, newnft.Author); }
/// <summary> /// Fill basic parameters /// </summary> /// <param name="NFT"></param> /// <returns></returns> public override async Task Fill(INFT NFT) { await FillCommon(NFT); }
/// <summary> /// Load the NFT based on the data from the cache /// </summary> /// <param name="metadata">Metadata from cache of NFTs</param> /// <param name="utxo">Utxo of the NFT</param> /// <param name="utxoindex">Utxo Index of the NFT</param> /// <param name="txinfo">preloaded txinfo</param> /// <param name="asType">Force the output type</param> /// <param name="type">Specify the output type - you must set asType flag</param> /// <returns>INFT compatible object</returns> public static async Task <INFT> GetNFTFromCacheMetadata(IDictionary <string, string> metadata, string utxo, int utxoindex, NeblioAPI.GetTransactionInfoResponse txinfo = null, bool asType = false, NFTTypes type = NFTTypes.Image) { if (!asType) { try { type = ParseNFTType(metadata); } catch (Exception ex) { Console.WriteLine($"Cannot load Type of NFT from cache. " + ex.Message); return(null); } } if (type == NFTTypes.IoTDevice) { return(null); } if (utxoindex == 1 && metadata.TryGetValue("ReceiptFromPaymentUtxo", out var rfp)) { if (!string.IsNullOrEmpty(rfp)) { type = NFTTypes.Receipt; } } if (txinfo == null) { txinfo = await NeblioTransactionHelpers.GetTransactionInfo(utxo); if (txinfo == null) { return(null); } if (txinfo.Vout == null) { return(null); } } var tokid = string.Empty; try { var tid = txinfo.Vout.ToList()[utxoindex]?.Tokens.ToList()[0]?.TokenId; tokid = tid; if (string.IsNullOrEmpty(tokid)) { tokid = NFTHelpers.TokenId; } } catch (Exception ex) { Console.WriteLine("Cannot parse token Id from NFT. " + ex.Message); return(null); } INFT nft = null; switch (type) { case NFTTypes.Image: nft = new ImageNFT(utxo); break; case NFTTypes.Profile: nft = new ProfileNFT(utxo); break; case NFTTypes.Post: nft = new PostNFT(utxo); break; case NFTTypes.Music: nft = new MusicNFT(utxo); break; case NFTTypes.Payment: nft = new PaymentNFT(utxo); break; case NFTTypes.Receipt: nft = new ReceiptNFT(utxo); break; case NFTTypes.Invoice: nft = new InvoiceNFT(utxo); break; case NFTTypes.Order: nft = new OrderNFT(utxo); break; case NFTTypes.Product: nft = new ProductNFT(utxo); break; case NFTTypes.Message: nft = new MessageNFT(utxo); break; case NFTTypes.Ticket: nft = new TicketNFT(utxo); break; case NFTTypes.Event: nft = new EventNFT(utxo); break; case NFTTypes.CoruzantArticle: nft = new CoruzantArticleNFT(utxo); break; case NFTTypes.CoruzantProfile: nft = new CoruzantProfileNFT(utxo); break; case NFTTypes.Device: nft = new DeviceNFT(utxo); break; case NFTTypes.IoTDevice: nft = new IoTDeviceNFT(utxo); break; case NFTTypes.Protocol: nft = new ProtocolNFT(utxo); break; case NFTTypes.HWSrc: nft = new HWSrcNFT(utxo); break; case NFTTypes.FWSrc: nft = new FWSrcNFT(utxo); break; case NFTTypes.SWSrc: nft = new SWSrcNFT(utxo); break; case NFTTypes.MechSrc: nft = new MechSrcNFT(utxo); break; case NFTTypes.IoTMessage: nft = new IoTMessageNFT(utxo); break; case NFTTypes.Xray: nft = new XrayNFT(utxo); break; case NFTTypes.XrayImage: nft = new XrayImageNFT(utxo); break; } if (nft != null) { nft.Time = TimeHelpers.UnixTimestampToDateTime((double)txinfo.Blocktime); nft.Utxo = utxo; nft.UtxoIndex = utxoindex; nft.TxDetails = txinfo; nft.TokenId = tokid; nft.IsLoaded = true; await nft.LoadLastData(metadata); if (nft.Type == NFTTypes.Message) { (nft as MessageNFT).Decrypted = false; } if (nft.Type == NFTTypes.IoTMessage) { (nft as IoTMessageNFT).Decrypted = false; } if (nft.Type == NFTTypes.IoTDevice) { (nft as IoTDeviceNFT).DecryptedSetting = false; } return(nft); } else { return(null); } }
/// <summary> /// This function will change Coruzant Post NFT /// You can use this function for sending the NFT when you will fill receiver parameter /// </summary> /// <param name="address">sender address</param> /// <param name="ekey">Encryption Key object of the address</param> /// <param name="NFT">Input NFT object with data to save to metadata. Must contain Utxo hash</param> /// <param name="nutxos">List of spendable neblio utxos if you have it loaded.</param> /// <param name="receiver">Fill when you want to send NFT to another address</param> /// <returns>New Tx Id Hash</returns> public static async Task <string> ChangeCoruzantPostNFT(string address, EncryptionKey ekey, INFT NFT, ICollection <Utxos> nutxos, NBitcoin.BitcoinSecret secret, string receiver = "") { var cnft = NFT as CoruzantArticleNFT; // create token metadata var metadata = new Dictionary <string, string>(); metadata.Add("NFT", "true"); metadata.Add("Type", "NFT CoruzantPost"); metadata.Add("Name", NFT.Name); metadata.Add("Author", NFT.Author); metadata.Add("AuthorProfileUtxo", cnft.AuthorProfileUtxo); metadata.Add("Description", NFT.Description); metadata.Add("Image", NFT.ImageLink); metadata.Add("Link", NFT.Link); metadata.Add("Tags", NFT.Tags); metadata.Add("FullPostLink", cnft.FullPostLink); metadata.Add("LastComment", cnft.LastComment); metadata.Add("LastCommentBy", cnft.LastCommentBy); if (NFT.Price > 0) { metadata.Add("Price", NFT.Price.ToString(CultureInfo.InvariantCulture)); } var rec = address; if (!string.IsNullOrEmpty(receiver)) { rec = receiver; } // fill input data for sending tx var dto = new SendTokenTxData() // please check SendTokenTxData for another properties such as specify source UTXOs { Id = CoruzantTokenId, // id of token Metadata = metadata, Amount = 1, sendUtxo = new List <string>() { NFT.Utxo }, SenderAddress = address, ReceiverAddress = rec }; try { // send tx var transaction = await NeblioTransactionHelpers.SendNFTTokenAsync(dto, nutxos); var rtxid = await NeblioTransactionHelpers.SignAndBroadcastTransaction(transaction, secret); if (rtxid != null) { return(rtxid); } else { return(string.Empty); } } catch (Exception ex) { throw ex; } }
/// <summary> /// TODO /// </summary> /// <param name="nft"></param> /// <param name="categories"></param> /// <param name="quantity"></param> /// <param name="apiurl"></param> /// <param name="options"></param> /// <returns></returns> public static async Task <Product> AddNewProduct(INFT nft, List <Category> categories, int quantity = 1, string apiurl = "", Dictionary <string, string> options = null) { try { if (IsInitialized && string.IsNullOrEmpty(apiurl)) { apiurl = GetFullAPIUrl("products"); } if (wpClient == null) { throw new Exception("Please init the connection and obtain JWT Token first."); } if (string.IsNullOrEmpty(nft.ImageLink)) { throw new Exception("Image link cannot be empty."); } if (categories == null || categories.Count == 0) { throw new Exception("Please provide at least one category."); } if (System.Text.RegularExpressions.Regex.Match(nft.Name, RegexMatchPaterns.EmojiPattern).Success) { throw new Exception("You cannot use Emojis in the name if you want to publish it into the shop."); } if (System.Text.RegularExpressions.Regex.Match(nft.Description, RegexMatchPaterns.EmojiPattern).Success) { throw new Exception("You cannot use Emojis in the description if you want to publish it into the shop."); } Product p = null; var link = nft.ImageLink; var productlink = nft.ImageLink; var desc = nft.Description; if (nft.Type == NFTTypes.Music || (nft.Type == NFTTypes.Ticket && (nft as TicketNFT).MusicInLink) || (nft.Type == NFTTypes.Event && (nft as EventNFT).MusicInLink)) { productlink = nft.Link; //desc += " - This NFT contains music which is available after your order is finished."; } var price = "0.0"; if (nft.DogePriceActive) { price = Convert.ToString(nft.DogePrice, CultureInfo.InvariantCulture).Replace(",", "."); } else if (nft.PriceActive) { price = Convert.ToString(nft.Price, CultureInfo.InvariantCulture).Replace(",", "."); } var resi = await UploadIFPSImageToWP(link, nft.Name.Replace(" ", "_")); // todo add illegal chars check/cleanup var imagelink = string.Empty; if (resi.Item1) { imagelink = resi.Item2; } var authorDogeAddress = string.Empty; if (!string.IsNullOrEmpty(nft.DogeftInfo.AuthorDogeAddress)) { authorDogeAddress = nft.DogeftInfo.AuthorDogeAddress; } var metadata = await nft.GetMetadata(); if (metadata.ContainsKey("SoldInfo")) { metadata.Remove("SoldInfo"); } if (metadata.ContainsKey("DogeftInfo")) { metadata.Remove("DogeftInfo"); } p = new Product() { name = nft.Name, description = nft.Text, regular_price = price, images = new List <ImageObject>() { new ImageObject() { src = imagelink } }, status = "publish", categories = categories, downloadable = true, stock_quantity = quantity, stock_status_enum = StockStatus.instock, _virtual = true, type = "simple", short_description = desc, meta_data = new List <ProductMetadata>() { new ProductMetadata() { key = "Author", value = nft.Author }, new ProductMetadata() { key = "Utxo", value = nft.Utxo }, new ProductMetadata() { key = "Utxoindex", value = nft.UtxoIndex.ToString() }, new ProductMetadata() { key = "ShortHash", value = nft.ShortHash }, new ProductMetadata() { key = "AuthorDogeAddress", value = authorDogeAddress }, new ProductMetadata() { key = "NFTData", value = JsonConvert.SerializeObject(metadata) } }, downloads = new List <DownloadsObject>() { new DownloadsObject() { name = "NFT on IPFS", file = productlink, external_url = $"https://nft.ve-nft.com/?txid={nft.Utxo}", categories = new List <CategoryOfDownloads>() { new CategoryOfDownloads() { id = 3 } } } } }; if (options != null) { foreach (var o in options) { p.meta_data.Add(new ProductMetadata() { key = o.Key, value = o.Value }); } } var pr = JsonConvert.SerializeObject(p); pr = pr.Replace("_virtual", "virtual"); var content = new StringContent(pr, Encoding.UTF8, "application/json"); try { var res = await httpClient.PostAsync(apiurl, content); var resmsg = await res.Content.ReadAsStringAsync(); //Console.WriteLine(resmsg); var prd = JsonConvert.DeserializeObject <Product>(resmsg); return(prd); } catch (Exception ex) { ////log.Error("Cannot upload WooCommerce product. " + ex.Message); Console.WriteLine(ex.Message); } return(new Product()); } catch { ////log.Error("Cannot add new WooCommerce Product. " + ex.Message); return(new Product()); } }
/// <summary> /// Load all source NFTs /// </summary> /// <returns></returns> public async Task LoadSourceNFTs() { if (!string.IsNullOrEmpty(ProtocolNFTHash)) { try { var nft = await NFTFactory.GetNFT("", ProtocolNFTHash, 0, 0, true, true, NFTTypes.Protocol); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { LoadedProtocolNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the ProtocolNFT: {ProtocolNFTHash} in DeviceNFT: {Utxo}, exception: {ex.Message}"); } } if (!string.IsNullOrEmpty(HWSrcNFTHash)) { try { var nft = await NFTFactory.GetNFT("", HWSrcNFTHash, 0, 0, true, true, NFTTypes.HWSrc); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { HwSourceNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the HWSrcNFT: {HWSrcNFTHash} in DeviceNFT: {Utxo}, exception: {ex.Message}"); } } if (!string.IsNullOrEmpty(FWSrcNFTHash)) { try { var nft = await NFTFactory.GetNFT("", FWSrcNFTHash, 0, 0, true, true, NFTTypes.FWSrc); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { FwSourceNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the FWSrcNFT: {FWSrcNFTHash} in DeviceNFT: {Utxo}, exception: {ex.Message}"); } } if (!string.IsNullOrEmpty(SWSrcNFTHash)) { try { var nft = await NFTFactory.GetNFT("", SWSrcNFTHash, 0, 0, true, true, NFTTypes.SWSrc); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { SwSourceNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the SWSrcNFT: {SWSrcNFTHash} in DeviceNFT: {Utxo}, exception: {ex.Message}"); } } if (!string.IsNullOrEmpty(MechSrcNFTHash)) { try { var nft = await NFTFactory.GetNFT("", MechSrcNFTHash, 0, 0, true, true, NFTTypes.MechSrc); if (nft != null && !string.IsNullOrEmpty(nft.Utxo)) { MechSourceNFT = nft; } } catch (Exception ex) { Console.WriteLine($"Cannot load the MechSrcNFT: {MechSrcNFTHash} in DeviceNFT: {Utxo}, exception: {ex.Message}"); } } }
/// <summary> /// Init driver communication - means autorefresh of the messages /// </summary> /// <param name="nft"></param> /// <returns></returns> public abstract Task Init(INFT nft);
/// <summary> /// Buy the NFT based on the NFT and Neblio Address /// </summary> /// <param name="neblioAddress"></param> /// <param name="receiver"></param> /// <param name="nft"></param> /// <returns></returns> public async Task <(bool, string)> BuyNFT(string neblioAddress, string receiver, INFT nft) { if (!nft.PriceActive) { return(false, "NFT does not have setted up the price. It is not sellable NFT."); } if (IsLocked()) { await InvokeAccountLockedEvent(); return(false, "Account is locked."); } var res = await CheckSpendableDoge(nft.Price); if (res.Item2 == null) { await InvokeErrorDuringSendEvent(res.Item1, "Not enough spendable inputs"); return(false, res.Item1); } var nftid = nft.Utxo + ":" + nft.UtxoIndex.ToString(); var msg = neblioAddress + "=" + String.Format("{0:X}", nftid.GetHashCode()); // fill input data for sending tx var dto = new SendTxData() // please check SendTxData for another properties such as specify source UTXOs { Amount = nft.Price, SenderAddress = Address, ReceiverAddress = receiver, CustomMessage = msg }; try { // send tx var transaction = DogeTransactionHelpers.GetDogeTransactionWithMessageAsync(dto, BAddress, res.Item2); var result = await SignBroadcastAndInvokeSucessEvent(transaction, Secret, res.Item2, "Doge Payment Sent"); if (result.Item1) { return(true, result.Item2); } } catch (Exception ex) { await InvokeErrorDuringSendEvent(ex.Message, "Unknown Error"); return(false, ex.Message); } await InvokeErrorDuringSendEvent("Unknown Error", "Unknown Error"); return(false, "Unexpected error during send."); }