Beispiel #1
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="transactionExecutorFactory">Transaction execution</param>
        /// <param name="faucetDataManager">Data manager for faucet.</param>
        /// <param name="ethereumAccountBalanceSource">Balance source for Ethereum/ERC20 tokens.</param>
        /// <param name="contractInfoRegistry">Registry of contracts.</param>
        /// <param name="houseFundingIpWhiteList">IP Whitelist for faucet/funding operations.</param>
        /// <param name="executionEnvironment">The Execution Environment.</param>
        /// <param name="faucetConfiguration">Faucet configuration.</param>
        /// <param name="ethereumAccountManager">Ethereum account manager</param>
        /// <param name="logger">Logging.</param>
        public FaucetManager(ITransactionExecutorFactory transactionExecutorFactory,
                             IFaucetDataManager faucetDataManager,
                             IEthereumAccountBalanceSource ethereumAccountBalanceSource,
                             IContractInfoRegistry contractInfoRegistry,
                             IWhiteListedIpAddressIdentifier houseFundingIpWhiteList,
                             ExecutionEnvironment executionEnvironment,
                             IFaucetConfiguration faucetConfiguration,
                             IEthereumAccountManager ethereumAccountManager,
                             ILogger <FaucetManager> logger)
        {
            if (contractInfoRegistry == null)
            {
                throw new ArgumentNullException(nameof(contractInfoRegistry));
            }

            if (faucetConfiguration == null)
            {
                throw new ArgumentNullException(nameof(faucetConfiguration));
            }

            this._faucetDataManager            = faucetDataManager ?? throw new ArgumentNullException(nameof(faucetDataManager));
            this._ethereumAccountBalanceSource = ethereumAccountBalanceSource ?? throw new ArgumentNullException(nameof(ethereumAccountBalanceSource));
            this._transactionExecutorFactory   = transactionExecutorFactory ?? throw new ArgumentNullException(nameof(transactionExecutorFactory));
            this._fundingWhiteList             = houseFundingIpWhiteList ?? throw new ArgumentNullException(nameof(houseFundingIpWhiteList));
            this._executionEnvironment         = executionEnvironment;
            this._ethereumAccountManager       = ethereumAccountManager ?? throw new ArgumentNullException(nameof(ethereumAccountManager));

            this._nativeCurrencyLimits = new Limits <EthereumAmount>(amountToIssue: faucetConfiguration.NativeCurrencyToGive, faucetConfiguration.NativeCurrencyToGive / 2);
            this._tokenCurrencyLimits  = new Limits <Token>(amountToIssue: faucetConfiguration.TokenToGive, faucetConfiguration.TokenToGive / 2);

            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));

            this._tokenContract  = (Erc20TokenContractInfo)contractInfoRegistry.FindContractInfo(WellKnownContracts.Token);
            this._faucetContract = contractInfoRegistry.FindContractInfo(WellKnownContracts.Faucet);
        }
        /// <summary>
        ///     Constructor,
        /// </summary>
        /// <param name="gameRoundDataManager">Game Round Data Manager</param>
        /// <param name="gameManager">Game manager</param>
        /// <param name="ethereumAccountManager">Ethereum account manager.</param>
        /// <param name="transactionLoader">Transaction Loader.</param>
        /// <param name="contractInfoRegistry">Contract info registry.</param>
        /// <param name="eventSignatureFactory">Event signature factory.</param>
        /// <param name="eventHandlerFactory">Event Handler Factory.</param>
        /// <param name="eventDataManager">Event data manager.</param>
        /// <param name="eventDecoder">Event Decoder.</param>
        /// <param name="confirmationsReadinessChecker">Confirmations readiness checker.</param>
        /// <param name="dateTimeSource">Source of time.</param>
        /// <param name="logger">Logging.</param>
        public BrokenGameRecovery(IGameRoundDataManager gameRoundDataManager,
                                  IGameManager gameManager,
                                  IEthereumAccountManager ethereumAccountManager,
                                  ITransactionLoader transactionLoader,
                                  IContractInfoRegistry contractInfoRegistry,
                                  IEventSignatureFactory eventSignatureFactory,
                                  IEventHandlerFactory eventHandlerFactory,
                                  IEventDataManager eventDataManager,
                                  IEventDecoder eventDecoder,
                                  IConfirmationsReadinessChecker confirmationsReadinessChecker,
                                  IDateTimeSource dateTimeSource,
                                  ILogger <BrokenGameRecovery> logger)
        {
            this._gameRoundDataManager          = gameRoundDataManager ?? throw new ArgumentNullException(nameof(gameRoundDataManager));
            this._gameManager                   = gameManager ?? throw new ArgumentNullException(nameof(gameManager));
            this._ethereumAccountManager        = ethereumAccountManager ?? throw new ArgumentNullException(nameof(ethereumAccountManager));
            this._transactionLoader             = transactionLoader ?? throw new ArgumentNullException(nameof(transactionLoader));
            this._eventSignatureFactory         = eventSignatureFactory ?? throw new ArgumentNullException(nameof(eventSignatureFactory));
            this._eventHandlerFactory           = eventHandlerFactory ?? throw new ArgumentNullException(nameof(eventHandlerFactory));
            this._eventDataManager              = eventDataManager ?? throw new ArgumentNullException(nameof(eventDataManager));
            this._eventDecoder                  = eventDecoder ?? throw new ArgumentNullException(nameof(eventDecoder));
            this._confirmationsReadinessChecker = confirmationsReadinessChecker ?? throw new ArgumentNullException(nameof(confirmationsReadinessChecker));
            this._dateTimeSource                = dateTimeSource ?? throw new ArgumentNullException(nameof(dateTimeSource));
            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));

            this._contractInfo = contractInfoRegistry.FindContractInfo(WellKnownContracts.GameManager);
        }
        /// <summary>
        ///     Constructor,
        /// </summary>
        /// <param name="transactionExecutorFactory">Transaction execution factory.</param>
        /// <param name="contractInfoRegistry">Contract info registry.</param>
        /// <param name="logger">Logging.</param>
        public TransactionService(ITransactionExecutorFactory transactionExecutorFactory, IContractInfoRegistry contractInfoRegistry, ILogger <TransactionService> logger)
        {
            this._transactionExecutorFactory = transactionExecutorFactory ?? throw new ArgumentNullException(nameof(transactionExecutorFactory));
            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));

            this._contractInfo = contractInfoRegistry.FindContractInfo(WellKnownContracts.GameManager);
        }
        public static void ConfigureEventProcessing(IServiceProvider serviceProvider)
        {
            IContractInfoRegistry          registry  = serviceProvider.GetRequiredService <IContractInfoRegistry>();
            IContractEventWatcherProcessor processor = serviceProvider.GetRequiredService <IContractEventWatcherProcessor>();

            IContractInfo contractInfo = registry.FindContractInfo(WellKnownContracts.GameManager);

            processor.RegisterEventHandler <StartGameRoundEventHandler, StartGameRoundEvent, StartGameRoundEventOutput>(contractInfo);
            processor.RegisterEventHandler <NoMoreBetsEventHandler, NoMoreBetsEvent, NoMoreBetsEventOutput>(contractInfo);
            processor.RegisterEventHandler <EndGameRoundEventHandler, EndGameRoundEvent, EndGameRoundEventOutput>(contractInfo);
        }
