All files / src privatemetadata.ts

100% Statements 12/12
83.33% Branches 5/6
100% Functions 2/2
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 27 28 29 30 31 32 33 34 35 36 37 3827x   27x                             191x 191x 191x 191x     190x   190x 88x   190x 190x                
export { PrivateMetadata };
import { Field } from "o1js";
import { MinaNFT } from "./minanft";
import { BaseMinaNFTObject } from "./baseminanftobject";
 
class PrivateMetadata {
  data: Field;
  kind: Field;
  isPrivate: boolean;
  linkedObject?: BaseMinaNFTObject;
 
  constructor(value: {
    data: Field;
    kind: Field;
    isPrivate?: boolean;
    linkedObject?: BaseMinaNFTObject;
  }) {
    this.data = value.data;
    this.kind = value.kind;
    this.isPrivate = value.isPrivate ?? false;
    this.linkedObject = value.linkedObject;
  }
  public toJSON(): object {
    const kind = MinaNFT.stringFromField(this.kind);
    let data: string;
    if (kind === "string") data = MinaNFT.stringFromField(this.data);
    else data = this.data.toJSON();
    const isPrivate: boolean | undefined =
      this.isPrivate === true ? true : undefined;
    return {
      data,
      kind,
      isPrivate,
      linkedObject: this.linkedObject?.toJSON(),
    };
  }
}