Example #1
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out BigInteger val)
        {
            var encoder = new Int256Encoder();

            encoder.SetTypeInfo(solidityType);
            encoder.Decode(ref buff, out val);
        }
Example #2
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out UInt256 val)
        {
            NumberEncoder <UInt256> encoder = new UInt256Encoder();

            encoder.SetTypeInfo(solidityType);
            encoder.Decode(ref buff, out val);
        }
Example #3
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out ulong val)
        {
            var encoder = new UInt64Encoder();

            encoder.SetTypeInfo(solidityType);
            encoder.Decode(ref buff, out val);
        }
Example #4
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out Hash val)
        {
            var encoder = new BytesMEncoder();

            encoder.SetTypeInfo(solidityType);
            encoder.Decode(ref buff, out var bytes);
            val = new Hash(bytes is byte[] b ? b : bytes.ToArray());
        }
Example #5
0
        public static void Decode <TItem>(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out TItem val)
        {
            var encoder = EncoderFactory.LoadEncoder(solidityType);

            encoder.SetTypeInfo(solidityType);
            encoder.DecodeObject(ref buff, out var objectVal);
            val = (TItem)objectVal;
        }
Example #6
0
        public static void Decode <TItem>(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out IEnumerable <TItem> val, IAbiTypeEncoder <TItem> itemEncoder)
        {
            AbiTypeEncoder <IEnumerable <TItem> > encoder;

            switch (solidityType.Category)
            {
            case SolidityTypeCategory.DynamicArray:
                encoder = new DynamicArrayEncoder <TItem>(itemEncoder);
                break;

            case SolidityTypeCategory.FixedArray:
                encoder = new FixedArrayEncoder <TItem>(itemEncoder);
                break;

            default:
                throw new ArgumentException($"Encoder factory for array types was called with a type '{solidityType.Category}'");
            }

            encoder.SetTypeInfo(solidityType);
            encoder.Decode(ref buff, out val);
        }
Example #7
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out IEnumerable <byte> val)
        {
            switch (solidityType.Category)
            {
            case SolidityTypeCategory.Bytes:
            {
                var encoder = new BytesEncoder();
                encoder.SetTypeInfo(solidityType);
                encoder.Decode(ref buff, out val);
                break;
            }

            case SolidityTypeCategory.DynamicArray:
            {
                var encoder = new DynamicArrayEncoder <byte>(new UInt8Encoder());
                encoder.SetTypeInfo(solidityType);
                encoder.Decode(ref buff, out val);
                break;
            }

            case SolidityTypeCategory.FixedArray:
            {
                var encoder = new FixedArrayEncoder <byte>(new UInt8Encoder());
                encoder.SetTypeInfo(solidityType);
                encoder.Decode(ref buff, out val);
                break;
            }

            case SolidityTypeCategory.Elementary when solidityType.ElementaryBaseType == SolidityTypeElementaryBase.Bytes:
            {
                var encoder = new BytesMEncoder();
                encoder.SetTypeInfo(solidityType);
                encoder.Decode(ref buff, out val);
                break;
            }

            default:
                throw new ArgumentException($"Encoder factor method for byte arrays called with type '{solidityType.Category}'");
            }
        }
Example #8
0
 public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out byte[] val)
 {
     Decode(solidityType, ref buff, out IEnumerable <byte> bytes);
     val = bytes is byte[] arr ? arr : bytes.ToArray();
 }
Example #9
0
 public static void Decode <TItem>(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out TItem[] val, IAbiTypeEncoder <TItem> itemEncoder)
 {
     Decode(solidityType, ref buff, out IEnumerable <TItem> items, itemEncoder);
     val = items is TItem[] arr ? arr : items.ToArray();
 }
Example #10
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out sbyte val)
        {
            var encoder = new Int8Encoder();

            encoder.Decode(ref buff, out val);
        }
Example #11
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out bool val)
        {
            var encoder = new BoolEncoder();

            encoder.Decode(ref buff, out val);
        }
Example #12
0
        public static void Decode(AbiTypeInfo solidityType, ref AbiDecodeBuffer buff, out Address val)
        {
            var encoder = new AddressEncoder();

            encoder.Decode(ref buff, out val);
        }
Example #13
0
 public void DecodeObject(ref AbiDecodeBuffer buff, out object val)
 {
     _encoder.DecodeObject(ref buff, out val);
 }
Example #14
0
 public void Decode(ref AbiDecodeBuffer buff, out TItem val)
 {
     _encoder.DecodeObject(ref buff, out object objectVal);
     val = (TItem)objectVal;
 }