Beispiel #5
0
        public static void ConfigureEventProcessing(IServiceProvider serviceProvider)
        {
            // TODO: Implement any event handlers we need
#if FALSE
            IContractInfoRegistry          registry  = serviceProvider.GetRequiredService <IContractInfoRegistry>();
            IContractEventWatcherProcessor processor = serviceProvider.GetRequiredService <IContractEventWatcherProcessor>();

            IContractInfo contractInfo = registry.FindContractInfo(WellKnownContracts.GameManager);

            processor.RegisterEventHandler <CreateProgressivePotEventHandler, CreateProgressivePotEvent, CreateProgressivePotEventOutput>(contractInfo);
#endif
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="transactionExecutorFactory">Transaction execution</param>
        /// <param name="faucetDataManager">Data manager for faucet.</param>
        /// <param name="ethereumAccountBalanceSource">Balance source for Ethereum/ERC20 tokens.</param>
        /// <param name="contractInfoRegistry">Registry of contracts.</param>
        /// <param name="houseFundingIpWhiteList">IP Whitelist for faucet/funding operations.</param>
        /// <param name="executionEnvironment">The Execution Environment.</param>
        /// <param name="faucetConfiguration">Faucet configuration.</param>
        /// <param name="ethereumAccountManager">Ethereum account manager</param>
        /// <param name="logger">Logging.</param>
        public FaucetManager(ITransactionExecutorFactory transactionExecutorFactory,
                             IFaucetDataManager faucetDataManager,
                             IEthereumAccountBalanceSource ethereumAccountBalanceSource,
                             IContractInfoRegistry contractInfoRegistry,
                             IWhiteListedIpAddressIdentifier houseFundingIpWhiteList,
                             ExecutionEnvironment executionEnvironment,
                             IFaucetConfiguration faucetConfiguration,
                             IEthereumAccountManager ethereumAccountManager,
                             ILogger <FaucetManager> logger)
        {
            if (contractInfoRegistry == null)
            {
                throw new ArgumentNullException(nameof(contractInfoRegistry));
            }

            if (faucetConfiguration == null)
            {
                throw new ArgumentNullException(nameof(faucetConfiguration));
            }

            this._faucetDataManager            = faucetDataManager ?? throw new ArgumentNullException(nameof(faucetDataManager));
            this._ethereumAccountBalanceSource = ethereumAccountBalanceSource ?? throw new ArgumentNullException(nameof(ethereumAccountBalanceSource));
            this._transactionExecutorFactory   = transactionExecutorFactory ?? throw new ArgumentNullException(nameof(transactionExecutorFactory));
            this._fundingWhiteList             = houseFundingIpWhiteList ?? throw new ArgumentNullException(nameof(houseFundingIpWhiteList));
            this._executionEnvironment         = executionEnvironment;
            this._ethereumAccountManager       = ethereumAccountManager;
            this._ethToGive    = faucetConfiguration.EthToGive;
            this._tokenToGiven = faucetConfiguration.TokenToGive;
            this._maximumRecipientEthBalance   = this._ethToGive / 2;
            this._maximumRecipientTokenBalance = this._tokenToGiven / 2;

            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));

            this._tokenContract  = (Erc20TokenContractInfo)contractInfoRegistry.FindContractInfo(WellKnownContracts.Token);
            this._faucetContract = contractInfoRegistry.FindContractInfo(WellKnownContracts.Faucet);
        }
