Exemplo n.º 1
0
        protected async Task <TokenModel> AuthorizeToGolos(CancellationToken token = default(CancellationToken))
        {
            var login    = ConfigurationManager.AppSettings["GolosLogin"];
            var password = ConfigurationManager.AppSettings["GolosPostingWif"];

            var keys = new List <byte[]> {
                Base58.DecodePrivateWif(password)
            };
            var op         = new Ditch.Golos.Operations.FollowOperation(login, "steepshot", Ditch.Golos.Models.FollowType.Blog, login);
            var properties = new Ditch.Golos.Models.DynamicGlobalPropertyObject
            {
                HeadBlockId     = "0000000000000000000000000000000000000000",
                Time            = DateTime.Now,
                HeadBlockNumber = 0
            };

            var operationManager = new Ditch.Golos.OperationManager(null);

            var tr = await operationManager.CreateTransactionAsync(properties, keys, op, token).ConfigureAwait(false);

            var trx = JsonConvert.SerializeObject(tr, operationManager.JsonSerializerSettings);

            var authModel = new AuthModel
            {
                Args     = trx,
                AuthType = AuthType.Golos
            };
            HttpContent content = new StringContent(JsonConvert.SerializeObject(authModel), Encoding.UTF8, "application/json");

            var httpClient = new HttpClient();
            var response   = await httpClient.PostAsync(AuthApiUrl, content, token).ConfigureAwait(false);

            var opt = await CreateResultAsync <TokenModel>(response, token).ConfigureAwait(false);

            Assert.IsTrue(opt.IsSuccess, opt.Exception?.Message);
            Assert.IsTrue(opt.Result.Login.Equals(login));
            Assert.IsTrue(opt.Result.Type == AuthType.Golos);
            return(opt.Result);
        }
Exemplo n.º 2
0
 public ApiProvider(IConfiguration configuration, HttpManager httpManager, WebSocketManager webSocketManager)
 {
     _steem         = new Ditch.Steem.OperationManager(httpManager);
     _golos         = new Ditch.Golos.OperationManager(webSocketManager);
     _configuration = configuration;
 }