Esempio n. 1
0
        public static StObject Formatted(StObject source)
        {
            if (AffectedNode.IsAffectedNode(source))
            {
                return(new AffectedNode(source));
            }

            if (TransactionMeta.IsTransactionMeta(source))
            {
                var meta = new TransactionMeta {
                    fields = source.fields
                };
                return(meta);
            }

            var ledgerEntryType = LedgerEntryType(source);

            if (ledgerEntryType != null)
            {
                return(LedgerFormatted(source, ledgerEntryType));
            }

            var transactionType = TransactionType(source);

            if (transactionType != null)
            {
                return(TransactionFormatted(source, transactionType));
            }

            return(source);
        }
Esempio n. 2
0
        public static LedgerEntryType LedgerEntryType(StObject obj)
        {
            UInt.UInt16 uInt16 = obj[UInt.UInt16.LedgerEntryType];
            if (uInt16 == null)
            {
                return(null);
            }

            return(Enums.LedgerEntryType.FromNumber(uInt16));
        }
Esempio n. 3
0
        // TODO, move these some where more specific
        // leave these here as static methods
        // delegate from more specific places
        public static TransactionEngineResult TransactionResult(StObject obj)
        {
            var uInt8 = obj[UInt8.TransactionResult];

            if (uInt8 == null)
            {
                return(null);
            }

            return(TransactionEngineResult.FromNumber(uInt8.IntValue()));
        }
Esempio n. 4
0
        public static TransactionType TransactionType(StObject obj)
        {
            var uInt16 = obj[UInt.UInt16.TransactionType];

            if (uInt16 == null)
            {
                return(null);
            }

            return(Enums.TransactionType.FromNumber(uInt16));
        }
Esempio n. 5
0
        private static StObject LedgerFormatted(StObject source, LedgerEntryType ledgerEntryType)
        {
            StObject constructed = null;

            if (ledgerEntryType == Enums.LedgerEntryType.Offer)
            {
                constructed = new Offer();
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.RippleState)
            {
                constructed = new RippleState();
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.AccountRoot)
            {
                constructed = new AccountRoot();
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.Invalid)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.DirectoryNode)
            {
                constructed = new DirectoryNode();
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.GeneratorMap)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.Nickname)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.Contract)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.LedgerHashes)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.EnabledFeatures)
            {
            }
            else if (ledgerEntryType == Enums.LedgerEntryType.FeeSettings)
            {
            }

            if (constructed == null)
            {
                constructed = new LedgerEntry(ledgerEntryType);
            }

            constructed.fields = source.fields;

            return(constructed);
        }
Esempio n. 6
0
            public override StArray FromJsonArray(JArray jsonArray)
            {
                var arr = new StArray();

                for (int i = 0; i < jsonArray.Count; i++)
                {
                    try
                    {
                        var o = jsonArray[i];
                        arr.Add(StObject.FromJObject(o.ToObject <JObject>()));
                    }
                    catch (JsonException e)
                    {
                        throw new ApplicationException("Json deserialization failed.", e);
                    }
                }

                return(arr);
            }
Esempio n. 7
0
            public override StArray FromParser(BinaryParser parser, int?hint)
            {
                var stArray = new StArray();

                while (!parser.End)
                {
                    Field field = parser.ReadField();

                    if (field == Field.ArrayEndMarker)
                    {
                        break;
                    }

                    var outer = new StObject {
                        { field, StObject.OutTranslate.FromParser(parser) }
                    };
                    stArray.Add(outer);
                }

                return(stArray);
            }
Esempio n. 8
0
 public static BigDecimal FromOfferBookDirectory(StObject offer)
 {
     return(FromBookDirectory(offer[Hash256.BookDirectory], offer[Amount.TakerPays].IsNative,
                              offer[Amount.TakerPays].IsNative));
 }
Esempio n. 9
0
        private static StObject TransactionFormatted(StObject source, TransactionType transactionType)
        {
            StObject constructed = null;

            if (transactionType == Enums.TransactionType.Invalid)
            {
            }
            else if (transactionType == Enums.TransactionType.Payment)
            {
                constructed = new Payment();
            }
            else if (transactionType == Enums.TransactionType.Claim)
            {
            }
            else if (transactionType == Enums.TransactionType.WalletAdd)
            {
            }
            else if (transactionType == Enums.TransactionType.AccountSet)
            {
                constructed = new AccountSet();
            }
            else if (transactionType == Enums.TransactionType.PasswordFund)
            {
            }
            else if (transactionType == Enums.TransactionType.SetRegularKey)
            {
            }
            else if (transactionType == Enums.TransactionType.NickNameSet)
            {
            }
            else if (transactionType == Enums.TransactionType.OfferCreate)
            {
                constructed = new OfferCreate();
            }
            else if (transactionType == Enums.TransactionType.OfferCancel)
            {
                constructed = new OfferCancel();
            }
            else if (transactionType == Enums.TransactionType.Contract)
            {
            }
            else if (transactionType == Enums.TransactionType.RemoveContract)
            {
            }
            else if (transactionType == Enums.TransactionType.TrustSet)
            {
                constructed = new TrustSet();
            }
            else if (transactionType == Enums.TransactionType.EnableFeature)
            {
            }
            else if (transactionType == Enums.TransactionType.SetFee)
            {
            }

            if (constructed == null)
            {
                constructed = new Transaction(transactionType);
            }

            constructed.fields = source.fields;

            return(constructed);
        }