Exemple #1
0
        public async Task <ActionResult <IEnumerable <BigMapUpdate> > > GetBigMapUpdates(
            Int32Parameter bigmap,
            StringParameter path,
            AccountParameter contract,
            BigMapTagsParameter tags,
            BigMapActionParameter action,
            JsonParameter value,
            Int32Parameter level,
            TimestampParameter timestamp,
            SortParameter sort,
            OffsetParameter offset,
            [Range(0, 10000)] int limit = 100,
            MichelineFormat micheline   = MichelineFormat.Json)
        {
            #region validate
            if (sort != null && !sort.Validate("id", "level"))
            {
                return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."));
            }
            #endregion

            if (path == null && contract == null && tags == null)
            {
                return(Ok(await BigMaps.GetUpdates(bigmap, action, value, level, timestamp, sort, offset, limit, micheline)));
            }

            return(Ok(await BigMaps.GetUpdates(bigmap, path, contract, action, value, tags, level, timestamp, sort, offset, limit, micheline)));
        }
Exemple #2
0
        public async Task <ActionResult <IEnumerable <BigMap> > > GetBigMaps(
            AccountParameter contract,
            StringParameter path,
            BigMapTagsParameter tags,
            bool?active,
            Int32Parameter lastLevel,
            SelectParameter select,
            SortParameter sort,
            OffsetParameter offset,
            [Range(0, 10000)] int limit = 100,
            MichelineFormat micheline   = MichelineFormat.Json)
        {
            #region validate
            if (sort != null && !sort.Validate("id", "ptr", "firstLevel", "lastLevel", "totalKeys", "activeKeys", "updates"))
            {
                return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."));
            }
            #endregion

            if (select == null)
            {
                return(Ok(await BigMaps.Get(contract, path, tags, active, lastLevel, sort, offset, limit, micheline)));
            }

            if (select.Values != null)
            {
                if (select.Values.Length == 1)
                {
                    return(Ok(await BigMaps.Get(contract, path, tags, active, lastLevel, sort, offset, limit, select.Values[0], micheline)));
                }
                else
                {
                    return(Ok(await BigMaps.Get(contract, path, tags, active, lastLevel, sort, offset, limit, select.Values, micheline)));
                }
            }
            else
            {
                if (select.Fields.Length == 1)
                {
                    return(Ok(await BigMaps.Get(contract, path, tags, active, lastLevel, sort, offset, limit, select.Fields[0], micheline)));
                }
                else
                {
                    return(Ok(new SelectionResponse
                    {
                        Cols = select.Fields,
                        Rows = await BigMaps.Get(contract, path, tags, active, lastLevel, sort, offset, limit, select.Fields, micheline)
                    }));
                }
            }
        }