Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 public decimal GetIcxValue()
 {
     return(IconGateway.GetIcxValueFromHex(Value));
 }