import { cloneDeep } from "lodash";
import { pond } from "protobuf-ts/pond";
import { or } from "utils/types";

export class Transaction {
  public transaction: pond.Transaction = pond.Transaction.create();

  public static create(pb?: pond.Transaction): Transaction {
    let my = new Transaction();
    if (pb) {
      my.transaction = pond.Transaction.fromObject(cloneDeep(or(pb, {})));
    }
    return my;
  }

  public static any(data: any): Transaction {
    return Transaction.create(pond.Transaction.fromObject(cloneDeep(data)));
  }
}