public async Task Handle(OperationAcceptedEvent evt, ICommandSender sender)
        {
            var aggregate = await _riskControlRepository.TryGetAsync(evt.OperationId);

            if (aggregate == null)
            {
                return; // not a cashout operation
            }

            if (aggregate.OnOperationAccepted())
            {
                sender.SendCommand
                (
                    new AcceptCashoutCommand
                {
                    OperationId       = evt.OperationId,
                    ClientId          = aggregate.ClientId,
                    AssetId           = aggregate.AssetId,
                    BlockchainType    = aggregate.BlockchainType,
                    BlockchainAssetId = aggregate.BlockchainAssetId,
                    HotWalletAddress  = aggregate.HotWalletAddress,
                    ToAddress         = aggregate.ToAddress,
                    Amount            = aggregate.Amount
                },
                    Self
                );

                _chaosKitty.Meow(evt.OperationId);

                await _riskControlRepository.SaveAsync(aggregate);

                _chaosKitty.Meow(evt.OperationId);
            }
        }
        public Task Handle(OperationAcceptedEvent evt, ICommandSender sender)
        {
            sender.SendCommand
            (
                new RegisterOperationStatisticsCommand
            {
                OperationId = evt.OperationId
            },
                BlockchainRiskControlBoundedContext.Name
            );

            return(Task.CompletedTask);
        }
示例#3
0
        public async Task Handle(OperationAcceptedEvent message)
        {
            var op = await _dbContext.Operations.FindAsync(message.OperationId).ConfigureAwait(false);

            if (op == null)
            {
                return;
            }

            op.Status        = OperationStatus.Running;
            op.StatusMessage = OperationStatus.Running.ToString();
            op.AgentName     = message.AgentName;

            await _dbContext.SaveChangesAsync();
        }
示例#4
0
        private async Task Handle(OperationAcceptedEvent evt, ICommandSender sender)
        {
            var aggregate = await _cashinRepository.TryGetAsync(evt.OperationId);

            if (aggregate == null)
            {
                // This is not a cashin operation
                return;
            }

            var transitionResult = aggregate.OnOperationAccepted();

            if (transitionResult.ShouldSaveAggregate())
            {
                await _cashinRepository.SaveAsync(aggregate);
            }

            if (transitionResult.ShouldSendCommands())
            {
                sender.SendCommand
                (
                    new EnrollToMatchingEngineCommand
                {
                    AssetId                       = aggregate.AssetId,
                    BlockchainAssetId             = aggregate.BlockchainAssetId,
                    BlockchainType                = aggregate.BlockchainType,
                    DepositWalletAddress          = aggregate.DepositWalletAddress,
                    OperationId                   = aggregate.OperationId,
                    MatchingEngineOperationAmount = aggregate.MeAmount.Value,
                    ClientId                      = aggregate.ClientId
                },
                    Self
                );

                _chaosKitty.Meow(evt.OperationId);
            }
        }