Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/errors/src/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
export const CODAMA_ERROR__UNRECOGNIZED_NODE_KIND = 1;
export const CODAMA_ERROR__UNEXPECTED_NODE_KIND = 2;
/** @deprecated No longer thrown as of Codama v2, which removed nested type node wrappers. */
export const CODAMA_ERROR__UNEXPECTED_NESTED_NODE_KIND = 3;
export const CODAMA_ERROR__LINKED_NODE_NOT_FOUND = 4;
export const CODAMA_ERROR__NODE_FILESYSTEM_FUNCTION_UNAVAILABLE = 5;
Expand All @@ -50,11 +51,12 @@ export const CODAMA_ERROR__VISITORS__ACCOUNT_FIELD_NOT_FOUND = 1200005;
export const CODAMA_ERROR__VISITORS__INVALID_NUMBER_WRAPPER = 1200006;
export const CODAMA_ERROR__VISITORS__CANNOT_EXTEND_MISSING_VISIT_FUNCTION = 1200007;
export const CODAMA_ERROR__VISITORS__FAILED_TO_VALIDATE_NODE = 1200008;
export const CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND = 1200009;
export const CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND = 1200009;
export const CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES = 1200010;
export const CODAMA_ERROR__VISITORS__RENDER_MAP_KEY_NOT_FOUND = 1200011;
export const CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK = 1200012;
export const CODAMA_ERROR__VISITORS__INVALID_PROVIDED_VALUE = 1200013;
export const CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS = 1200014;

