<commit_before>import Web3 from 'web3'
import { Contract } from '../../node_modules/web3/types.d'

export async function commitVote(
  web3:Web3,
  voting:Contract,
  pollID:string,
  voter:string,
  vote:string|number|boolean = 1,
  tokens:string|number = 10,
  salt:string|number = 420,
): Promise<any> {
  const hash = getVoteSaltHash(web3, vote, salt)

  await voting.methods.requestVotingRights(tokens).send({ from: voter })

  const prevPollID = await voting.methods.getInsertPointForNumTokens(voter, tokens, pollID).call(),
    tx = await voting.methods.commitVote(pollID, hash, tokens, prevPollID).send({ from: voter })

  return tx
}

function getVoteSaltHash(web3:Web3, vote:string|number|boolean, salt:string|number): string {
  //`0x${abi.soliditySHA3(['uint', 'uint'], [vote, salt]).toString('hex')}`
  return web3.utils.soliditySha3({ t: 'uint', v: vote }, { t: 'uint', v: salt })
}
<commit_msg>remove old comments<commit_after>import Web3 from 'web3'
import { Contract } from '../../node_modules/web3/types.d'

export async function commitVote(
  web3:Web3,
  voting:Contract,
  pollID:string,
  voter:string,
  vote:string|number|boolean = 1,
  tokens:string|number = 10,
  salt:string|number = 420,
): Promise<any> {
  const hash = getVoteSaltHash(web3, vote, salt)

  await voting.methods.requestVotingRights(tokens).send({ from: voter })

  const prevPollID = await voting.methods.getInsertPointForNumTokens(voter, tokens, pollID).call(),
    tx = await voting.methods.commitVote(pollID, hash, tokens, prevPollID).send({ from: voter })

  return tx
}

function getVoteSaltHash(web3:Web3, vote:string|number|boolean, salt:string|number): string {
  return web3.utils.soliditySha3({ t: 'uint', v: vote }, { t: 'uint', v: salt })
}

{'fraction_non_alphanumeric': 0.14988558352402745, 'fraction_numerical': 0.019450800915331808, 'mean_word_length': 5.224199288256227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2722008', 'n_tokens_mistral': 624, 'n_tokens_neox': 606, 'n_words': 132}