Exemple #1
0
        static public void publishTransferMessage(ConfirmedTransaction trx)
        {
            eventCounter++;
            var msgStr = JsonConvert.SerializeObject(trx);
            Dictionary <String, MessageAttributeValue> messageAttributes = new Dictionary <string, MessageAttributeValue>();

            messageAttributes["from"] = new MessageAttributeValue
            {
                DataType    = "String",
                StringValue = trx.From
            };
            messageAttributes["to"] = new MessageAttributeValue
            {
                DataType    = "String",
                StringValue = trx.To
            };
            messageAttributes["value"] = new MessageAttributeValue
            {
                DataType    = "Number",
                StringValue = trx.GetIcxValue().ToString()
            };

            var request = new PublishRequest("arn:aws:sns:ap-southeast-2:850900483067:ICX_Transfer", msgStr, "transfer");

            request.MessageAttributes = messageAttributes;

            GetSNS().PublishAsync(request);

            Console.WriteLine($"Published message to AWS : ICX_Transfer, txHash " + trx.TxHash);
        }
        private void Tx_ConfirmedTransaction(object sender, NewTransactionDTO dto)
        {
            var tx = sender as NeblioTransaction;

            if (Transactions.TryGetValue(tx.TxId, out var t))
            {
                t.ConfirmedTransaction -= Tx_ConfirmedTransaction;
                LastConfirmedTxId       = t.TxId;
                ConfirmedTransaction?.Invoke(this, dto);
            }
        }
Exemple #3
0
        static public void publishContractMethodMessage(ConfirmedTransaction trx)
        {
            eventCounter++;
            var msgStr = JsonConvert.SerializeObject(trx);
            Dictionary <String, MessageAttributeValue> messageAttributes = new Dictionary <string, MessageAttributeValue>();

            messageAttributes["from"] = new MessageAttributeValue
            {
                DataType    = "String",
                StringValue = trx.From
            };
            messageAttributes["contract"] = new MessageAttributeValue
            {
                DataType    = "String",
                StringValue = trx.To
            };
            if (trx.Data != null && !(trx.Data is string) && trx.Data.method != null)
            {
                messageAttributes["method"] = new MessageAttributeValue
                {
                    DataType    = "String",
                    StringValue = trx.Data.method.Value
                };
            }

            List <string> eventList = new List <string>();

            foreach (var eventitem in trx.TxResultDetails.EventLogs)
            {
                string eventName = eventitem.Indexed[0];
                if (eventName.IndexOf("(") > 0)
                {
                    eventName = eventName.Substring(0, eventName.IndexOf("("));
                }
                eventList.Add(eventName);
            }

            messageAttributes["events"] = new MessageAttributeValue
            {
                DataType    = "String.Array",
                StringValue = "[\"" + string.Join("\",\"", eventList) + "\"]"
            };

            var request = new PublishRequest("arn:aws:sns:ap-southeast-2:850900483067:ICX_Contract_Method", msgStr, "score method");

            request.MessageAttributes = messageAttributes;

            GetSNS().PublishAsync(request);

            Console.WriteLine($"Published message to AWS : ICX_Contract_Method, txHash " + trx.TxHash);
        }
