getNonNullResolvedInstructionInput

function getNonNullResolvedInstructionInput<T>(inputName, value): T;

Ensures a resolved instruction input is not null or undefined.

This function is used during instruction resolution to validate that required inputs have been properly resolved to a non-null value.

Type Parameters

Type ParameterDescription
TThe expected type of the resolved input value.

Parameters

ParameterTypeDescription
inputNamestringThe name of the instruction input, used in error messages.
valueT | null | undefinedThe resolved value to validate.

Returns

T

The validated non-null value.

Throws

Throws a SolanaError if the value is null or undefined.

Example

const resolvedAuthority = getNonNullResolvedInstructionInput(
  'authority',
  maybeAuthority
);
// resolvedAuthority is guaranteed to be non-null here.

On this page