public void Initialize(string testName = null) { Deploy(testName); HoardServiceOptions options = new HoardServiceOptions(); FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("settings.ini"); options.GameCenterContract = data["hoard_game_center"]["contract_addr"]; Assert.NotEmpty(options.GameCenterContract); options.BCClientOptions = new EthereumClientOptions(new Nethereum.JsonRpc.Client.RpcClient(new Uri(string.Format("http://{0}:{1}", data["network"]["host"], data["network"]["port"])))); HoardService = HoardService.Instance; try { HoardService.Initialize(options); } catch (Exception) { Assert.True(false); } //authenticate user UserIDs.Add(CreateUser().Result); }
public void Start() { HoardConfig = new HoardConfigLoader(hoardConfig).GetHoardServiceOptions(); var clientURL = ((EthereumClientConfig)HoardConfig.BCClient).ClientUrl; var ethClient = new EthereumClientOptions(new UnityRpcClientAsync(new Uri(clientURL))); var options = new HoardServiceOptions(HoardConfig, ethClient); HoardService.Instance.Initialize(options) .ContinueGUISynch(AfterInit); }
public void InitializeFromConfig(string configPath = null) { HoardServiceConfig config = HoardServiceConfig.Load(configPath); BCClientOptions clientOpts = null; if (config.BCClient is EthereumClientConfig) { var ethConfig = config.BCClient as EthereumClientConfig; clientOpts = new EthereumClientOptions( new Nethereum.JsonRpc.Client.RpcClient(new Uri(ethConfig.ClientUrl)) ); } else { var plasmaConfig = config.BCClient as PlasmaClientConfig; PlasmaCore.RPC.RpcClient watcherClient = new PlasmaCore.RPC.RpcClient(new Uri(plasmaConfig.WatcherUrl)); PlasmaCore.RPC.RpcClient childChainClient = null; if (plasmaConfig.ChildChainUrl != null && plasmaConfig.ChildChainUrl != string.Empty) { childChainClient = new PlasmaCore.RPC.RpcClient(new Uri(plasmaConfig.ChildChainUrl)); } clientOpts = new PlasmaClientOptions( new Nethereum.JsonRpc.Client.RpcClient(new Uri(plasmaConfig.ClientUrl)), plasmaConfig.RootChainAddress, plasmaConfig.RootChainVersion, watcherClient, childChainClient ); } HoardServiceOptions options = new HoardServiceOptions(config, clientOpts); HoardService = HoardService.Instance; try { HoardService.Initialize(options); } catch (Exception) { Assert.True(false); } //authenticate user UserIDs.Add(CreateUser().Result); }
/// <summary> /// Creates blockchain communication channel based on given Hoard service options /// </summary> /// <param name="options">Hoard service options containing blockchain communication data</param> /// <returns>Specialized blockchain communication instance</returns> public static IBCComm Create(HoardServiceOptions options) { if (options.BCClientOptions is PlasmaClientOptions) { var clientOpts = options.BCClientOptions as PlasmaClientOptions; return(new PlasmaComm(clientOpts.RpcClient, options.GameCenterContract, clientOpts.WatcherClient, clientOpts.ChildChainClient, clientOpts.RootChainAddress, clientOpts.RootChainVersion)); } else if (options.BCClientOptions is EthereumClientOptions) { var clientOpts = options.BCClientOptions as EthereumClientOptions; return(new BCComm(clientOpts.RpcClient, options.GameCenterContract)); } else { throw new NotSupportedException(); } }