// Anchor-related errors.
// Reserve error codes in the range [2100000-2100999].
Expand Down Expand Up @@ -158,11 +160,12 @@ export type CodamaErrorCode =
| typeof CODAMA_ERROR__VISITORS__CANNOT_ADD_DUPLICATED_PDA_NAMES
| typeof CODAMA_ERROR__VISITORS__CANNOT_EXTEND_MISSING_VISIT_FUNCTION
| typeof CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES
| typeof CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS
| typeof CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK
| typeof CODAMA_ERROR__VISITORS__CANNOT_USE_OPTIONAL_ACCOUNT_AS_PDA_SEED_VALUE
| typeof CODAMA_ERROR__VISITORS__CYCLIC_DEPENDENCY_DETECTED_WHEN_RESOLVING_INSTRUCTION_DEFAULT_VALUES
| typeof CODAMA_ERROR__VISITORS__FAILED_TO_VALIDATE_NODE
| typeof CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND
| typeof CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND
| typeof CODAMA_ERROR__VISITORS__INVALID_INSTRUCTION_DEFAULT_VALUE_DEPENDENCY
| typeof CODAMA_ERROR__VISITORS__INVALID_NUMBER_WRAPPER
| typeof CODAMA_ERROR__VISITORS__INVALID_PDA_SEED_VALUES
Expand Down
11 changes: 8 additions & 3 deletions packages/errors/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ import {
CODAMA_ERROR__VISITORS__CANNOT_ADD_DUPLICATED_PDA_NAMES,
CODAMA_ERROR__VISITORS__CANNOT_EXTEND_MISSING_VISIT_FUNCTION,
CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES,
CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS,
CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK,
CODAMA_ERROR__VISITORS__CANNOT_USE_OPTIONAL_ACCOUNT_AS_PDA_SEED_VALUE,
CODAMA_ERROR__VISITORS__CYCLIC_DEPENDENCY_DETECTED_WHEN_RESOLVING_INSTRUCTION_DEFAULT_VALUES,
CODAMA_ERROR__VISITORS__FAILED_TO_VALIDATE_NODE,
CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND,
CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND,
CODAMA_ERROR__VISITORS__INVALID_INSTRUCTION_DEFAULT_VALUE_DEPENDENCY,
CODAMA_ERROR__VISITORS__INVALID_NUMBER_WRAPPER,
CODAMA_ERROR__VISITORS__INVALID_PDA_SEED_VALUES,
Expand Down Expand Up @@ -271,6 +272,10 @@ export type CodamaErrorContext = DefaultUnspecifiedErrorContextToUndefined<{
[CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES]: {
conflictingAttributes: IdentifierString[];
};
[CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS]: {
field: StructFieldTypeNode;
fieldName: IdentifierString;
};
[CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK]: {
path: readonly Node[];
};
Expand All @@ -293,8 +298,8 @@ export type CodamaErrorContext = DefaultUnspecifiedErrorContextToUndefined<{
formattedHistogram: string;
validationItems: readonly ValidationItem[];
};
[CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND]: {
argumentName: IdentifierString;
[CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND]: {
fieldName: IdentifierString;
instruction: InstructionNode;
instructionName: IdentifierString;
};
Expand Down
9 changes: 6 additions & 3 deletions packages/errors/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ import {
CODAMA_ERROR__VISITORS__CANNOT_ADD_DUPLICATED_PDA_NAMES,
CODAMA_ERROR__VISITORS__CANNOT_EXTEND_MISSING_VISIT_FUNCTION,
CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES,
CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS,
CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK,
CODAMA_ERROR__VISITORS__CANNOT_USE_OPTIONAL_ACCOUNT_AS_PDA_SEED_VALUE,
CODAMA_ERROR__VISITORS__CYCLIC_DEPENDENCY_DETECTED_WHEN_RESOLVING_INSTRUCTION_DEFAULT_VALUES,
CODAMA_ERROR__VISITORS__FAILED_TO_VALIDATE_NODE,
CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND,
CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND,
CODAMA_ERROR__VISITORS__INVALID_INSTRUCTION_DEFAULT_VALUE_DEPENDENCY,
CODAMA_ERROR__VISITORS__INVALID_NUMBER_WRAPPER,
CODAMA_ERROR__VISITORS__INVALID_PDA_SEED_VALUES,
Expand Down Expand Up @@ -139,14 +140,16 @@ export const CodamaErrorMessages: Readonly<{
'Cannot extend visitor with function [$visitFunction] as the base visitor does not support it.',
[CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_CONFLICTING_ATTRIBUTES]:
'Cannot flatten struct since this would cause the following attributes to conflict [$conflictingAttributes].',
[CODAMA_ERROR__VISITORS__CANNOT_FLATTEN_STRUCT_WITH_PLUGINS]:
'Cannot flatten the struct of field [$fieldName] since it carries plugins that would be lost.',
[CODAMA_ERROR__VISITORS__CANNOT_REMOVE_LAST_PATH_IN_NODE_STACK]: 'Cannot remove the last path in the node stack.',
[CODAMA_ERROR__VISITORS__CANNOT_USE_OPTIONAL_ACCOUNT_AS_PDA_SEED_VALUE]:
'Cannot use optional account [$seedValueName] as the [$seedName] PDA seed for the [$instructionAccountName] account of the [$instructionName] instruction.',
[CODAMA_ERROR__VISITORS__CYCLIC_DEPENDENCY_DETECTED_WHEN_RESOLVING_INSTRUCTION_DEFAULT_VALUES]:
'Circular dependency detected when resolving the default values of the [$instructionName] instruction. Got the following dependency cycle [$formattedCycle].',
[CODAMA_ERROR__VISITORS__FAILED_TO_VALIDATE_NODE]: 'Failed to validate the given node [$formattedHistogram].',
[CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_ARGUMENT_NOT_FOUND]:
'Could not find an enum argument named [$argumentName] for instruction [$instructionName].',
[CODAMA_ERROR__VISITORS__INSTRUCTION_ENUM_DATA_FIELD_NOT_FOUND]:
'Could not find an enum data field named [$fieldName] for instruction [$instructionName].',
[CODAMA_ERROR__VISITORS__INVALID_INSTRUCTION_DEFAULT_VALUE_DEPENDENCY]:
'Dependency [$dependencyName] of kind [$dependencyKind] is not a valid dependency of [$parentName] of kind [$parentKind] in the [$instructionName] instruction.',
[CODAMA_ERROR__VISITORS__INVALID_NUMBER_WRAPPER]: 'Invalid number wrapper kind [$wrapper].',
Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-from-anchor/src/defaultVisitor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { assertIsNode, Node, RootNode } from '@codama/nodes';
import {
deduplicateIdenticalDefinedTypesVisitor,
flattenInstructionDataArgumentsVisitor,
flattenInstructionDataVisitor,
getCommonInstructionAccountDefaultRules,
rootNodeVisitor,
setFixedAccountSizesVisitor,
setInstructionAccountDefaultValuesVisitor,
transformU8ArraysToBytesVisitor,
unwrapInstructionArgsDefinedTypesVisitor,
unwrapInstructionDataDefinedTypesVisitor,
visit,
Visitor,
} from '@codama/visitors';
Expand All @@ -34,8 +34,8 @@ export function defaultVisitor() {

// Instructions.
updateRoot(setInstructionAccountDefaultValuesVisitor(getCommonInstructionAccountDefaultRules()));
updateRoot(unwrapInstructionArgsDefinedTypesVisitor());
updateRoot(flattenInstructionDataArgumentsVisitor());
updateRoot(unwrapInstructionDataDefinedTypesVisitor());
updateRoot(flattenInstructionDataVisitor());

// Extras.
updateRoot(transformU8ArraysToBytesVisitor());
Expand Down
Loading
Loading