import gql from 'graphql-tag' ; export const GET_DISPUTABLE_VOTING = ( type ) => gql `
  ${ type } DisputableVoting($disputableVoting: String!) {
    disputableVoting(id: $disputableVoting) {
      id
      dao
      agreement
      token {
        id      
      }
      setting {
        id
      }
      collateralRequirement {
        id
      }
    }
  }
` ; export const GET_CURRENT_SETTING = ( type ) => gql `
  ${ type } DisputableVoting($disputableVoting: String!) {
    disputableVoting(id: $disputableVoting) {
      setting {
        id
        settingId
        voteTime
        supportRequiredPct
        minimumAcceptanceQuorumPct
        delegatedVotingPeriod
        quietEndingPeriod
        quietEndingExtension
        executionDelay
        createdAt
        voting {
          id
        }
      }
    }
  }
` ; export const GET_CURRENT_COLLATERAL_REQUIREMENT = ( type ) => gql `
  ${ type } DisputableVoting($disputableVoting: String!) {
    disputableVoting(id: $disputableVoting) {
      collateralRequirement {
        id
        voting {
          id
        }
        token {
          id
          symbol
          decimals
        }
        actionAmount
        challengeAmount
        challengeDuration
        collateralRequirementId
      }
    }
  }
` ; export const GET_SETTING = ( type ) => gql `
  ${ type } Setting($settingId: String!) {
    setting(id: $settingId) {
      id
      settingId
      voteTime
      supportRequiredPct
      minimumAcceptanceQuorumPct
      delegatedVotingPeriod
      quietEndingPeriod
      quietEndingExtension
      executionDelay
      createdAt
      voting {
        id
      }
    }
  }
` ; export const ALL_SETTINGS = ( type ) => gql `
  ${ type } Settings($disputableVoting: String!, $first: Int!, $skip: Int!) {
    settings(where: {
      voting: $disputableVoting
    }, first: $first, skip: $skip) {
      id
      settingId
      voteTime
      supportRequiredPct
      minimumAcceptanceQuorumPct
      delegatedVotingPeriod
      quietEndingPeriod
      quietEndingExtension
      executionDelay
      createdAt
      voting {
        id
      }
    }
  }
` ; export const GET_VOTE = ( type ) => gql `
  ${ type } Vote($voteId: String!) {
    vote(id: $voteId) {
      id
      voting { 
        id 
        token {
          id
          symbol  
          decimals
        }
      }
      voteId
      creator
      originalCreator
      context
      status
      actionId
      challengeId
      challenger
      challengeEndDate
      disputeId
      setting { 
        id 
        voteTime
        quietEndingExtension
      }
      startDate
      totalPower
      snapshotBlock
      yeas
      nays
      pausedAt
      pauseDuration
      quietEndingExtensionDuration
      quietEndingSnapshotSupport
      script
      settledAt
      disputedAt
      executedAt
      isAccepted
      settlementOffer
      collateralRequirement {
        id
        token {
          id
          symbol
          decimals
        }
      }
      submitterArbitratorFee {
        id
      }
      challengerArbitratorFee {
        id
      }
    }
  }
` ; export const ALL_VOTES = ( type ) => gql `
  ${ type } Votes($disputableVoting: String!, $first: Int!, $skip: Int!) {
    votes(where: {
      voting: $disputableVoting
    }, orderBy: startDate, orderDirection: asc, first: $first, skip: $skip) {
      id
      voting { 
        id 
        token {
          id
          symbol
          decimals
        }
      }
      voteId
      creator
      originalCreator
      context
      status
      actionId
      challengeId
      challenger
      challengeEndDate
      disputeId
      setting { 
        id 
        voteTime
        quietEndingExtension
      }
      startDate
      totalPower
      snapshotBlock
      yeas
      nays
      pausedAt
      pauseDuration
      quietEndingExtensionDuration
      quietEndingSnapshotSupport
      script
      settledAt
      disputedAt
      executedAt
      isAccepted
      settlementOffer
      collateralRequirement {
        id
        token {
          id
          symbol
          decimals
        }
      }
      submitterArbitratorFee {
        id
      }
      challengerArbitratorFee {
        id  
      }
    }
  }
` ; export const GET_CAST_VOTE = ( type ) => gql `
  ${ type } CastVote($castVoteId: String!) {
    castVote(id: $castVoteId) {
      id
      vote { 
        id 
      }
      voter { 
        id
      }
      caster
      supports
      stake
      createdAt
    }
  }
` ; export const ALL_CAST_VOTES = ( type ) => gql `
  ${ type } CastVotes($voteId: ID!, $first: Int!, $skip: Int!) {
    castVotes(where: {
      vote: $voteId
    }, first: $first, skip: $skip) {
      id
      vote { 
        id 
      }
      voter { 
        id 
      }
      caster
      supports
      stake
      createdAt
    }
  }
` ; export const GET_VOTER = ( type ) => gql `
  ${ type } Voter($voterId: String!) {
    voter(id: $voterId) {
      id
      address
      representative
      voting { 
        id
      }
    }
  }
` ; export const GET_COLLATERAL_REQUIREMENT = ( type ) => gql `
  ${ type } CollateralRequirement($collateralRequirementId: String!) {
    collateralRequirement(id: $collateralRequirementId) {
      id
      voting {
        id
      }
      token {
        id
        symbol
        decimals
      }
      actionAmount
      challengeAmount
      challengeDuration
      collateralRequirementId
    }
  }
` ; export const GET_ARBITRATOR_FEE = ( type ) => gql `
  ${ type } ArbitratorFee($arbitratorFeeId: String!) {
    arbitratorFee(id: $arbitratorFeeId) {
      id
      amount
      vote {
        id
      }
      token {
        id
        symbol
        decimals
      }
    }
  }
` ; export const GET_ERC20 = ( type ) => gql `
  ${ type } ERC20($tokenAddress: String!) {
    erc20(id: $tokenAddress) {
      id
      name
      symbol
      decimals
    }
  }
` ;