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

fragment DelegationFields on Delegation {
  amount
  epoch
}

query Rewards($partyId: ID!, $delegationsPagination: Pagination) {
  party(id: $partyId) {
    id
    rewardsConnection {
      edges {
        node {
          ...RewardFields
        }
      }
    }
    delegationsConnection(pagination: $delegationsPagination) {
      edges {
        node {
          ...DelegationFields
        }
      }
    }
  }
  epoch {
    id
    timestamps {
      start
      end
      expiry
    }
  }
}

fragment EpochRewardSummaryFields on EpochRewardSummary {
  epoch
  assetId
  amount
  rewardType
}

query EpochAssetsRewards($epochRewardSummariesPagination: Pagination) {
  assetsConnection {
    edges {
      node {
        id
        name
      }
    }
  }
  epochRewardSummaries(pagination: $epochRewardSummariesPagination) {
    edges {
      node {
        ...EpochRewardSummaryFields
      }
    }
  }
  epoch {
    timestamps {
      expiry
    }
  }
}

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

query Epoch {
  epoch {
    ...EpochFields
  }
}
