Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="faucetManager">The Faucet manager.</param>
 /// <param name="ethereumAccountManager">The Ethereum Account Manager</param>
 /// <param name="networkManager">Network manager</param>
 /// <param name="requestIpAddressManager">IP Address manager.</param>
 /// <param name="contractInfoRegistry">Contract info registry</param>
 /// <param name="ethereumBlockStatus">Ethereum Block Status</param>
 public FaucetController(IFaucetManager faucetManager,
                         IEthereumAccountManager ethereumAccountManager,
                         IEthereumNetworkRegistry networkManager,
                         IRemoteIpAddressRetriever requestIpAddressManager,
                         IContractInfoRegistry contractInfoRegistry,
                         IEthereumBlockStatus ethereumBlockStatus)
 {
     this._faucetManager            = faucetManager ?? throw new ArgumentNullException(nameof(faucetManager));
     this._ethereumAccountManager   = ethereumAccountManager ?? throw new ArgumentNullException(nameof(ethereumAccountManager));
     this._networkManager           = networkManager ?? throw new ArgumentNullException(nameof(networkManager));
     this._remoteIpAddressRetriever = requestIpAddressManager ?? throw new ArgumentNullException(nameof(requestIpAddressManager));
     this._ethereumBlockStatus      = ethereumBlockStatus ?? throw new ArgumentNullException(nameof(ethereumBlockStatus));
     this._faucetContractInfo       = (contractInfoRegistry ?? throw new ArgumentNullException(nameof(contractInfoRegistry))).FindContractInfo(WellKnownContracts.Faucet);
 }
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="ethereumAccountManager">Ethereum account manager.</param>
 /// <param name="gameRoundDataManager">Game round data manager.</param>
 /// <param name="gameManager">Game Manager.</param>
 /// <param name="gameRoundLockManager">Game round lock manager.</param>
 /// <param name="dateTimeSource">Source of time.</param>
 /// <param name="logger">Logging.</param>
 public EndGameService(IEthereumAccountManager ethereumAccountManager,
                       IGameRoundDataManager gameRoundDataManager,
                       IGameManager gameManager,
                       IObjectLockManager <GameRoundId> gameRoundLockManager,
                       IDateTimeSource dateTimeSource,
                       ILogger <EndGameService> logger)
 {
     this._ethereumAccountManager = ethereumAccountManager ?? throw new ArgumentNullException(nameof(ethereumAccountManager));
     this._gameRoundDataManager   = gameRoundDataManager ?? throw new ArgumentNullException(nameof(gameRoundDataManager));
     this._gameManager            = gameManager ?? throw new ArgumentNullException(nameof(gameManager));
     this._gameRoundLockManager   = gameRoundLockManager ?? throw new ArgumentNullException(nameof(gameRoundLockManager));
     this._dateTimeSource         = dateTimeSource ?? throw new ArgumentNullException(nameof(dateTimeSource));
     this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Ejemplo n.º 5
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);
        }
        /// <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);
        }