export const latestBlockQuery = `query getLatestBlocks($limit: Int!, $timeRange:[Int],$offset: Int!){
  paginatedBlock(sortBy:{_id:desc},filter:{timestamp:{range:$timeRange}},limit:$limit,offset:$offset){
    totalRecords
    blocks{
      _id
      hash
      proposer
      txn_count
      timestamp
    }
  }
}
`;
export const latestBlockQueryWithSignatures = `query getLatestBlocks($limit: Int!, $timeRange:[Int],$offset: Int!){
  paginatedBlock(sortBy:{_id:desc},filter:{timestamp:{range:$timeRange}},limit:$limit,offset:$offset){
    totalRecords
    blocks{
      _id
      hash
      proposer
      txn_count
      timestamp
      signatures{
      validatorAddress
      timestamp
    }
    }
  }
}
`;

export const specificBlockQuery = `
  query getBlockByHeight($height: Int!){
  block(_id:$height){
    _id
    hash
    proposer
    txn_count
    timestamp
    signatures{
      validatorAddress
      timestamp
    }
    transactions{
         _id
        height
        sender
        status
        receiver
        timestamp
        gasWanted
        gasUsed
        fee
        event_logs
        success
        rawLog
        routePrice
    }
  }
}
`;
export const latestTransactionsQuery = `
  query getLatestTransactions($timeRange:[Int], $limit: Int!, $offset: Int!){
    paginatedTransaction(filter:{timestamp:{range:$timeRange}},sortBy:{height:desc},limit:$limit,offset:$offset){
    totalRecords
  transactions{
     _id
    height
    sender
    status
    receiver
    timestamp
    gasWanted
    gasUsed
    fee
    event_logs
    success
    rawLog
    routePrice
  }
  }
}
`;

export const latestTransactionsOfAddressQuery = `
  query getLatestTransactions($timeRange:[Int], $address: String!,$limit: Int!, $offset: Int!){
   paginatedTransaction(filter:{timestamp:{range:$timeRange}}, where_or:{sender:$address, receiver:$address}, limit:$limit, offset:$offset){
    totalRecords
    transactions{
      _id
      height
      sender
      status
      receiver
      timestamp
      gasWanted
      gasUsed
      fee
      event_logs
      success
      rawLog
      routePrice
    }
  }
}
`;

export const specificTransactionQuery = `
  query getTransactionByHash($hash: String!){
  transaction(_id:$hash){
    _id
    height
    sender
    status
    receiver
    timestamp
    gasWanted
    gasUsed
    fee
    event_logs
    success
    rawLog
    routePrice
  }
}
`;

export const latestCrosschainsQuery = `
  query getLatestCrosschains($timeRange:[Int], $limit: Int!, $offset: Int!){
    paginatedCrosschain(filter:{createdAt:{range:$timeRange}}, sortBy:{createdAt:desc}, limit:$limit, offset:$offset){
    totalRecords
    crosschains{
      id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
    }
    }
}
`;

export const specificCrosschainQuery = `
  query getCrosschainByFormAttestationId($formAttestationId: String!){
  crosschain(id:$formAttestationId){
    id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
  }
}
`;
export const searchSpecificCrosschainQuery = `
  query getCrosschainByFormAttestationId($timeRange:[Int], $searchTerm: String! , $handlerAddress: String!, $limit: Int!, $offset: Int!){
  paginatedCrosschain(filter:{createdAt:{range:$timeRange}},where_or:{sourceTxHash:$searchTerm, srcTxOrigin:$searchTerm, requestSender:$searchTerm},handlerAddress:$handlerAddress,sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    crosschains{
      id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
    }
    }
}
`;

export const searchSpecificCrosschainSrcChainIdQuery = `
  query getCrosschainByFormAttestationId($timeRange:[Int],$sourceChainIds: [String],$handlerAddress: String!,$searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedCrosschain(filter:{srcChainId:{in:$sourceChainIds}, createdAt:{range:$timeRange}},where_or:{sourceTxHash:$searchTerm, srcTxOrigin:$searchTerm, requestSender:$searchTerm},handlerAddress:$handlerAddress,sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    crosschains{
      id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
    }
    }
}
`;

