getTransactionType function

String getTransactionType(
  1. Map transaction
)

Gets the transaction type depending on the information in the transaction object If an account index is used, it will be 'Transfer' If a Hermez address is used, it will be 'TransferToEthAddr' If a BabyJubJub is used, it will be 'TransferToBjj'

@param {Object} transaction - Transaction object sent to generateL2Transaction

@return {String} transactionType

Implementation

String getTransactionType(Map transaction) {
  if (transaction["to"] != null) {
    if (isHermezAccountIndex(transaction['to'])) {
      return 'Transfer';
    } else if (isHermezEthereumAddress(transaction['to'])) {
      return 'TransferToEthAddr';
    } else if (isHermezBjjAddress(transaction['to'])) {
      return 'TransferToBJJ';
    } else {
      return 'Transfer';
    }
  } else {
    return 'Exit';
  }
}