Beispiel #7
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="ethereumNetworkConfigurationManager">Ethereum network configuration manager.</param>
        /// <param name="ethereumAccountWatcher">Ethereum Account Watcher.</param>
        /// <param name="contractInfoRegistry">Contract info registry</param>
        /// <param name="alertDispatcher">Alert dispatcher.</param>
        /// <param name="faucetBalanceConfiguration">Faucet balance configuration</param>
        /// <param name="logger">Logger.</param>
        public DrainedFaucetAlerter(IEthereumNetworkConfigurationManager ethereumNetworkConfigurationManager,
                                    IEthereumAccountBalanceWatcher ethereumAccountWatcher,
                                    IContractInfoRegistry contractInfoRegistry,
                                    IAlertDispatcher alertDispatcher,
                                    IFaucetBalanceConfiguration faucetBalanceConfiguration,
                                    ILogger <DrainedFaucetAlerter> logger)
        {
            this._ethereumNetworkConfigurationManager = ethereumNetworkConfigurationManager ?? throw new ArgumentNullException(nameof(ethereumNetworkConfigurationManager));
            this._ethereumAccountWatcher     = ethereumAccountWatcher ?? throw new ArgumentNullException(nameof(ethereumAccountWatcher));
            this._contractInfoRegistry       = contractInfoRegistry ?? throw new ArgumentNullException(nameof(contractInfoRegistry));
            this._alertDispatcher            = alertDispatcher ?? throw new ArgumentNullException(nameof(alertDispatcher));
            this._faucetBalanceConfiguration = faucetBalanceConfiguration ?? throw new ArgumentNullException(nameof(faucetBalanceConfiguration));
            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));

            this._tokenContract = (Erc20TokenContractInfo)contractInfoRegistry.FindContractInfo(WellKnownContracts.Token);

            this._watchedContracts = new ConcurrentDictionary <NetworkAccount, SubscriptionToken>();
        }
