Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task <object> GetAsset(UInt160 asset)
        {
            var assetInfo = AssetCache.GetAssetInfo(asset);

            if (assetInfo == null)
            {
                return(null);
            }
            var totalSupply = AssetCache.GetTotalSupply(asset);

            using var db = new TrackDB();
            var record = db.GetContract(asset);
            var trans  = db.QueryTransactions(new TransactionFilter()
            {
                Contracts = new List <UInt160>()
                {
                    asset
                }, PageSize = 0
            });

            return(new AssetInfoModel()
            {
                Asset = assetInfo.Asset,
                Decimals = assetInfo.Decimals,
                Name = assetInfo.Name,
                Symbol = assetInfo.Symbol,
                TotalSupply = totalSupply,
                CreateTime = record?.CreateTime,
                TransactionCount = trans.TotalCount,
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// query all nep transactions(on chain)
        /// </summary>
        /// <returns></returns>
        public async Task <object> QueryNep5Transactions(int pageIndex = 1, int limit = 100, UInt160 address = null, UInt160 asset = null, uint?blockHeight = null)
        {
            using var db = new TrackDB();
            var filter = new TransactionFilter()
            {
                BlockHeight = blockHeight,
                PageIndex   = pageIndex,
                PageSize    = limit
            };

            if (address != null)
            {
                filter.FromOrTo = new List <UInt160>()
                {
                    address
                };
            }
            if (asset != null)
            {
                filter.Contracts = new List <UInt160>()
                {
                    asset
                };
            }
            var trans  = db.QueryTransactions(filter, true);
            var result = new PageList <TransactionPreviewModel>
            {
                TotalCount = trans.TotalCount,
                PageSize   = trans.PageSize,
                PageIndex  = pageIndex,
                List       = ConvertToTransactionPreviewModel(trans.List),
            };

            return(result);
        }