All files / src/clarity/types stringCV.ts

81.81% Statements 9/11
0% Branches 0/2
66.66% Functions 2/3
77.77% Lines 7/9

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 3121x                       21x 42x     21x 11x     21x                 21x  
import { ClarityType } from '../common/constants';
 
interface StringAsciiCV {
  readonly type: ClarityType.StringASCII;
  readonly data: string;
}
 
interface StringUtf8CV {
  readonly type: ClarityType.StringUTF8;
  readonly data: string;
}
 
const stringAsciiCV = (data: string): StringAsciiCV => {
  return { type: ClarityType.StringASCII, data };
};
 
const stringUtf8CV = (data: string): StringUtf8CV => {
  return { type: ClarityType.StringUTF8, data };
};
 
const stringCV = (data: string, encoding: 'ascii' | 'utf8'): StringAsciiCV | StringUtf8CV => {
  switch (encoding) {
    case 'ascii':
      return stringAsciiCV(data);
    case 'utf8':
      return stringAsciiCV(data);
  }
};
 
export { StringAsciiCV, StringUtf8CV, stringAsciiCV, stringUtf8CV, stringCV };