Exemplo n.º 1
0
        public override async Task <FinalExecutionOutcome> SendTransactionAsync(SignedTransaction signedTransaction)
        {
            var bytes      = signedTransaction.ToByteArray();
            var parameters = new dynamic[1];

            parameters[0] = Convert.ToBase64String(bytes, 0, bytes.Length);
            var rawOutcomeResult = await SendJsonRpc("broadcast_tx_commit", parameters);

            var result = FinalExecutionOutcome.FromDynamicJsonObject(rawOutcomeResult);

            return(result);
        }
Exemplo n.º 2
0
        public static FinalExecutionOutcome FromDynamicJsonObject(dynamic jsonObject)
        {
            var receipts = new List <ExecutionOutcomeWithId>();

            foreach (var receipt in jsonObject.receipts)
            {
                receipts.Add(ExecutionOutcomeWithId.FromDynamicJsonObject(receipt));
            }
            var result = new FinalExecutionOutcome()
            {
                Receipts    = receipts.ToArray(),
                Status      = FinalExecutionStatus.FromDynamicJsonObject(jsonObject.status),
                Transaction = ExecutionOutcomeWithId.FromDynamicJsonObject(jsonObject.transaction)
            };

            return(result);
        }
Exemplo n.º 3
0
        public static dynamic GetTransactionLastResult(FinalExecutionOutcome txResult)
        {
            if (txResult.Status == null || txResult.Status.GetType() != typeof(FinalExecutionStatus) || string.Equals(
                    txResult.Status.SuccessValue, null, StringComparison.Ordinal))
            {
                return(null);
            }

            var value = Encoding.UTF8.GetString(Convert.FromBase64String(txResult.Status.SuccessValue)).Trim('"');

            try
            {
                var result = JObject.Parse(value);
                return(result);
            }
            catch
            {
                return(value);
            }
        }