fragment PendingWithdrawal on Withdrawal {
  pendingOnForeignChain @client
  txHash
}

fragment WithdrawalFields on Withdrawal {
  id
  status
  amount
  asset {
    id
    name
    symbol
    decimals
    status
    source {
      ... on ERC20 {
        contractAddress
      }
    }
  }
  createdTimestamp
  withdrawnTimestamp
  txHash
  details {
    ... on Erc20WithdrawalDetails {
      receiverAddress
    }
  }
  pendingOnForeignChain @client
}

query Withdrawals($partyId: ID!) {
  party(id: $partyId) {
    id
    withdrawalsConnection {
      edges {
        node {
          ...WithdrawalFields
        }
      }
    }
  }
}

subscription WithdrawalEvent($partyId: ID!) {
  busEvents(partyId: $partyId, batchSize: 0, types: [Withdrawal]) {
    event {
      ... on Withdrawal {
        ...WithdrawalFields
      }
    }
  }
}