export const searchSpecificCrosschainDestChainIdQuery = `
  query getCrosschainByFormAttestationId($timeRange:[Int],$destinationChainIds: [String],$searchTerm: String! , $handlerAddress: String!,$limit: Int!, $offset: Int!){
  paginatedCrosschain(filter:{destChainId:{in:$destinationChainIds},createdAt:{range:$timeRange}},where_or:{sourceTxHash:$searchTerm, srcTxOrigin:$searchTerm, requestSender:$searchTerm},handlerAddress:$handlerAddress,sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    crosschains{
     id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
    }
    }
}
`;

export const searchSpecificCrosschainChainIdQuery = `
  query getCrosschainByFormAttestationId($timeRange:[Int], $sourceChainIds: [String],$destinationChainIds: [String],$searchTerm: String! , $handlerAddress: String!,$limit: Int!, $offset: Int!){
  paginatedCrosschain(filter:{srcChainId:{in:$sourceChainIds},destChainId:{in:$destinationChainIds}, createdAt:{range:$timeRange}},where_or:{sourceTxHash:$searchTerm, srcTxOrigin:$searchTerm, requestSender:$searchTerm},handlerAddress:$handlerAddress,sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    crosschains{
      id
      attestationId
      srcChainId
      requestIdentifier
      blockHeight
      sourceTxHash
      srcTimestamp
      srcTxOrigin
      routeAmount
      routeRecipient
      destChainId
      requestSender
      requestMetadata{
        destGasLimit
        destGasPrice
        ackGasLimit
        ackGasPrice
        ackType
        isReadCall
        asmAddress
      }
      requestPacket{
        handler
        payload
      }
      srcChainType
      destChainType
      status
      eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      ackRequest{
        eventAckRequestCreated{
          attestationId
          ackSrcChainId
          ackRequestIdentifier
          blockHeight
          destTxHash
          relayerRouterAddress
          ackDestChainId
          requestSender
          requestIdentifier
          ackSrcChainType
          ackDestChainType
          execData
          execStatus
          status
        }
        eventAckRequestConfirm{
          ackSrcChainId
          ackRequestIdentifier
          claimHash
          ethSigner
          signature
          orchestrator
        }
        status
        eventHistory{
          name
          height
          timestamp
          txnHash
          height
        }
        historyStatus{
          status
          txnHash
          timestamp
        }
        claimHash
        txFeeInRoute
        chainType
        chainId
        requestIdentifier
        customFormAttestationId
        ackReceiptRequest{
          ackReceipt{
            attestationId
            ackReceiptSrcChainId
            ackReceiptIdentifier
            ackReceiptBlockHeight
            ackReceiptTxHash
            relayerRouterAddress
            requestIdentifier
            status
          }
          historyStatus{
            status
            txnHash
            timestamp
          }
          relayerFeeInRoute
          refundFeeInRoute
          ackReceiptKey
          status
          claimHash
        }
        ackGasLimit
        ackGasPrice
        feePayer
        relayerFeeInRoute
        relayerIncentiveInRoute
        refundFeeInRoute
        errorResponse
        eventSignatures{
          chainType
          chainId
          eventNonce
          voter
          blockHeight
          timestamp
        }
      }
      customFormAttestationId
      destinationTxHash
      eventAckConfirmSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      createdAt
      updatedAt
      destTxFeeInRoute
      relayerFee
			relayerFeeInRoute
      relayerIncentiveInRoute
      refundFeeInRoute
      feePayer
      errorResponse
      relayerAddress
      execStatus
      execData
      eventSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
    }
    }
}
`;

export const inboundOutboundQuery = `
query findOutboundsToInbound($middlewareContract:String!,$inboundId:String!){
  outboundToInboundMap(where:{middlewareContract:$middlewareContract, inboundId:$inboundId}){
    inboundId
    outboundId
    inboundNonce
    outboundChainId
    outboundNonce
    middlewareContract
    blockHeight
    timestamp
  }
}
`;

