All files / src/clarity/types tupleCV.ts

85.71% Statements 6/7
0% Branches 0/1
100% Functions 1/1
85.71% Lines 6/7

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 2321x 21x                     35x 185x         35x     21x  
import { ClarityType } from '../common/constants';
import { isClarityName } from '../common/utils';
import { ClarityValue } from '../clarity-value/types';
 
type TupleData<T extends ClarityValue = ClarityValue> = { [key: string]: T };
 
interface TupleCV<T extends TupleData = TupleData> {
  type: ClarityType.Tuple;
  data: T;
}
 
function tupleCV<T extends ClarityValue = ClarityValue>(data: TupleData<T>): TupleCV<TupleData<T>> {
  for (const key in data) {
    Iif (!isClarityName(key)) {
      throw new Error(`"${key}" is not a valid Clarity name`);
    }
  }
 
  return { type: ClarityType.Tuple, data };
}
 
export { TupleCV, tupleCV };