public static Order CreateFromJson(DictionaryObject json, Asset amountAsset, Asset priceAsset) { var side = OrderSide.Buy; if (json.ContainsKey("orderType")) { side = json.GetString("orderType") == "buy" ? OrderSide.Buy : OrderSide.Sell; } else { side = (OrderSide)Enum.Parse(typeof(OrderSide), json.GetString("type"), true); } var senderPublicKey = json.ContainsKey("senderPublicKey") ? json.GetString("senderPublicKey") : ""; var matcherPublicKey = json.ContainsKey("matcherPublicKey") ? json.GetString("matcherPublicKey") : ""; var expiration = json.ContainsKey("expiration") ? json.GetDate("expiration") : json.GetDate("timestamp"); var matcherFee = json.ContainsKey("matcherFee") ? Assets.WAVES.LongToAmount(json.GetLong("matcherFee")) : 1; string sender = json.ContainsKey("sender") ? json.GetString("sender") : null; var proofs = new byte[8][]; if (json.ContainsKey("proofs")) { proofs = json.Get <string[]>("proofs") .Select(item => item.FromBase58()) .ToArray(); } else { if (json.ContainsKey("signature")) { proofs[0] = json.GetString("signature").FromBase58(); } } var status = json.ContainsKey("status") ? (OrderStatus)Enum.Parse(typeof(OrderStatus), json.GetString("status")) : OrderStatus.Accepted; var id = json.ContainsKey("id") ? json.GetString("id") : null; var filled = json.ContainsKey("filled") ? amountAsset.LongToAmount(json.GetLong("filled")) : 1m; var version = json.ContainsKey("version") ? json.GetByte("version") : (byte)2; return(new Order( side, amountAsset.LongToAmount(json.GetLong("amount")), Asset.LongToPrice(amountAsset, priceAsset, json.GetLong("price")), json.GetDate("timestamp"), amountAsset, priceAsset, senderPublicKey.FromBase58(), matcherPublicKey.FromBase58(), expiration, matcherFee, sender, version) { Proofs = proofs, Status = status, Id = id, Filled = filled }); }
public static Order CreateFromJson(Dictionary <string, object> json, Asset amountAsset, Asset priceAsset) { return(new Order( json.GetString("id"), (OrderSide)Enum.Parse(typeof(OrderSide), json.GetString("type"), true), amountAsset.LongToAmount(json.GetLong("amount")), Asset.LongToPrice(amountAsset, priceAsset, json.GetLong("price")), json.GetDate("timestamp"), amountAsset.LongToAmount(json.GetLong("filled")), (OrderStatus)Enum.Parse(typeof(OrderStatus), json.GetString("status")), amountAsset, priceAsset)); }
public BurnTransaction(DictionaryObject tx, Node node) : base(tx) { Asset = node.GetAsset(tx.GetString("assetId")); Quantity = Asset.LongToAmount(tx.GetLong("amount")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); Version = tx.GetByte("version"); }
public ReissueTransaction(DictionaryObject tx, Node node) : base(tx) { Asset = node.GetAsset(tx.GetString("assetId")); Quantity = Asset.LongToAmount(tx.GetLong("quantity")); Reissuable = tx.GetBool("reissuable"); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); }
public TransferTransaction(DictionaryObject tx) : base(tx) { var node = new Node(tx.GetChar("chainId")); Asset = Assets.WAVES; if (tx.ContainsKey("assetId") && tx.GetString("assetId") != null) { Asset = node.GetAsset(tx.GetString("assetId")); } FeeAsset = Assets.WAVES; if (tx.ContainsKey("feeAssetId") && tx.GetString("feeAssetId") != null && tx.GetString("feeAssetId") != "") { FeeAsset = node.GetAsset(tx.GetString("feeAssetId")); } Amount = Asset.LongToAmount(tx.GetLong("amount")); Fee = FeeAsset.LongToAmount(tx.GetLong("fee")); Recipient = tx.GetString("recipient"); Attachment = tx.ContainsKey("attachment") ? tx.GetString("attachment").FromBase58() : new byte[0]; }
public BurnTransaction(DictionaryObject tx) : base(tx) { var node = new Node(tx.GetChar("chainId")); Asset = node.GetAsset(tx.GetString("assetId")); Quantity = Asset.LongToAmount(tx.GetLong("amount")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); }
public SponsoredFeeTransaction(DictionaryObject tx) : base(tx) { var node = new Node(tx.GetChar("chainId")); Asset = node.GetAsset(tx.GetString("assetId")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); MinimalFeeInAssets = tx["minSponsoredAssetFee"] != null?Asset.LongToAmount(tx.GetLong("minSponsoredAssetFee")) : 0; }
public ReissueTransaction(DictionaryObject tx) : base(tx) { var node = new Node(tx.GetChar("chainId")); Asset = node.GetAsset(tx.GetString("assetId")); Quantity = Asset.LongToAmount(tx.GetLong("quantity")); Reissuable = tx.GetBool("reissuable"); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); Version = tx.GetByte("version"); }
public MassTransferTransaction(DictionaryObject tx) : base(tx) { Asset = Assets.GetById(tx.GetString("assetId") ?? Assets.WAVES.Id); Attachment = tx.GetString("attachment").FromBase58(); Transfers = tx.GetObjects("transfers") .Select(transfer => new MassTransferItem(transfer.GetString("recipient"), Asset.LongToAmount(transfer.GetLong("amount")))) .ToArray(); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); }
public Dictionary <Asset, decimal> GetTradableBalance(string address, Asset amountAsset, Asset priceAsset) { var url = $"{_host}/matcher/orderbook/{amountAsset.Id}/{priceAsset.Id}/tradableBalance/{address}"; var response = Http.GetObject(url); return(new Dictionary <Asset, decimal> { { amountAsset, amountAsset.LongToAmount(response.GetLong(amountAsset.Id)) }, { priceAsset, priceAsset.LongToAmount(response.GetLong(priceAsset.Id)) }, }); }
public ExchangeTransaction(DictionaryObject tx) : base(tx) { Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); BuyMatcherFee = Assets.WAVES.LongToAmount(tx.GetLong("buyMatcherFee")); SellMatcherFee = Assets.WAVES.LongToAmount(tx.GetLong("sellMatcherFee")); AmountAsset = Assets.GetById((tx.GetValue("order1.assetPair.amountAsset") ?? Assets.WAVES.Id).ToString()); PriceAsset = Assets.GetById((tx.GetValue("order1.assetPair.priceAsset") ?? Assets.WAVES.Id).ToString()); BuyOrder = Order.CreateFromJson(tx.GetObject("order1"), AmountAsset, PriceAsset); SellOrder = Order.CreateFromJson(tx.GetObject("order2"), AmountAsset, PriceAsset); Amount = AmountAsset.LongToAmount(tx.GetLong("amount")); Price = Asset.LongToPrice(AmountAsset, PriceAsset, tx.GetLong("price")); }
public InvokeScriptTransaction(DictionaryObject tx, Node node) : base(tx) { DappAddress = tx.GetString("dApp"); FunctionHeader = tx.ContainsKey("call") ? tx.GetString("call.function") : null; FunctionCallArguments = tx.GetObjects("call.args") .Select(Node.DataValue) .ToList(); Payment = tx.GetObjects("payment") .ToDictionary(o => node.GetAsset(o.GetString("assetId")), o => node.GetAsset(o.GetString("assetId")).LongToAmount(o.GetLong("amount"))); FeeAsset = tx.ContainsKey("feeAssetId") && tx.GetString("feeAssetId") != null?node.GetAsset(tx.GetString("feeAssetId")) : Assets.WAVES; Fee = FeeAsset.LongToAmount(tx.GetLong("fee")); }
public ExchangeTransaction(DictionaryObject tx) : base(tx) { var node = new Node(tx.GetChar("chainId")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); BuyMatcherFee = Assets.WAVES.LongToAmount(tx.GetLong("buyMatcherFee")); SellMatcherFee = Assets.WAVES.LongToAmount(tx.GetLong("sellMatcherFee")); AmountAsset = node.GetAsset((tx.GetValue("order1.assetPair.amountAsset") ?? Assets.WAVES.Id).ToString()); PriceAsset = node.GetAsset((tx.GetValue("order1.assetPair.priceAsset") ?? Assets.WAVES.Id).ToString()); BuyOrder = Order.CreateFromJson(tx.GetObject("order1"), AmountAsset, PriceAsset); SellOrder = Order.CreateFromJson(tx.GetObject("order2"), AmountAsset, PriceAsset); Amount = AmountAsset.LongToAmount(tx.GetLong("amount")); Price = Asset.LongToPrice(AmountAsset, PriceAsset, tx.GetLong("price")); Version = tx.GetByte("version"); }
public static decimal GetDecimal(this DictionaryObject d, string field, Asset asset) { return(asset.LongToAmount(long.Parse(d.GetValue(field).ToString()))); }
public SponsoredFeeTransaction(DictionaryObject tx) : base(tx) { Asset = Assets.GetById(tx.GetString("assetId")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); MinimalFeeInAssets = Asset.LongToAmount(tx.GetLong("minSponsoredAssetFee")); }
private static Item ParseItem(Asset amountAsset, Asset priceAsset, DictionaryObject o) { return(new Item( Asset.LongToPrice(amountAsset, priceAsset, o.GetLong("price")), amountAsset.LongToAmount(o.GetLong("amount")))); }
public BurnTransaction(DictionaryObject tx) : base(tx) { Asset = Assets.GetById(tx.GetString("assetId")); Quantity = Asset.LongToAmount(tx.GetLong("amount")); Fee = Assets.WAVES.LongToAmount(tx.GetLong("fee")); }