コード例 #1
0
        public static TransactionPayloadLCS FromProgram(PayloadLCS payloadLCS)
        {
            var program = new ProgramLCS();

            program.Code    = payloadLCS.Code;
            program.Modules = payloadLCS.Modules;
            program.TransactionArguments = payloadLCS.TransactionArguments;
            return(new TransactionPayloadLCS
            {
                PayloadType = TransactionPayloadType.Program,
                Program = program
            });
        }
コード例 #2
0
        public ProgramLCS GetProgram(byte[] source, ref int cursor)
        {
            var retVal = new ProgramLCS();

            //struct Program
            // {
            //  code: Vec<u8>, // Variable length byte array
            //  args: Vec<TransactionArgument>, // Variable length array of TransactionArguments
            //  modules: Vec<Vec<u8>>, // Variable length array of variable length byte arrays
            // }
            retVal.Code = source.LCSerialization <byte[]>(ref cursor);
            retVal.TransactionArguments = source.LCSerialization <List <TransactionArgumentLCS> >(ref cursor);
            retVal.Modules = source.LCSerialization <List <byte[]> >(ref cursor);

            return(retVal);
        }
コード例 #3
0
        public byte[] ProgramToByte(ProgramLCS source)
        {
            var result = ByteArrayToByte(source.Code);
            var argLen = U32ToByte((uint)source.TransactionArguments.Count);

            result = result.Concat(argLen).ToArray();
            foreach (var arg in source.TransactionArguments)
            {
                var argData = LCSCore.LCSDeserialization(arg);
                result = result.Concat(argData).ToArray();
            }

            var module = LCSCore.LCSDeserialization(source.Modules);

            result = result.Concat(module).ToArray();

            return(result);
        }