export const latestFundPaidQuery = `
  query getLatestFundPaid($timeRange:[Int], $limit: Int!, $offset: Int!){
    paginatedFundPaid(filter:{createdAt:{range:$timeRange}}, sortBy:{createdAt:desc}, limit:$limit, offset:$offset){
    totalRecords
    fundPaid{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      eventNonce
      blockHeight
      messageHash
      forwarder
      forwarderRouterAddr
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const specificFundPaidQuery = `
  query getFundPaidById($id:String!){
  fundPaid(id:$id){
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      eventNonce
      blockHeight
      messageHash
      forwarder
      forwarderRouterAddr
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
       chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
}
`;
export const searchSpecificFundPaidQuery = `
  query getFundPaidBySearch($timeRange:[Int], $searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundPaid(filter:{createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, messageHash:$searchTerm, forwarder:$searchTerm, forwarderRouterAddr:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundPaid{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      eventNonce
      blockHeight
      messageHash
      forwarder
      forwarderRouterAddr
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
`;

export const searchSpecificFundPaidSrcChainIdQuery = `
  query getCrosschainBySearch($timeRange:[Int],$sourceChainIds: [String],$searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundPaid(filter:{srcChainId:{in:$sourceChainIds}, createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, messageHash:$searchTerm, forwarder:$searchTerm, forwarderRouterAddr:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundPaid{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      eventNonce
      blockHeight
      messageHash
      forwarder
      forwarderRouterAddr
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const latestFundDepositQuery = `
  query getLatestFundDeposit($timeRange:[Int], $limit: Int!, $offset: Int!){
    paginatedFundDeposit(filter:{createdAt:{range:$timeRange}}, sortBy:{createdAt:desc}, limit:$limit, offset:$offset){
    totalRecords
    fundDeposit{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const specificFundDepositQuery = `
  query getFundDepositById($id:String!){
  fundDeposit(id:$id){
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
}
`;
export const searchSpecificFundDepositQuery = `
  query getFundPaidBySearch($timeRange:[Int], $searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundDeposit(filter:{createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, srcToken:$searchTerm, recipient:$searchTerm, depositor:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundDeposit{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const searchSpecificFundDepositSrcChainIdQuery = `
  query getCrosschainBySearch($timeRange:[Int],$sourceChainIds: [String],$searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundDeposit(filter:{srcChainId:{in:$sourceChainIds}, createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, srcToken:$searchTerm, recipient:$searchTerm, depositor:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundDeposit{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const searchSpecificFundDepositDestChainIdQuery = `
 query getCrosschainBySearch($timeRange:[Int],$destinationChainIds: [String],$searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundDeposit(filter:{destChainId:{in:$destinationChainIds}, createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, srcToken:$searchTerm, recipient:$searchTerm, depositor:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundDeposit{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const searchSpecificFundDepositChainIdQuery = `
 query getCrosschainBySearch($timeRange:[Int],$sourceChainIds:[String],$destinationChainIds: [String],$searchTerm: String! ,$limit: Int!, $offset: Int!){
  paginatedFundDeposit(filter:{srcChainId:{in:$sourceChainIds}, destChainId:{in:$destinationChainIds}, createdAt:{range:$timeRange}},where_or:{srcTxHash:$searchTerm, contract:$searchTerm, srcToken:$searchTerm, recipient:$searchTerm, depositor:$searchTerm},sortBy:{createdAt:desc},limit:$limit,offset:$offset){
    totalRecords
    fundDeposit{
      id
			srcChainId
      srcChainType
      srcTxHash
      srcTimestamp
      contract
      depositId
      blockHeight
      destChainId
      amount
      relayerFees
			srcToken
			recipient
			depositor
      execResponse
      errorResponse
       eventHistory{
        name
        height
        timestamp
        txnHash
        height
      }
      historyStatus{
        status
        txnHash
        timestamp
      }
      eventSignatures{
        validator
        txnHash
        timestamp
        blockHeight
        signature
        ethSigner
      }
      eventConfirmSignatures{
        chainType
        chainId
        eventNonce
        voter
        blockHeight
        timestamp
      }
      status
      createdAt
      updatedAt
    }
  }
}
`;

export const validatorsUptimeQuery = `
query getValidatorsUptime{
  validators{
    operatorAddress
    consensusAddress
    upTime
  }
}
`;

//const x = gql(latestBlockQuery) for apollo client DocumentNode
