예제 #1
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, CallInput callInput, BlockParameter block)
        {
            callInput.Data = encodedFunctionCall;
            var result = await ethCall.SendRequestAsync(callInput, block);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
예제 #2
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, CallInput callInput)
        {
            callInput.Data = encodedFunctionCall;
            var result = await ethCall.SendRequestAsync(callInput, DefaultBlock).ConfigureAwait(false);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
예제 #3
0
        /// <summary>
        /// 解析output
        /// </summary>
        /// <typeparam name="FunctionOutputDTO">解析output Dto</typeparam>
        /// <param name="encodeOutput">原始output</param>
        /// <returns>解析后得到对象</returns>
        public FunctionOutputDTO OutputDecode <FunctionOutputDTO>(FunctionOutputDTO outputDto, string encodeOutput)
        {
            var functionCallDecoder = new FunctionCallDecoder();
            var outputData          = functionCallDecoder.DecodeFunctionOutput <FunctionOutputDTO>(outputDto, encodeOutput);

            return(outputData);
        }
예제 #4
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall)
        {
            var result =
                await
                ethCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress), DefaultBlock)
                .ConfigureAwait(false);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
예제 #5
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, CallInput callInput, BlockParameter block)
        {
            var result =
                await
                EthCall.SendRequestAsync(callInput, block)
                .ConfigureAwait(false);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
예제 #6
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, string from,
                                                           HexBigInteger gas, HexBigInteger value, BlockParameter block)
        {
            var result =
                await
                EthCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress, @from, gas, value),
                                         block).ConfigureAwait(false);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
예제 #7
0
 protected Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, CallInput callInput, BlockParameter block)
 {
     return(EthCall.SendRequestAsync(callInput, block).ContinueWith(result =>
     {
         if (result.Exception != null)
         {
             throw result.Exception;
         }
         return FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result.Result);
     }));
 }
        public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray()
        {
            var functionCallDecoder = new FunctionCallDecoder();

            var array = new uint[20];

            for (uint i = 0; i < 20; i++)
            {
                array[i] = i + 234567;
            }

            var result = functionCallDecoder.
                         DecodeFunctionOutput <FunctionMultipleInputOutput>("0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000"
                                                                            );

            Assert.Equal("hello", result.A);
            Assert.Equal("world", result.C);
            Assert.Equal(array[6], result.B[6]);
        }
예제 #9
0
 public TReturn DecodeDTOTypeOutput <TReturn>(string output) where TReturn : new()
 {
     return(FunctionCallDecoder.DecodeFunctionOutput <TReturn>(output));
 }
예제 #10
0
 public TReturn DecodeDTOTypeOutput <TReturn>(TReturn functionOuput, string output)
 {
     return(FunctionCallDecoder.DecodeFunctionOutput <TReturn>(functionOuput, output));
 }
 public static TFunctionOutputDTO DecodeOutput <TFunctionOutputDTO>(this TFunctionOutputDTO functionOuputDTO, string output) where TFunctionOutputDTO : IFunctionOutputDTO
 {
     return(_functionCallDecoder.DecodeFunctionOutput(functionOuputDTO, output));
 }
예제 #12
0
        protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, string from, HexBigInteger gas, HexBigInteger value)
        {
            var result = await ethCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress, from, gas, value), DefaultBlock);

            return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result));
        }
        public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray()
        {

            var functionCallDecoder = new FunctionCallDecoder();

            var array = new uint[20];
            for (uint i = 0; i < 20; i++)
            {
                array[i] = i + 234567;
            }

            var result = functionCallDecoder.
                DecodeFunctionOutput<FunctionMultipleInputOutput>("0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000"
                );

            Assert.Equal("hello", result.A);
            Assert.Equal("world", result.C);
            Assert.Equal(array[6], result.B[6]);
        }