コード例 #1
0
 public async Task <IEnumerable <OriginationOperation> > GetOriginations(
     AnyOfParameter anyof,
     AccountParameter initiator,
     AccountParameter sender,
     AccountParameter contractManager,
     AccountParameter contractDelegate,
     AccountParameter originatedContract,
     Int32Parameter typeHash,
     Int32Parameter codeHash,
     Int32Parameter level,
     DateTimeParameter timestamp,
     OperationStatusParameter status,
     SortParameter sort,
     OffsetParameter offset,
     int limit,
     MichelineFormat format,
     Symbols quote,
     bool includeStorage = false,
     bool includeBigmaps = false)
 {
     var sql = new SqlBuilder($@"
         SELECT      o.*, b.""Hash""
         FROM        ""OriginationOps"" AS o
         INNER JOIN  ""Blocks"" as b
                 ON  b.""Level"" = o.""Level""
         {(typeHash != null || codeHash != null ? @"LEFT JOIN ""Accounts"" as c ON c.""Id"" = o.""ContractId""" : "")}")
               .Filter(anyof, x => x switch
     {
         "initiator" => "InitiatorId",
         "sender" => "SenderId",
         "contractManager" => "ManagerId",
         "contractDelegate" => "DelegateId",
         _ => "ContractId"
     })
コード例 #2
0
 public async Task <IEnumerable <RegisterConstantOperation> > GetRegisterConstants(
     AccountParameter sender,
     ExpressionParameter address,
     Int32Parameter level,
     DateTimeParameter timestamp,
     OperationStatusParameter status,
     SortParameter sort,
     OffsetParameter offset,
     int limit,
     MichelineFormat format,
     Symbols quote)
 {
     var sql = new SqlBuilder(@"
         SELECT      o.*, b.""Hash""
         FROM        ""RegisterConstantOps"" AS o
         INNER JOIN  ""Blocks"" as b
                 ON  b.""Level"" = o.""Level""")
               .Filter("SenderId", sender)
               .Filter("Address", address)
               .FilterA(@"o.""Level""", level)
               .FilterA(@"o.""Timestamp""", timestamp)
               .Filter("Status", status)
               .Take(sort, offset, limit, x => x switch
     {
         "level" => ("Id", "Level"),
         "gasUsed" => ("GasUsed", "GasUsed"),
         "storageUsed" => ("StorageUsed", "StorageUsed"),
         "bakerFee" => ("BakerFee", "BakerFee"),
         "storageFee" => ("StorageFee", "StorageFee"),
         _ => ("Id", "Id")
     }, "o");
コード例 #3
0
 public async Task <IEnumerable <DelegationOperation> > GetDelegations(
     AnyOfParameter anyof,
     AccountParameter initiator,
     AccountParameter sender,
     AccountParameter prevDelegate,
     AccountParameter newDelegate,
     Int32Parameter level,
     DateTimeParameter timestamp,
     OperationStatusParameter status,
     SortParameter sort,
     OffsetParameter offset,
     int limit,
     Symbols quote)
 {
     var sql = new SqlBuilder(@"SELECT o.*, b.""Hash"" FROM ""DelegationOps"" AS o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level""")
               .Filter(anyof, x => x switch
     {
         "initiator" => "InitiatorId",
         "sender" => "SenderId",
         "prevDelegate" => "PrevDelegateId",
         _ => "DelegateId"
     })
コード例 #4
0
ファイル: AccountsController.cs プロジェクト: baking-bad/tzkt
        public async Task <ActionResult <IEnumerable <Operation> > > GetOperations(
            [Required][Address] string address,
            string type,
            AccountParameter initiator,
            AccountParameter sender,
            AccountParameter target,
            AccountParameter prevDelegate,
            AccountParameter newDelegate,
            AccountParameter contractManager,
            AccountParameter contractDelegate,
            AccountParameter originatedContract,
            AccountParameter accuser,
            AccountParameter offender,
            AccountParameter baker,
            Int32Parameter level,
            DateTimeParameter timestamp,
            StringParameter entrypoint,
            JsonParameter parameter,
            StringParameter parameters,
            BoolParameter hasInternals,
            OperationStatusParameter status,
            SortMode sort = SortMode.Descending,
            int?lastId    = null,
            [Range(0, 1000)] int limit = 100,
            MichelineFormat micheline  = MichelineFormat.Json,
            Symbols quote       = Symbols.None,
            DateTimeOffset?from = null,
            DateTimeOffset?to   = null)
        {
            #region validate
            if (initiator != null)
            {
                if (initiator.Eqx != null)
                {
                    return(new BadRequest($"{nameof(initiator)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (initiator.Nex != null)
                {
                    return(new BadRequest($"{nameof(initiator)}.eqx", "This parameter doesn't support .eqx mode."));
                }
            }

            if (sender != null)
            {
                if (sender.Eqx != null)
                {
                    return(new BadRequest($"{nameof(sender)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (sender.Nex != null)
                {
                    return(new BadRequest($"{nameof(sender)}.eqx", "This parameter doesn't support .eqx mode."));
                }
            }

            if (target != null)
            {
                if (target.Eqx != null)
                {
                    return(new BadRequest($"{nameof(target)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (target.Nex != null)
                {
                    return(new BadRequest($"{nameof(target)}.eqx", "This parameter doesn't support .eqx mode."));
                }
            }

            if (prevDelegate != null)
            {
                if (prevDelegate.Eqx != null)
                {
                    return(new BadRequest($"{nameof(prevDelegate)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (prevDelegate.Nex != null)
                {
                    return(new BadRequest($"{nameof(prevDelegate)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (newDelegate != null)
            {
                if (newDelegate.Eqx != null)
                {
                    return(new BadRequest($"{nameof(newDelegate)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (newDelegate.Nex != null)
                {
                    return(new BadRequest($"{nameof(newDelegate)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (contractManager != null)
            {
                if (contractManager.Eqx != null)
                {
                    return(new BadRequest($"{nameof(contractManager)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (contractManager.Nex != null)
                {
                    return(new BadRequest($"{nameof(contractManager)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (contractDelegate != null)
            {
                if (contractDelegate.Eqx != null)
                {
                    return(new BadRequest($"{nameof(contractDelegate)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (contractDelegate.Nex != null)
                {
                    return(new BadRequest($"{nameof(contractDelegate)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (originatedContract != null)
            {
                if (originatedContract.Eqx != null)
                {
                    return(new BadRequest($"{nameof(originatedContract)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (originatedContract.Nex != null)
                {
                    return(new BadRequest($"{nameof(originatedContract)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (accuser != null)
            {
                if (accuser.Eqx != null)
                {
                    return(new BadRequest($"{nameof(accuser)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (accuser.Nex != null)
                {
                    return(new BadRequest($"{nameof(accuser)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (offender != null)
            {
                if (offender.Eqx != null)
                {
                    return(new BadRequest($"{nameof(offender)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (offender.Nex != null)
                {
                    return(new BadRequest($"{nameof(offender)}.nex", "This parameter doesn't support .nex mode."));
                }
            }

            if (baker != null)
            {
                if (baker.Eqx != null)
                {
                    return(new BadRequest($"{nameof(baker)}.eqx", "This parameter doesn't support .eqx mode."));
                }

                if (baker.Nex != null)
                {
                    return(new BadRequest($"{nameof(baker)}.nex", "This parameter doesn't support .nex mode."));
                }
            }
            #endregion

            var types = type != null ? new HashSet <string>(type.Split(',')) : OpTypes.DefaultSet;

            var _sort = sort == SortMode.Ascending
                ? new SortParameter {
                Asc = "Id"
            }
                : new SortParameter {
                Desc = "Id"
            };

            var _offset = lastId != null
                ? new OffsetParameter {
                Cr = lastId
            }
                : null;

            #region legacy
            if (timestamp == null && (from != null || to != null))
            {
                timestamp = new DateTimeParameter();
            }

            if (from != null)
            {
                timestamp.Ge = from.Value.DateTime;
            }
            if (to != null)
            {
                timestamp.Lt = to.Value.DateTime;
            }
            #endregion

            return(Ok(await Accounts.GetOperations(address, types, initiator, sender, target, prevDelegate, newDelegate, contractManager, contractDelegate, originatedContract, accuser, offender, baker, level, timestamp, entrypoint, parameter, parameters, hasInternals, status, _sort, _offset, limit, micheline, quote)));
        }