All files / src/clarity/types responseCV.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

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 2521x                               8x       11x     21x  
import { ClarityType } from '../common/constants';
import { ClarityValue } from '../clarity-value/types';
 
type ResponseCV = ResponseErrorCV | ResponseOkCV;
 
interface ResponseErrorCV<T extends ClarityValue = ClarityValue> {
  readonly type: ClarityType.ResponseErr;
  readonly value: T;
}
 
interface ResponseOkCV<T extends ClarityValue = ClarityValue> {
  readonly type: ClarityType.ResponseOk;
  readonly value: T;
}
 
function responseErrorCV<T extends ClarityValue = ClarityValue>(value: T): ResponseErrorCV<T> {
  return { type: ClarityType.ResponseErr, value };
}
 
function responseOkCV<T extends ClarityValue = ClarityValue>(value: T): ResponseOkCV<T> {
  return { type: ClarityType.ResponseOk, value };
}
 
export { ResponseCV, ResponseErrorCV, ResponseOkCV, responseErrorCV, responseOkCV };