public ContractsData GetContracts(int page)
        {
            const int numPerPage = 20;

            if (page <= 0)
            {
                page = 1;
            }
            var result = new ContractsData {
                Page = page
            };

            using (var client = CreateApi())
            {
                var offset = numPerPage * (page - 1);
                var res    = client.SmartContractsAllListGet(offset, numPerPage + 1);
                result.HaveNextPage = res.SmartContractsList.Count > numPerPage;
                var count = Math.Min(numPerPage, res.SmartContractsList.Count);
                for (var i = 0; i < count; i++)
                {
                    var c     = res.SmartContractsList[i];
                    var cInfo = new ContractLinkInfo(i + offset + 1, Base58Encoding.Encode(c.Address));
                    result.Contracts.Add(cInfo);
                }
            }
            result.NumStr = result.Contracts.Any() ? $"{result.Contracts.First().Index} - {result.Contracts.Last().Index}" : "0";
            return(result);
        }
Esempio n. 2
0
        public ContractsData GetContracts(int page)
        {
            if (page <= 0)
            {
                page = 1;
            }
            var result = new ContractsData {
                Page = page, LastPage = 1
            };

            using (var db = ApiFab.GetDbContext())
            {
                var i = 1;
                foreach (var s in db.Smarts.Where(s => s.Network == Net))
                {
                    result.Contracts.Add(new ContractLinkInfo(i++, s.Address));
                }
            }
            result.NumStr = result.Contracts.Any() ? $"{result.Contracts.First().Index} - {result.Contracts.Last().Index}" : "0";
            return(result);
        }
Esempio n. 3
0
        public ContractsData GetContracts(int page)
        {
            if (page <= 0)
            {
                page = 1;
            }
            var result = new ContractsData {
                Page = page
            };

            if (Net == "tetris")
            {
                using (var client = CreateApi())
                {
                    var offset = result.NumPerPage * (page - 1);
                    var res    = client.SmartContractsAllListGet(offset, result.NumPerPage + 1);
                    result.HaveNextPage = res.SmartContractsList.Count > result.NumPerPage;
                    var count = Math.Min(result.NumPerPage, res.SmartContractsList.Count);
                    for (var i = 0; i < count; i++)
                    {
                        var c     = res.SmartContractsList[i];
                        var cInfo = new ContractLinkInfo(i + offset + 1, c.Address);
                        result.Contracts.Add(cInfo);
                    }
                }
            }
            else
            {
                using (var db = ApiFab.GetDbContext())
                {
                    var i = 1;
                    foreach (var s in db.Smarts.Where(s => s.Network == Net))
                    {
                        result.Contracts.Add(new ContractLinkInfo(i++, s.Address));
                    }
                }
            }
            return(result);
        }