public Task EnqueueAsync(
     T task)
 {
     return(_queue.PutRawMessageAsync
            (
                JsonConvert.SerializeObject(task)
            ));
 }
        public async Task WarningAsync(string message)
        {
            var obj = new
            {
                Type    = "Warnings",
                Sender  = _sender,
                Message = message
            };

            await _queue.PutRawMessageAsync(JsonConvert.SerializeObject(obj));
        }
 public Task AddCashinToMonitoring(string txHash, string userContract, BigInteger amount)
 {
     return(_queue.PutRawMessageAsync(new TransactionMonitoringMessage
     {
         UserContract = userContract,
         Amount = amount.ToString(),
         TxHash = txHash,
         Type = TransactionType.Cashin,
         PutDateTime = DateTime.UtcNow
     }.ToJson()));
 }
Esempio n. 4
0
        private async Task RepeatOperationTillWin(CoinTransactionMessage message)
        {
            var operation = await GetOperationAsync(message?.TransactionHash, message?.OperationId);

            if (operation == null)
            {
                return;
            }

            switch (operation.OperationType)
            {
            case HotWalletOperationType.Cashout:
                break;

            case HotWalletOperationType.Cashin:
                var retryMessage = new LykkePayErc20TransferMessage()
                {
                    OperationId = operation.OperationId
                };

                await _transferStartQueue.PutRawMessageAsync(retryMessage.ToJson());

                break;

            default:
                return;
            }
        }
Esempio n. 5
0
 public Task Add(Guid channelId)
 {
     return(_queue.PutRawMessageAsync(new CommitmentClosingTask
     {
         ChannelId = channelId
     }.ToJson()));
 }
Esempio n. 6
0
        private async Task IndexEventsInRange(string coinAdapterAddress, Nethereum.Contracts.Event coinCashInEvent, BigInteger from, BigInteger to)
        {
            var fromBlock = new Nethereum.RPC.Eth.DTOs.BlockParameter(new Nethereum.Hex.HexTypes.HexBigInteger(from));
            var toBlock   = new Nethereum.RPC.Eth.DTOs.BlockParameter(new Nethereum.Hex.HexTypes.HexBigInteger(to));
            var filter    = await coinCashInEvent.CreateFilterBlockRangeAsync(fromBlock, toBlock);

            var filterByCaller = await coinCashInEvent.GetAllChanges <CoinCashinEvent>(filter);

            filterByCaller.ForEach(async @event =>
            {
                string transactionHash = @event.Log.TransactionHash;
                CoinEventCashinCompletedMessage cashinTransactionMessage = new CoinEventCashinCompletedMessage()
                {
                    TransactionHash = transactionHash
                };

                await _cashinEventRepository.InsertAsync(new CashinEvent()
                {
                    CoinAdapterAddress = coinAdapterAddress,
                    Amount             = @event.Event.Amount.ToString(),
                    TransactionHash    = transactionHash,
                    UserAddress        = @event.Event.Caller
                });

                await _cashinQueue.PutRawMessageAsync(Newtonsoft.Json.JsonConvert.SerializeObject(cashinTransactionMessage));
            });

            await _blockSyncedRepository.InsertAsync(new BlockSynced()
            {
                BlockNumber = to.ToString(), CoinAdapterAddress = coinAdapterAddress
            });
        }
Esempio n. 7
0
 public Task AddToReturn(string transactionHex, List <string> address)
 {
     return(_queue.PutRawMessageAsync(new ReturnOutputMessage
     {
         TransactionHex = transactionHex,
         Addresses = address
     }.ToJson()));
 }
 public async Task CreateUpsertAssetImageCommand(IEnumerable <string> assetIds, string iconUrl, string imageUrl)
 {
     await _queue.PutRawMessageAsync(new AssetImageContext
     {
         AssetIds = assetIds,
         IconUrl  = iconUrl,
         ImageUrl = imageUrl
     }.ToJson());
 }
 public Task AddToMonitoring(Guid transactionId, string transactionHash)
 {
     return(_queue.PutRawMessageAsync(new TransactionMonitoringMessage
     {
         TransactionId = transactionId,
         TransactionHash = transactionHash,
         PutDateTime = DateTime.UtcNow
     }.ToJson()));
 }
 public Task AddToMonitoring(Guid commitmentId, string transactionHash)
 {
     return(_queue.PutRawMessageAsync(new SpendCommitmentMonitorindMessage()
     {
         PutDateTime = DateTime.UtcNow,
         TransactionHash = transactionHash,
         CommitmentId = commitmentId
     }.ToJson()));
 }
