<commit_before>import { BaseCoin as CoinConfig } from '@bitgo/statics';
import { Eth } from '../../index';
import { TxData } from '../eth/iface';

export class Transaction extends Eth.Transaction {
  constructor(_coinConfig: Readonly<CoinConfig>, txData?: TxData) {
    super(_coinConfig, txData);
  }
}<commit_msg>celo transactions sign and broadcast<commit_after>import { BaseCoin as CoinConfig } from '@bitgo/statics';
import { Eth } from '../../index';
import { InvalidTransactionError } from '../baseCoin/errors';
import { KeyPair, Utils } from './';

export class Transaction extends Eth.Transaction {
  private _encodedTransaction?: string;

  constructor(_coinConfig: Readonly<CoinConfig>) {
    super(_coinConfig);
  }

  /**
   * Sign the transaction with the provided key. It does not check if the signer is allowed to sign
   * it or not.
   *
   * @param {KeyPair} keyPair The key to sign the transaction with
   */
  async sign(keyPair: KeyPair): Promise<void> {
    // Check if there is a transaction to sign
    if (!this._ethTransaction) {
      throw new InvalidTransactionError('Empty transaction');
    }
    this._encodedTransaction = await Utils.sign(this._ethTransaction.toJson(), keyPair);
  }

  /** @inheritdoc */
  toBroadcastFormat(): any {
    if (!this._encodedTransaction) {
      return super.toBroadcastFormat();
    }
    return this._encodedTransaction;
  }
}
{'fraction_non_alphanumeric': 0.12195121951219512, 'fraction_numerical': 0.0, 'mean_word_length': 3.7773972602739727, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '2985883', 'n_tokens_mistral': 397, 'n_tokens_neox': 393, 'n_words': 120}