Exemple #4
0
        public async Task ProcessRecordAsync(ILambdaContext context, string message)
        {
            context.Logger.LogLine($"[{DateTime.Now.ToString()}] Processed record {message}");

            ConfirmedTransaction tx = JsonConvert.DeserializeObject <ConfirmedTransaction>(message);

            string  address;
            decimal amount;

            //Subscription to AWS Topic ICX_Transfer
            //Just triggered from normal ICX to ICX wallets
            if (tx.From != null && tx.From.StartsWith("hx") && tx.To != null && tx.To.StartsWith("hx"))
            {
                address = tx.To;
                amount  = tx.GetIcxValue();
                ProcessAddress(context, address, amount);
            }

            //Subscription to AWS Topic ICX_Contract_Method
            //Looks for specific events that causes ICX to be transferred
            if (tx.TxResultDetails != null)
            {
                foreach (var eventItem in tx.TxResultDetails.EventLogs)
                {
                    if (eventItem.Indexed[0].StartsWith("ICXTransfer"))
                    {
                        address = eventItem.Indexed[2];
                        amount  = IconGateway.GetIcxValueFromHex(eventItem.Indexed[3]);
                        ProcessAddress(context, address, amount);
                    }
                    if (eventItem.Indexed[0].StartsWith("IScoreClaimed"))
                    {
                        address = tx.From;
                        amount  = IconGateway.GetIcxValueFromHex(eventItem.Data[0]);
                        amount  = amount / 1000M;
                        ProcessAddress(context, address, amount);
                    }
                }
            }

            await Task.CompletedTask;
        }
        private async Task <bool> LoadRoutine()
        {
            var conf = Confirmations;

            Loading = true;
            var dto = await LoadInfoFromAPI();

            if (dto != null)
            {
                if (Confirmations < EconomyMainContext.NumberOfConfirmationsToAccept)
                {
                    (dto.TransactionDetails as NeblioTransaction).Dispose();
                    return(false);
                }
                else
                {
                    Loading = false;
                    if (conf < EconomyMainContext.NumberOfConfirmationsToAccept)
                    {
                        if (InvokeLoadFinish)
                        {
                            ConfirmedTransaction?.Invoke(this, dto);
                        }

                        (dto.TransactionDetails as NeblioTransaction).Dispose();

                        return(true);
                    }
                    else
                    {
                        (dto.TransactionDetails as NeblioTransaction).Dispose();
                        return(true);
                    }
                }

                (dto.TransactionDetails as NeblioTransaction).Dispose();
            }

            return(false);
        }
Exemple #6
0
        public JsonResult Confirm(ConfirmedTransaction confirmed)
        {
            //Get the transaction from the db
            var transaction = db.Transactions.Find(confirmed.TransactionID);

            //Update the CategoryID and VendorID to match the confirmed transaction
            transaction.VendorID   = confirmed.VendorID;
            transaction.CategoryID = confirmed.CategoryID;

            //Update the status to confirmed
            transaction.StatusID = 1;

            //Save Changes
            if (ModelState.IsValid)
            {
                db.Entry(transaction).State = EntityState.Modified;
                db.SaveChanges();
            }

            //Update the transaction count on the vendor category table or add a new row

            try
            {
                var vc = db.VendorCategory.Find(confirmed.VendorID, confirmed.CategoryID);
                vc.TransactionCount++;
                db.Entry(vc).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch
            {
                var newVC = new VendorCategory(confirmed.VendorID, confirmed.CategoryID, 1);
                db.VendorCategory.Add(newVC);
                db.SaveChanges();
            }

            confirmed.VendorDetected = transaction.VendorDetected;
            confirmed.Description    = transaction.Description;
            return(Json(confirmed));
        }
Exemple #7
0
        public async Task ProcessRecordAsync(ILambdaContext context, string message)
        {
            context.Logger.LogLine($"[{DateTime.Now.ToString()}] Processed record {message}");
            ConfirmedTransaction tx = JsonConvert.DeserializeObject <ConfirmedTransaction>(message);

            string  address;
            string  contractAddress;
            decimal amount;

            //Subscription to AWS Topic ICX_Contract_Method
            //Looks for specific events that causes Tokens to be transferred
            foreach (var eventItem in tx.TxResultDetails.EventLogs)
            {
                if (eventItem.Indexed[0].StartsWith("Transfer"))
                {
                    contractAddress = eventItem.ScoreAddress;
                    address         = eventItem.Indexed[2];
                    amount          = IconGateway.GetIcxValueFromHex(eventItem.Indexed[3]);
                    ProcessAddress(context, address, contractAddress, amount);
                }
            }

            await Task.CompletedTask;
        }