@codama/renderers-js
Version:
JavaScript renderer compatible with the Solana Kit library
44 lines • 2.6 kB
TypeScript
import { ConstantDiscriminatorNode, DiscriminatorNode, FieldDiscriminatorNode, InstructionArgumentNode, StructFieldTypeNode } from '@codama/nodes';
import { Fragment, NameApi, RenderScope } from '../utils';
export declare function getDiscriminatorConstantsFragment(scope: Pick<RenderScope, 'nameApi' | 'typeManifestVisitor'> & {
discriminatorNodes: DiscriminatorNode[];
fields: InstructionArgumentNode[] | StructFieldTypeNode[];
prefix: string;
}): Fragment;
export declare function getDiscriminatorConstantFragment(discriminatorNode: DiscriminatorNode, scope: Pick<RenderScope, 'nameApi' | 'typeManifestVisitor'> & {
discriminatorNodes: DiscriminatorNode[];
fields: InstructionArgumentNode[] | StructFieldTypeNode[];
prefix: string;
}): Fragment | null;
/**
* Derives the camel-case name of the constant rendered for a constant discriminator.
*
* The first constant discriminator of a node gets no index suffix, whilst subsequent
* ones are numbered from 2 — e.g. `myEventDiscriminator` and `myEventDiscriminator2`,
* since the whole name goes through `camelCase`.
*
* @param prefix - The camel-case name of the node owning the discriminator.
* @param index - The position of the discriminator amongst the node's constant discriminators.
* @returns The camel-case constant name, before any {@link NameApi.constant} transformation.
*/
export declare function getConstantDiscriminatorName(prefix: string, index: number): string;
/**
* Derives the camel-case prefix used for an event's discriminator constants.
*
* Both the constant declarations on the event page and the codecs referencing
* them derive the prefix through this helper so the two can never drift apart.
*
* @param nameApi - The naming API of the current render scope.
* @param eventName - The name of the event node.
* @returns The camel-case prefix to combine with {@link getConstantDiscriminatorName}.
*/
export declare function getEventDiscriminatorPrefix(nameApi: NameApi, eventName: string): string;
export declare function getConstantDiscriminatorConstantFragment(discriminatorNode: ConstantDiscriminatorNode, scope: Pick<RenderScope, 'nameApi' | 'typeManifestVisitor'> & {
discriminatorNodes: DiscriminatorNode[];
prefix: string;
}): Fragment | null;
export declare function getFieldDiscriminatorConstantFragment(discriminatorNode: FieldDiscriminatorNode, scope: Pick<RenderScope, 'nameApi' | 'typeManifestVisitor'> & {
fields: InstructionArgumentNode[] | StructFieldTypeNode[];
prefix: string;
}): Fragment | null;
//# sourceMappingURL=discriminatorConstants.d.ts.map