assertIsDecimalFixedPoint

function assertIsDecimalFixedPoint<TSignedness, TTotalBits, TDecimals>(
    value,
    signedness?,
    totalBits?,
    decimals?,
): asserts value is DecimalFixedPoint<
    TSignedness,
    TTotalBits,
    TDecimals
>;

Asserts that value is a DecimalFixedPoint.

Every shape parameter is independently optional. Pass undefined (or simply omit trailing arguments) to leave a given field unconstrained.

Throws SOLANA_ERROR__FIXED_POINTS__SHAPE_MISMATCH if the value does not match the expected shape, or SOLANA_ERROR__FIXED_POINTS__VALUE_OUT_OF_RANGE if the raw bigint does not fit the claimed signedness and total bits.

Type Parameters

Type ParameterDefault type
TSignedness extends SignednessSignedness
TTotalBits extends numbernumber
TDecimals extends numbernumber

Parameters

ParameterType
valueunknown
signedness?TSignedness
totalBits?TTotalBits
decimals?TDecimals

Returns

asserts value is DecimalFixedPoint<TSignedness, TTotalBits, TDecimals>

Example

assertIsDecimalFixedPoint(value);                   // any decimal fixed-point
assertIsDecimalFixedPoint(value, 'unsigned');        // any unsigned decimal
assertIsDecimalFixedPoint(value, 'unsigned', 64, 6); // fully pinned
assertIsDecimalFixedPoint(value, undefined, 64);     // any decimal with totalBits=64

See

On this page