Skip to content

Commit

Permalink
fix: a few Clarity value construction functions were not being exported
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x authored and janniks committed Jan 31, 2023
1 parent 7c9b0b4 commit f0ba4a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
11 changes: 8 additions & 3 deletions packages/transactions/src/clarity/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ClarityValue, getCVTypeString, cvToString, cvToJSON, cvToValue } from './clarityValue';
import { ClarityType } from './constants';
import { BooleanCV, TrueCV, FalseCV, trueCV, falseCV } from './types/booleanCV';
import { BooleanCV, TrueCV, FalseCV, trueCV, falseCV, boolCV } from './types/booleanCV';
import { IntCV, UIntCV, intCV, uintCV } from './types/intCV';
import { BufferCV, bufferCV, bufferCVFromString } from './types/bufferCV';
import { OptionalCV, NoneCV, SomeCV, noneCV, someCV } from './types/optionalCV';
import { OptionalCV, NoneCV, SomeCV, noneCV, someCV, optionalCVOf } from './types/optionalCV';

import {
ResponseCV,
Expand All @@ -22,11 +22,12 @@ import {
contractPrincipalCVFromAddress,
PrincipalCV,
contractPrincipalCVFromStandard,
principalCV,
} from './types/principalCV';

import { ListCV, listCV } from './types/listCV';
import { TupleCV, tupleCV } from './types/tupleCV';
import { StringAsciiCV, StringUtf8CV, stringUtf8CV, stringAsciiCV } from './types/stringCV';
import { StringAsciiCV, StringUtf8CV, stringUtf8CV, stringAsciiCV, stringCV } from './types/stringCV';
import { serializeCV } from './serialize';
import deserializeCV from './deserialize';

Expand Down Expand Up @@ -57,6 +58,7 @@ export {

// Value construction functions
export {
boolCV,
trueCV,
falseCV,
intCV,
Expand All @@ -65,15 +67,18 @@ export {
bufferCVFromString,
noneCV,
someCV,
optionalCVOf,
responseOkCV,
responseErrorCV,
principalCV,
standardPrincipalCV,
standardPrincipalCVFromAddress,
contractPrincipalCV,
contractPrincipalCVFromAddress,
contractPrincipalCVFromStandard,
listCV,
tupleCV,
stringCV,
stringAsciiCV,
stringUtf8CV,
getCVTypeString,
Expand Down
20 changes: 19 additions & 1 deletion packages/transactions/src/clarity/types/booleanCV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ const trueCV = (): BooleanCV => ({ type: ClarityType.BoolTrue });
*/
const falseCV = (): BooleanCV => ({ type: ClarityType.BoolFalse });

export { BooleanCV, TrueCV, FalseCV, trueCV, falseCV };
/**
* Converts a boolean to BooleanCV clarity type
*
* @returns {BooleanCV} returns instance of type BooleanCV
*
* @example
* ```
* import { boolCV } from '@stacks/transactions';
*
* const boolCV = boolCV(false);
* // { type: 4 }
* ```
*
* @visit
* {@link https://github.com/hirosystems/stacks.js/blob/master/packages/transactions/tests/clarity.test.ts clarity test cases for more examples}
*/
const boolCV = (bool: boolean) => (bool ? trueCV() : falseCV());

export { BooleanCV, TrueCV, FalseCV, boolCV, trueCV, falseCV };

0 comments on commit f0ba4a2

Please sign in to comment.