Beispiel #8
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="gameRoundDataManager">Game round data manager</param>
        /// <param name="randomSource">Random source</param>
        /// <param name="transactionService">Transaction service</param>
        /// <param name="hasher">Hasher</param>
        /// <param name="contractInfoRegistry">Contract info registry.</param>
        /// <param name="gameStatisticsPublisher">The game stats publisher</param>
        /// <param name="lowBalanceWatcher">Low balance watcher</param>
        /// <param name="logger">Logger</param>
        public GameManager(IGameRoundDataManager gameRoundDataManager,
                           IRandomSource randomSource,
                           ITransactionService transactionService,
                           IHasher hasher,
                           IContractInfoRegistry contractInfoRegistry,
                           IGameStatisticsPublisher gameStatisticsPublisher,
                           ILowBalanceWatcher lowBalanceWatcher,
                           ILogger <GameManager> logger)
        {
            this._gameRoundDataManager = gameRoundDataManager ?? throw new ArgumentNullException(nameof(gameRoundDataManager));
            this._randomSource         = randomSource ?? throw new ArgumentNullException(nameof(randomSource));
            this._transactionService   = transactionService ?? throw new ArgumentNullException(nameof(transactionService));
            this._hasher = hasher ?? throw new ArgumentNullException(nameof(hasher));
            this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
            this._gameStatisticsPublisher = gameStatisticsPublisher ?? throw new ArgumentNullException(nameof(gameStatisticsPublisher));
            this._lowBalanceWatcher       = lowBalanceWatcher ?? throw new ArgumentNullException(nameof(lowBalanceWatcher));

            this._gameManager = contractInfoRegistry.FindContractInfo(WellKnownContracts.GameManager);
        }
Beispiel #9
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="ethereumAccountManager">The ethereum account manager.</param>
        /// <param name="gameManager">Game Manager.</param>
        /// <param name="gameRoundDataManager">Game round data manager.</param>
        /// <param name="ethereumBlockStatus">Ethereum block status.</param>
        /// <param name="gameManagerLockManager">Game contract lock manager.</param>
        /// <param name="contractInfoRegistry">The contract info registry.</param>
        /// <param name="gamesList">Game list.</param>
        /// <param name="playerCountManager">Player count manager.</param>
        /// <param name="logger">Logger</param>
        public StartGameService(IEthereumAccountManager ethereumAccountManager,
                                IGameManager gameManager,
                                IGameRoundDataManager gameRoundDataManager,
                                IEthereumBlockStatus ethereumBlockStatus,
                                IObjectLockManager <EthereumAddress> gameManagerLockManager,
                                IContractInfoRegistry contractInfoRegistry,
                                IGamesList gamesList,
                                IPlayerCountManager playerCountManager,
                                ILogger <StartGameService> logger)
        {
            this._ethereumAccountManager = ethereumAccountManager ?? throw new ArgumentNullException(nameof(ethereumAccountManager));

            this._gameManager            = gameManager ?? throw new ArgumentNullException(nameof(gameManager));
            this._gameRoundDataManager   = gameRoundDataManager ?? throw new ArgumentNullException(paramName: nameof(gameRoundDataManager));
            this._ethereumBlockStatus    = ethereumBlockStatus ?? throw new ArgumentNullException(nameof(ethereumBlockStatus));
            this._gameManagerLockManager = gameManagerLockManager ?? throw new ArgumentNullException(nameof(gameManagerLockManager));
            this._gamesList          = gamesList ?? throw new ArgumentNullException(nameof(gamesList));
            this._playerCountManager = playerCountManager ?? throw new ArgumentNullException(nameof(playerCountManager));
            this._logger             = logger ?? throw new ArgumentNullException(paramName: nameof(logger));

            this._contractInfo = contractInfoRegistry.FindContractInfo(WellKnownContracts.GameManager);
        }