public async Task broadcast_block()
        {
            var args = new SignedBlock();
            var resp = await Api.BroadcastBlockAsync(args, CancellationToken.None).ConfigureAwait(false);

            TestPropetries(resp);
        }
        public bool Parse(BlockHash bh, SignedBlock sb, string extrinsic)
        {
            bool   result = false;
            var    ex = extrinsic.Substring(2);
            var    ci = Scale.DecodeCompactInteger(ref ex);
            var    transactionParam = new List <object>();
            string t1 = string.Empty;
            string moduleName = string.Empty, methodName = string.Empty;
            var    nonce     = Scale.DecodeCompactInteger(ref ex);
            var    moduleInd = Scale.NextByte(ref ex);
            int    methodInd = 0;

            if (ex.Length > 0)
            {
                methodInd = Scale.NextByte(ref ex);
            }

            FunctionCallArgV8[] paramsInfo = null;

            // try parse transaction if catch exception that transaction is not supported
            try
            {
                paramsInfo = _metadata.GetModuleCallParamsByIds(moduleInd, methodInd);
                var r1 = _metadata.GetModuleCallNameByIds(moduleInd, methodInd);
                moduleName = r1.Item1;
                methodName = r1.Item2;
                result     = true;
            }
            catch (Exception)
            {
                return(false);
            }

            _pex = new ExtrinsicInfo
            {
                BlockNumber  = (int)sb.Block.Header.Number,
                BlockHash    = bh.Hash,
                Raw          = extrinsic,
                ModuleIndex  = moduleInd,
                ModuleName   = moduleName,
                MethodIndex  = methodInd,
                MethodName   = methodName,
                Nonce        = nonce.Value,
                ExtrinsicEra = 0,
                Params       = ex,
                Unknown      = result,
                ParamsInfo   = paramsInfo
            };

            return(result);
        }
Exemple #3
0
        internal ISpecificTransaction GetTransactionSpecific(BlockHash bh, SignedBlock sb, string ex)
        {
            foreach (var st in _specificTransactions)
            {
                try
                {
                    if (st.Parse(bh, sb, ex))
                    {
                        return(st);
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }

            return(new UnknownTransaction());
        }
Exemple #4
0
        public bool Parse(BlockHash bh, SignedBlock sb, string extrinsic)
        {
            var parse = extrinsic;

            parse = parse.Substring(2);
            var t1 = Scale.DecodeCompactInteger(ref parse);

            // delimiter
            Scale.NextByte(ref parse);
            Scale.NextByte(ref parse);

            // 32 * 2
            var senderPublic = parse.Substring(0, 64);

            parse = parse.Substring(64);
            sk    = senderPublic;
            var era = Scale.NextByte(ref parse);

            var signature = parse.Substring(0, 128);

            parse = parse.Substring(128);

            var err = Scale.DecodeCompactInteger(ref parse).Value;

            var nonce = Scale.DecodeCompactInteger(ref parse).Value;

            Scale.NextByte(ref parse);

            bool   result = false;
            string moduleName = string.Empty, methodName = string.Empty;

            var moduleInd = Scale.NextByte(ref parse);
            var methodInd = Scale.NextByte(ref parse);

            // Scale.NextByte(ref parse);

            FunctionCallArgV8[] paramsInfo = null;

            info = parse;

            // try parse transaction if catch exception that transaction is not supported
            try
            {
                paramsInfo = _metadata.GetModuleCallParamsByIds(moduleInd, methodInd);
                var r1 = _metadata.GetModuleCallNameByIds(moduleInd, methodInd);
                moduleName = r1.Item1;
                methodName = r1.Item2;
                if (moduleName.Equals("Identity", StringComparison.InvariantCultureIgnoreCase) &&
                    methodName.Equals("set_identity", StringComparison.InvariantCultureIgnoreCase))
                {
                    result = true;
                }
            }
            catch (Exception)
            {
                return(false);
            }

            pex = new ExtrinsicInfo
            {
                BlockNumber  = (int)sb.Block.Header.Number,
                BlockHash    = bh.Hash,
                Raw          = extrinsic,
                ModuleIndex  = moduleInd,
                ModuleName   = moduleName,
                MethodIndex  = methodInd,
                MethodName   = methodName,
                Nonce        = nonce,
                ExtrinsicEra = era,
                Params       = parse,
                Status       = err,
                Unknown      = result,
                Signature    = signature,
                ParamsInfo   = paramsInfo
            };

            return(result);
        }
 /// <summary>
 /// API name: broadcast_block
 ///
 /// </summary>
 /// <param name="block">API type: signed_block</param>
 /// <param name="token">Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.</param>
 /// <returns>API type: void</returns>
 /// <exception cref="T:System.OperationCanceledException">The token has had cancellation requested.</exception>
 public Task <JsonRpcResponse <VoidResponse> > BroadcastBlock(SignedBlock block, CancellationToken token)
 {
     return(CustomGetRequest <VoidResponse>(KnownApiNames.NetworkBroadcast, "broadcast_block", new object[] { block }, token));
 }
Exemple #6
0
 /// <summary>
 /// API name: broadcast_block
 ///
 /// </summary>
 /// <param name="block">API type: signed_block</param>
 /// <param name="token">Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.</param>
 /// <returns>API type: void</returns>
 /// <exception cref="T:System.OperationCanceledException">The token has had cancellation requested.</exception>
 public JsonRpcResponse BroadcastBlock(SignedBlock block, CancellationToken token)
 {
     return(CallRequest(KnownApiNames.NetworkBroadcastApi, "broadcast_block", new object[] { block }, token));
 }
Exemple #7
0
 public bool Parse(BlockHash bh, SignedBlock sb, string extrinsic)
 {
     throw new System.NotImplementedException();
 }
 public bool Parse(BlockHash bh, SignedBlock sb, string extrinsic)
 {
     return(true);
 }
Exemple #9
0
        /// <summary>
        ///
        /// curl --request POST \--url http://127.0.0.1:8888/v1/chain/get_producers
        /// </summary>
        /// <param name="args"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <OperationResult <VoidResponse> > PushBlock(SignedBlock args, CancellationToken token)
        {
            var endpoint = $"{ChainUrl}/v1/chain/push_block";

            return(await CustomPostRequestAsync <VoidResponse>(endpoint, args, token).ConfigureAwait(false));
        }