Exemplo n.º 1
0
        public async Task <CommandHandlingResult> Handle(AssignErc223DepositToUserCommand command,
                                                         IEventPublisher eventPublisher)
        {
            await _contractRepository.AddOrReplace(new Erc20DepositContract
            {
                ContractAddress = command.ContractAddress,
                UserAddress     = command.UserAddress
            });

            eventPublisher.PublishEvent(new Erc223DepositAssignedToUserEvent()
            {
                UserAddress     = command.UserAddress,
                ContractAddress = command.ContractAddress
            });

            return(CommandHandlingResult.Ok());
        }
        public async Task <string> AssignContract(string userAddress)
        {
            var contractAddress = await GetContractAddress(userAddress);

            if (string.IsNullOrEmpty(contractAddress))
            {
                var pool = _poolFactory.Get(Constants.Erc20DepositContractPoolQueue);

                contractAddress = await pool.GetContractAddress();

                await _contractRepository.AddOrReplace(new Erc20DepositContract
                {
                    ContractAddress = contractAddress,
                    UserAddress     = userAddress
                });
            }

            return(contractAddress);
        }