fragment RewardFields on Reward {
  rewardType
  asset {
    id
    symbol
    name
    decimals
  }
  party {
    id
  }
  epoch {
    id
  }
  amount
  percentageOfTotal
  receivedAt
}

fragment DelegationFields on Delegation {
  amount
  epoch
}

fragment EpochRewardSummaryFields on EpochRewardSummary {
  epoch
  assetId
  amount
  rewardType
}

query Rewards(
  $partyId: ID!
  $fromEpoch: Int
  $toEpoch: Int
  $rewardsPagination: Pagination
  $delegationsPagination: Pagination
) {
  party(id: $partyId) {
    id
    rewardsConnection(
      fromEpoch: $fromEpoch
      toEpoch: $toEpoch
      pagination: $rewardsPagination
    ) {
      edges {
        node {
          ...RewardFields
        }
      }
    }
    delegationsConnection(pagination: $delegationsPagination) {
      edges {
        node {
          ...DelegationFields
        }
      }
    }
  }
  epochRewardSummaries(
    filter: { fromEpoch: $fromEpoch, toEpoch: $toEpoch }
    pagination: $rewardsPagination
  ) {
    edges {
      node {
        ...EpochRewardSummaryFields
      }
    }
  }
}

query EpochAssetsRewards(
  $epochRewardSummariesFilter: RewardSummaryFilter
  $epochRewardSummariesPagination: Pagination
) {
  assetsConnection {
    edges {
      node {
        id
        name
        decimals
      }
    }
  }
  epochRewardSummaries(
    filter: $epochRewardSummariesFilter
    pagination: $epochRewardSummariesPagination
  ) {
    edges {
      node {
        ...EpochRewardSummaryFields
      }
    }
  }
}

fragment EpochFields on Epoch {
  id
  timestamps {
    start
    end
    expiry
  }
}

query Epoch {
  epoch {
    ...EpochFields
  }
}
