Exemple #1
0
        public async Task PostDepositNotEmpty()
        {
            using var client = CreateClient(Configuration.LocalBaseUrl);

            var baseReq = await client.CreateBaseReq(Configuration.LocalAccount1Address, "memo", null, null, null, null);

            var amount = new List <Coin>()
            {
                new Coin()
                {
                    Amount = 10,
                    Denom  = "stake"
                }
            };
            var depositReq = new DepositReq(baseReq, Configuration.LocalAccount1Address, amount);
            var tx         = await client
                             .Governance
                             .PostDepositAsync(ProposalId, depositReq);

            OutputHelper.WriteLine("Deserialized StdTx:");
            Dump(tx);

            Assert.Equal("memo", tx.Memo);
            var msgDeposit = tx.Msg.OfType <MsgDeposit>().First();

            Assert.Equal(Configuration.LocalAccount1Address, msgDeposit.Depositor, StringComparer.Ordinal);
            Assert.Equal(ProposalId, msgDeposit.ProposalId);
            Assert.Collection(msgDeposit.Amount, c =>
            {
                Assert.Equal(10, c.Amount);
                Assert.Equal("stake", c.Denom, StringComparer.OrdinalIgnoreCase);
            });
        }
Exemple #2
0
        public IActionResult DepositFunds(DepositReq model)
        {
            var response = _paymentsService.DepositFunds(model);

            if (response == null)
            {
                return(BadRequest(new { message = "User do not exist or not enough balance" }));
            }

            return(Ok(response));
        }
Exemple #3
0
        public Task <StdTx> PostDepositAsync(ulong proposalId, DepositReq request, CancellationToken cancellationToken = default)
        {
            var baseReq = new BaseReqWithSimulate(request.BaseReq, false);

            request = new DepositReq(baseReq, request.Depositor, request.Amount);

            return(_clientGetter()
                   .Request("gov", "proposals", proposalId, "deposits")
                   .PostJsonAsync(request, cancellationToken)
                   .ReceiveJson <StdTx>()
                   .WrapExceptions());
        }
Exemple #4
0
        /*
         * protected StockDatabase GetDatabase()
         * {
         *  return new StockDatabase("d:/VDisk/SNL/flash_stock.db");
         * }
         */

        public void Deposit(DepositReq depositReq)
        {
            //using var db = GetDatabase();
            var db = _db;

            db.Trans.Add(new TransEntity
            {
                TranTime = depositReq.TranTime,
                TranType = "Deposit",
                StockId  = string.Empty,
                Balance  = depositReq.Balance,
            });
            db.SaveChanges();
        }
        public async Task <DepositRes> DepositFunds(DepositReq model)
        {
            var accessTokenRes = await GetAccessToken();

            var data         = JObject.Parse(accessTokenRes);
            var access_token = data["access_token"].Value <string>();

            var orderRes = await MakeOrder(access_token, model);

            return(new DepositRes
            {
                Status = "OK"
            });
        }
        private async Task <HttpResponseMessage> MakeOrder(string token, DepositReq model)
        {
            using (var client = new HttpClient())
            {
                var content = new PaypalOrder(model);
                var json    = JsonConvert.SerializeObject(content);
                var req     = new HttpRequestMessage(HttpMethod.Post, "https://api-m.sandbox.paypal.com/v2/checkout/orders")
                {
                    Content = new StringContent(json, Encoding.UTF8, "application/json")
                };
                req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

                var response = await client.SendAsync(req);

                return(response);
            }
        }
Exemple #7
0
        public async Task PostDepositSimulationNotEmpty()
        {
            using var client = CreateClient(Configuration.LocalBaseUrl);

            var baseReq = await client.CreateBaseReq(Configuration.LocalAccount1Address, "", null, null, null, null);

            var amount = new List <Coin>()
            {
                new Coin()
                {
                    Amount = 10,
                    Denom  = "stake"
                }
            };
            var depositReq = new DepositReq(baseReq, Configuration.LocalDelegator1Address, amount);
            var estimation = await client
                             .Governance
                             .PostDepositSimulationAsync(ProposalId, depositReq);

            OutputHelper.WriteLine("Deserialized Gas Estimation:");
            Dump(estimation);

            Assert.True(estimation.GasEstimate > 0);
        }
Exemple #8
0
 public StdTx PostDeposit(ulong proposalId, DepositReq request)
 {
     return(PostDepositAsync(proposalId, request)
            .Sync());
 }
Exemple #9
0
 public GasEstimateResponse PostDepositSimulation(ulong proposalId, DepositReq request)
 {
     return(PostDepositSimulationAsync(proposalId, request)
            .Sync());
 }