Esempio n. 11
0
        public Task CreateParseBlockCommand(string blockHash)
        {
            var context = new AssetDefinitionParseBlockContext
            {
                BlockHash = blockHash
            };

            return(_queue.PutRawMessageAsync(context.ToJson()));
        }
 public Task AddNotify(string txHash, string contract, decimal amount)
 {
     return(_queue.PutRawMessageAsync(new IssueNotifyMessage
     {
         TransactionHash = txHash,
         Contract = contract,
         Amount = amount
     }.ToJson()));
 }
        public async Task RefreshOperationByIdAsync(string operationId)
        {
            IOperationToHashMatch match = await _operationToHashMatchRepository.GetAsync(operationId);

            if (match == null)
            {
                return;
            }

            match.TransactionHash = "";

            await _operationToHashMatchRepository.InsertOrReplaceAsync(match);

            await _queue.PutRawMessageAsync(JsonConvert.SerializeObject(new OperationHashMatchMessage()
            {
                OperationId = match.OperationId
            }));
        }
Esempio n. 14
0
 public async Task CreateAssetCoinholdersUpdateIndexCommand(params string[] assetIds)
 {
     foreach (var assetID in assetIds)
     {
         await _queue.PutRawMessageAsync(new AssetCoinholdersUpdateIndexCommand
         {
             AssetId = assetID
         }.ToJson());
     }
 }
Esempio n. 15
0
 public Task AddTask(string hash, DateTime date, string asset, string multisig)
 {
     return(_queue.PutRawMessageAsync(new PaidFeesTask
     {
         TransactionHash = hash,
         Date = date,
         Multisig = multisig,
         Asset = asset
     }.ToJson()));
 }
Esempio n. 16
0
        public async Task CreateCommand(string address, string email)
        {
            var msg = new AddressTransactionReportQueueCommand
            {
                Address = address,
                Email   = email
            };

            await _queue.PutRawMessageAsync(msg.ToJson());
        }
 public async Task AddCommand(Guid transactionId, TransactionCommandType type, string command)
 {
     var msg = new TransactionQueueMessage
     {
         TransactionId = transactionId,
         Type          = type,
         Command       = command
     };
     await _queue.PutRawMessageAsync(msg.ToJson());
 }
Esempio n. 18
0
        public async Task CreateCommand(string assetId, string email)
        {
            var msg = new AssetTransactionReportQueueCommand
            {
                AssetId = assetId,
                Email   = email
            };

            await _queue.PutRawMessageAsync(msg.ToJson());
        }
        public async Task CreateCommand(IEnumerable <string> blocks, string email)
        {
            var msg = new BlockTransactionReportQueueCommand
            {
                Blocks = blocks.ToArray(),
                Email  = email
            };

            await _queue.PutRawMessageAsync(msg.ToJson());
        }
        public Task AddTransactionFeeReserve(Guid transactionId, List <ICoin> feeCoins)
        {
            var message = new FeeReserveMonitoringMessage
            {
                PutDateTime   = DateTime.UtcNow,
                TransactionId = transactionId,
                FeeCoins      = feeCoins.OfType <Coin>().Select(x => new SerializableCoin(x)).ToList()
            };

            return(_queue.PutRawMessageAsync(message.ToJson()));
        }
Esempio n. 21
0
 public async Task EnqueueOutputs(params Coin[] coins)
 {
     if (coins == null)
     {
         return;
     }
     foreach (var item in coins)
     {
         await _queue.PutRawMessageAsync(new SerializableCoin(item).ToJson());
     }
 }
Esempio n. 22
0
        public async Task RetryCashoutAsync(IHotWalletOperation hotWalletCashout)
        {
            HotWalletCashoutMessage message = new HotWalletCashoutMessage()
            {
                OperationId = hotWalletCashout.OperationId
            };

            await _hotWalletCashoutRepository.SaveAsync(hotWalletCashout);

            await _hotWalletCashoutQueue.PutRawMessageAsync(Newtonsoft.Json.JsonConvert.SerializeObject(message));
        }
Esempio n. 23
0
 public async Task Notify(SlackMessage message)
 {
     try
     {
         await _slackQueue.PutRawMessageAsync(JsonConvert.SerializeObject(message));
     }
     catch (Exception e)
     {
         var a = 234;
     }
 }
