internal TransactionInfo CreateTransactionInfo(JObject jsonObject) { jsonObject = jsonObject["meta"].ToObject <JObject>(); if (jsonObject["hash"] != null && jsonObject["id"] != null) { return(TransactionInfo.Create(ExtractBigInteger(jsonObject, "height"), Int32.Parse(jsonObject["index"].ToString()), jsonObject["id"].ToString(), jsonObject["hash"].ToString(), jsonObject["merkleComponentHash"].ToString())); } if (jsonObject["aggregateHash"] != null && jsonObject["id"] != null) { return(TransactionInfo.CreateAggregate(ExtractBigInteger( jsonObject, "height"), Int32.Parse(jsonObject["index"].ToString()), jsonObject["id"].ToString(), jsonObject["aggregateHash"].ToString(), jsonObject["aggregateId"].ToString())); } return(TransactionInfo.Create(ExtractBigInteger(jsonObject, "height"), jsonObject["hash"].ToString(), jsonObject["merkleComponentHash"].ToString())); }
/// <summary> /// Create transaction info based on the provided transaction meta json object /// </summary> /// <param name="jsonObject">The json object</param> /// <returns>TransactionInfo</returns> public static TransactionInfo CreateTransactionInfo(JObject jsonObject) { var meta = jsonObject["meta"].ToObject <JObject>(); var heightOjb = meta["height"].ToObject <UInt64DTO>().ToUInt64(); var indexObj = meta["index"]?.ToObject <int>(); //standard transaction info based on hash + id if (meta.ContainsKey("hash") && meta.ContainsKey("id")) { return(TransactionInfo.Create(heightOjb, indexObj, meta["id"].ToObject <string>(), meta["hash"].ToObject <string>(), meta["merkleComponentHash"].ToObject <string>() )); } // aggregateHash and id indicate aggregate transaction if (meta.ContainsKey("aggregateHash") && meta.ContainsKey("id")) { return(TransactionInfo.CreateAggregate(heightOjb, indexObj, meta["id"].ToObject <string>(), meta["aggregateHash"].ToObject <string>(), meta["aggregateId"].ToObject <string>() )); } // missing id return(TransactionInfo.Create(heightOjb, meta["hash"].ToObject <string>(), meta["merkleComponentHash"].ToObject <string>())); }
public void CreateATransactionInfoWithStaticConstructorCreateForAggregateInnerTransactions() { TransactionInfo transactionInfo = TransactionInfo.CreateAggregate(121855, 1, "5A3D23889CD1E800015929A9", "3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006", "5A0069D83F17CF0001777E55"); Assert.AreEqual((ulong)121855, transactionInfo.Height); Assert.IsNotNull(transactionInfo.Index); Assert.IsNotNull(transactionInfo.Id); Assert.IsNull(transactionInfo.Hash); Assert.IsNull(transactionInfo.MerkleComponentHash); Assert.IsNotNull(transactionInfo.AggregateHash); Assert.IsNotNull(transactionInfo.AggregateId); Assert.IsTrue(1 == transactionInfo.Index); Assert.AreEqual("5A3D23889CD1E800015929A9", transactionInfo.Id); Assert.AreEqual("3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006", transactionInfo.AggregateHash); Assert.AreEqual("5A0069D83F17CF0001777E55", transactionInfo.AggregateId); }