Skip to content

Commit

Permalink
ts: Add missing errors (#2906)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Apr 13, 2024
1 parent a18d6ca commit 95c4959
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ The minor version will be incremented upon a breaking change and the patch versi
- avm, cli: Fix `stdsimd` feature compilation error from `ahash` when installing the CLI using newer Rust versions ([#2867](https://github.com/coral-xyz/anchor/pull/2867)).
- spl: Fix not being able to deserialize newer token 2022 extensions ([#2876](https://github.com/coral-xyz/anchor/pull/2876)).
- spl: Remove `solana-program` dependency ([#2900](https://github.com/coral-xyz/anchor/pull/2900)).
- spl: Make TokenAccount and Mint Copy ([#2904])(https://github.com/coral-xyz/anchor/pull/2904)
- spl: Make `TokenAccount` and ` Mint` `Copy` ([#2904](https://github.com/coral-xyz/anchor/pull/2904)).
- ts: Add missing errors ([#2906](https://github.com/coral-xyz/anchor/pull/2906)).

### Breaking

Expand Down
114 changes: 114 additions & 0 deletions ts/packages/anchor/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ export const LangErrorCode = {
// IDL instructions.
IdlInstructionStub: 1000,
IdlInstructionInvalidProgram: 1001,
IdlAccountNotEmpty: 1002,

// Event instructions.
EventInstructionStub: 1500,

// Constraints.
ConstraintMut: 2000,
Expand All @@ -338,6 +342,25 @@ export const LangErrorCode = {
ConstraintMintDecimals: 2018,
ConstraintSpace: 2019,
ConstraintAccountIsNone: 2020,
ConstraintTokenTokenProgram: 2021,
ConstraintMintTokenProgram: 2022,
ConstraintAssociatedTokenTokenProgram: 2023,
ConstraintMintGroupPointerExtension: 2024,
ConstraintMintGroupPointerExtensionAuthority: 2025,
ConstraintMintGroupPointerExtensionGroupAddress: 2026,
ConstraintMintGroupMemberPointerExtension: 2027,
ConstraintMintGroupMemberPointerExtensionAuthority: 2028,
ConstraintMintGroupMemberPointerExtensionMemberAddress: 2029,
ConstraintMintMetadataPointerExtension: 2030,
ConstraintMintMetadataPointerExtensionAuthority: 2031,
ConstraintMintMetadataPointerExtensionMetadataAddress: 2032,
ConstraintMintCloseAuthorityExtension: 2033,
ConstraintMintCloseAuthorityExtensionAuthority: 2034,
ConstraintMintPermanentDelegateExtension: 2035,
ConstraintMintPermanentDelegateExtensionDelegate: 2036,
ConstraintMintTransferHookExtension: 2037,
ConstraintMintTransferHookExtensionAuthority: 2038,
ConstraintMintTransferHookExtensionProgramId: 2039,

// Require.
RequireViolated: 2500,
Expand Down Expand Up @@ -370,6 +393,7 @@ export const LangErrorCode = {

// Miscellaneous
DeclaredProgramIdMismatch: 4100,
TryingToInitPayerAsProgramAccount: 4101,

// Used for APIs that shouldn't be used anymore.
Deprecated: 5000,
Expand Down Expand Up @@ -403,6 +427,16 @@ export const LangErrorMessage = new Map([
LangErrorCode.IdlInstructionInvalidProgram,
"The transaction was given an invalid program for the IDL instruction",
],
[
LangErrorCode.IdlAccountNotEmpty,
"IDL account must be empty in order to resize, try closing first",
],

// Event instructions.
[
LangErrorCode.EventInstructionStub,
"The program was compiled without `event-cpi` feature",
],

// Constraints.
[LangErrorCode.ConstraintMut, "A mut constraint was violated"],
Expand Down Expand Up @@ -447,6 +481,82 @@ export const LangErrorMessage = new Map([
LangErrorCode.ConstraintAccountIsNone,
"A required account for the constraint is None",
],
[
LangErrorCode.ConstraintTokenTokenProgram,
"A token account token program constraint was violated",
],
[
LangErrorCode.ConstraintMintTokenProgram,
"A mint token program constraint was violated",
],
[
LangErrorCode.ConstraintAssociatedTokenTokenProgram,
"An associated token account token program constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupPointerExtension,
"A group pointer extension constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupPointerExtensionAuthority,
"A group pointer extension authority constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupPointerExtensionGroupAddress,
"A group pointer extension group address constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupMemberPointerExtension,
"A group member pointer extension constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupMemberPointerExtensionAuthority,
"A group member pointer extension authority constraint was violated",
],
[
LangErrorCode.ConstraintMintGroupMemberPointerExtensionMemberAddress,
"A group member pointer extension group address constraint was violated",
],
[
LangErrorCode.ConstraintMintMetadataPointerExtension,
"A metadata pointer extension constraint was violated",
],
[
LangErrorCode.ConstraintMintMetadataPointerExtensionAuthority,
"A metadata pointer extension authority constraint was violated",
],
[
LangErrorCode.ConstraintMintMetadataPointerExtensionMetadataAddress,
"A metadata pointer extension metadata address constraint was violated",
],
[
LangErrorCode.ConstraintMintCloseAuthorityExtension,
"A close authority constraint was violated",
],
[
LangErrorCode.ConstraintMintCloseAuthorityExtensionAuthority,
"A close authority extension authority constraint was violated",
],
[
LangErrorCode.ConstraintMintPermanentDelegateExtension,
"A permanent delegate extension constraint was violated",
],
[
LangErrorCode.ConstraintMintPermanentDelegateExtensionDelegate,
"A permanent delegate extension delegate constraint was violated",
],
[
LangErrorCode.ConstraintMintTransferHookExtension,
"A transfer hook extension constraint was violated",
],
[
LangErrorCode.ConstraintMintTransferHookExtensionAuthority,
"A transfer hook extension authority constraint was violated",
],
[
LangErrorCode.ConstraintMintTransferHookExtensionProgramId,
"A transfer hook extension transfer hook program id constraint was violated",
],

// Require.
[LangErrorCode.RequireViolated, "A require expression was violated"],
Expand Down Expand Up @@ -524,6 +634,10 @@ export const LangErrorMessage = new Map([
LangErrorCode.DeclaredProgramIdMismatch,
"The declared program id does not match the actual program id",
],
[
LangErrorCode.TryingToInitPayerAsProgramAccount,
"You cannot/should not initialize the payer account as a program account",
],

// Deprecated
[
Expand Down

0 comments on commit 95c4959

Please sign in to comment.