Esempio n. 24
0
        public async Task CreateRetrieveAssetDefinitionCommand(params string[] urls)
        {
            foreach (var url in urls)
            {
                var context = new UpdateAssetDataContext
                {
                    AssetDefinitionUrl = url
                };

                await _queue.PutRawMessageAsync(context.ToJson());
            }
        }
        public async Task UpdateUserAssignmentFail(string contractAddress, string userAddress, string coinAdapter)
        {
            var canBeRestoredInternally = !string.IsNullOrEmpty(userAddress) && userAddress != Constants.EmptyEthereumAddress;

            var userAssignmentFail = await _userAssignmentFailRepository.GetAsync(contractAddress);

            if (userAssignmentFail == null)
            {
                userAssignmentFail = new UserAssignmentFail()
                {
                    CanBeRestoredInternally = canBeRestoredInternally,
                    ContractAddress         = contractAddress,
                    NotifiedInSlack         = false,
                    FailCount = 0
                };
            }

            if (userAssignmentFail.FailCount == _attempsBeforeReassign)
            {
                if (canBeRestoredInternally)
                {
                    var message = new TransferContractUserAssignment()
                    {
                        CoinAdapterAddress      = coinAdapter,
                        TransferContractAddress = contractAddress,
                        UserAddress             = userAddress
                    };

                    await _queueUserAssignment.PutRawMessageAsync(JsonConvert.SerializeObject(message));

                    userAssignmentFail.FailCount = 0;
                }
                else
                {
                    if (userAssignmentFail.NotifiedInSlack.HasValue &&
                        !userAssignmentFail.NotifiedInSlack.Value)
                    {
                        await _slackNotifier.ErrorAsync($"TransferAddress - {contractAddress}, UserAddress - {userAddress}, " +
                                                        $"CoinAdapter Address - {coinAdapter} can't be restored internally");

                        await _userAssignmentFailRepository.SaveAsync(userAssignmentFail);
                    }

                    return;
                }
            }
            else
            {
                userAssignmentFail.FailCount++;
            }

            await _userAssignmentFailRepository.SaveAsync(userAssignmentFail);
        }
        private async Task ResubmittTransactionAsync(string transactionHash, string operationId, IOperationResubmitt counter)
        {
            await _transactionMonitoringQueue.PutRawMessageAsync(
                Newtonsoft.Json.JsonConvert.SerializeObject(
                    new CoinTransactionMessage()
            {
                TransactionHash = transactionHash,
                OperationId     = operationId,
                LastError       = "FROM_JOB",
                PutDateTime     = DateTime.UtcNow
            }
                    ));

            counter.ResubmittCount++;
            await _operationResubmittRepository.InsertOrReplaceAsync(counter);
        }
Esempio n. 27
0
        public async Task Start()
        {
            int?cnt = 0;
            int i   = 0;

            while ((cnt = await _fromQueue.Count()) > 0)
            {
                var msg = await _fromQueue.GetRawMessageAsync();

                await _toQueue.PutRawMessageAsync(msg.AsString);

                await _fromQueue.FinishRawMessageAsync(msg);

                Console.WriteLine($"Processed {++i} from {cnt}");
            }
        }
        public async Task AddPaidFee(Guid id, string asset, string fromClient, string toClient, decimal volume, DateTime date, string order, string tradeClient, string tradeOppositeClient, decimal tradeVolume)
        {
            var msg = new PaidFeeQueueItem
            {
                AssetId             = asset,
                Date                = date,
                FromClient          = fromClient,
                Id                  = id,
                Order               = order,
                ToClient            = toClient,
                Volume              = volume,
                TradeClient         = tradeClient,
                TradeOppositeClient = tradeOppositeClient,
                TradeVolume         = tradeVolume
            };

            await _queue.PutRawMessageAsync(msg.ToJson());
        }
Esempio n. 29
0
        public void Warning(string title, string message)
        {
            var obj = new
            {
                Data = new
                {
                    BroadcastGroup = 100,
                    MessageData    = new
                    {
                        Subject = title,
                        Text    = message
                    }
                }
            };

            var str = "PlainTextBroadcast:" + JsonConvert.SerializeObject(obj);

            _queue.PutRawMessageAsync(str);
        }
        /// <summary>
        /// Sends event for ethereum payment to azure queue
        /// </summary>
        /// <param name="userContract"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public async Task FirePaymentEvent(string userContract, decimal amount, string trHash)
        {
            try
            {
                var model = new EthereumCashInModel
                {
                    Amount          = amount,
                    Contract        = userContract,
                    TransactionHash = trHash
                };

                var json = JsonConvert.SerializeObject(model);

                await _queue.PutRawMessageAsync(json);
            }
            catch (Exception e)
            {
                await _logger.WriteErrorAsync("ApiCallService", "FirePaymentEvent", $"Contract : {userContract}, amount: {amount}", e);
            }
        }