All files / src/trxTypes Vote.ts

100% Statements 10/10
100% Branches 6/6
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x                           1x 304x 304x     304x     1x 602x   1x  
import { BaseTx } from './BaseTx';
 
export interface IVoteAsset {
  /**
   * string array in the following format:
   *  ['-publicKey1', '+publicKey2']
   *  to remove publicKey1 and add publicKey2 among voted delegates
   */
  votes: string[];
}
 
/**
 * Vote transactions
 */
export class VoteTx extends BaseTx<IVoteAsset> {
  public type: number = 3;
  public amount       = 0;
 
  constructor(asset?: IVoteAsset) {
    super(asset);
  }
 
  protected getChildBytes(skipSignature: boolean, skipSecondSign: boolean) {
    return this.asset && this.asset.votes ? Buffer.from(this.asset.votes.join(''), 'utf8') : null;
  }
}