@solana/programs 5.1.0-canary-20251202172407 → 5.1.0-canary-20251202174830

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program-error.ts"],"names":["isSolanaError","SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM"],"mappings":";;;;;AA8BO,SAAS,cACZ,CAAA,KAAA,EACA,kBACA,EAAA,cAAA,EACA,IAE4D,EAAA;AAC5D,EAAA,IAAI,CAACA,oBAAA,CAAc,KAAO,EAAAC,8CAAuC,CAAG,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,MAAM,4BAA4B,kBAAmB,CAAA,YAAA,CAAa,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA,cAAA;AACxF,EAAI,IAAA,CAAC,yBAA6B,IAAA,yBAAA,KAA8B,cAAgB,EAAA;AAC5E,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,OAAO,OAAO,IAAA,KAAS,WAAe,IAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,IAAA;AACjE","file":"index.browser.cjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
1
+ {"version":3,"sources":["../src/program-error.ts"],"names":["isSolanaError","SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM"],"mappings":";;;;;AA8BO,SAAS,cAAA,CACZ,KAAA,EACA,kBAAA,EACA,cAAA,EACA,IAAA,EAE4D;AAC5D,EAAA,IAAI,CAACA,oBAAA,CAAc,KAAA,EAAOC,8CAAuC,CAAA,EAAG;AAChE,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,MAAM,4BAA4B,kBAAA,CAAmB,YAAA,CAAa,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,cAAA;AACxF,EAAA,IAAI,CAAC,yBAAA,IAA6B,yBAAA,KAA8B,cAAA,EAAgB;AAC5E,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,IAAe,KAAA,CAAM,QAAQ,IAAA,KAAS,IAAA;AACjE","file":"index.browser.cjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cACZ,CAAA,KAAA,EACA,kBACA,EAAA,cAAA,EACA,IAE4D,EAAA;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAO,EAAA,uCAAuC,CAAG,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,MAAM,4BAA4B,kBAAmB,CAAA,YAAA,CAAa,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA,cAAA;AACxF,EAAI,IAAA,CAAC,yBAA6B,IAAA,yBAAA,KAA8B,cAAgB,EAAA;AAC5E,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,OAAO,OAAO,IAAA,KAAS,WAAe,IAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,IAAA;AACjE","file":"index.browser.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
1
+ {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cAAA,CACZ,KAAA,EACA,kBAAA,EACA,cAAA,EACA,IAAA,EAE4D;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAA,EAAO,uCAAuC,CAAA,EAAG;AAChE,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,MAAM,4BAA4B,kBAAA,CAAmB,YAAA,CAAa,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,cAAA;AACxF,EAAA,IAAI,CAAC,yBAAA,IAA6B,yBAAA,KAA8B,cAAA,EAAgB;AAC5E,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,IAAe,KAAA,CAAM,QAAQ,IAAA,KAAS,IAAA;AACjE","file":"index.browser.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cACZ,CAAA,KAAA,EACA,kBACA,EAAA,cAAA,EACA,IAE4D,EAAA;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAO,EAAA,uCAAuC,CAAG,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,MAAM,4BAA4B,kBAAmB,CAAA,YAAA,CAAa,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA,cAAA;AACxF,EAAI,IAAA,CAAC,yBAA6B,IAAA,yBAAA,KAA8B,cAAgB,EAAA;AAC5E,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,OAAO,OAAO,IAAA,KAAS,WAAe,IAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,IAAA;AACjE","file":"index.native.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
1
+ {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cAAA,CACZ,KAAA,EACA,kBAAA,EACA,cAAA,EACA,IAAA,EAE4D;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAA,EAAO,uCAAuC,CAAA,EAAG;AAChE,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,MAAM,4BAA4B,kBAAA,CAAmB,YAAA,CAAa,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,cAAA;AACxF,EAAA,IAAI,CAAC,yBAAA,IAA6B,yBAAA,KAA8B,cAAA,EAAgB;AAC5E,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,IAAe,KAAA,CAAM,QAAQ,IAAA,KAAS,IAAA;AACjE","file":"index.native.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program-error.ts"],"names":["isSolanaError","SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM"],"mappings":";;;;;AA8BO,SAAS,cACZ,CAAA,KAAA,EACA,kBACA,EAAA,cAAA,EACA,IAE4D,EAAA;AAC5D,EAAA,IAAI,CAACA,oBAAA,CAAc,KAAO,EAAAC,8CAAuC,CAAG,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,MAAM,4BAA4B,kBAAmB,CAAA,YAAA,CAAa,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA,cAAA;AACxF,EAAI,IAAA,CAAC,yBAA6B,IAAA,yBAAA,KAA8B,cAAgB,EAAA;AAC5E,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,OAAO,OAAO,IAAA,KAAS,WAAe,IAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,IAAA;AACjE","file":"index.node.cjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
1
+ {"version":3,"sources":["../src/program-error.ts"],"names":["isSolanaError","SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM"],"mappings":";;;;;AA8BO,SAAS,cAAA,CACZ,KAAA,EACA,kBAAA,EACA,cAAA,EACA,IAAA,EAE4D;AAC5D,EAAA,IAAI,CAACA,oBAAA,CAAc,KAAA,EAAOC,8CAAuC,CAAA,EAAG;AAChE,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,MAAM,4BAA4B,kBAAA,CAAmB,YAAA,CAAa,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,cAAA;AACxF,EAAA,IAAI,CAAC,yBAAA,IAA6B,yBAAA,KAA8B,cAAA,EAAgB;AAC5E,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,IAAe,KAAA,CAAM,QAAQ,IAAA,KAAS,IAAA;AACjE","file":"index.node.cjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cACZ,CAAA,KAAA,EACA,kBACA,EAAA,cAAA,EACA,IAE4D,EAAA;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAO,EAAA,uCAAuC,CAAG,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,MAAM,4BAA4B,kBAAmB,CAAA,YAAA,CAAa,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA,cAAA;AACxF,EAAI,IAAA,CAAC,yBAA6B,IAAA,yBAAA,KAA8B,cAAgB,EAAA;AAC5E,IAAO,OAAA,KAAA;AAAA;AAEX,EAAA,OAAO,OAAO,IAAA,KAAS,WAAe,IAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,IAAA;AACjE","file":"index.node.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
1
+ {"version":3,"sources":["../src/program-error.ts"],"names":[],"mappings":";;;AA8BO,SAAS,cAAA,CACZ,KAAA,EACA,kBAAA,EACA,cAAA,EACA,IAAA,EAE4D;AAC5D,EAAA,IAAI,CAAC,aAAA,CAAc,KAAA,EAAO,uCAAuC,CAAA,EAAG;AAChE,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,MAAM,4BAA4B,kBAAA,CAAmB,YAAA,CAAa,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,cAAA;AACxF,EAAA,IAAI,CAAC,yBAAA,IAA6B,yBAAA,KAA8B,cAAA,EAAgB;AAC5E,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,IAAe,KAAA,CAAM,QAAQ,IAAA,KAAS,IAAA;AACjE","file":"index.node.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { isSolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SolanaError } from '@solana/errors';\n\n/**\n * Identifies whether an error -- typically caused by a transaction failure -- is a custom program\n * error from the provided program address.\n *\n * @param transactionMessage The transaction message that failed to execute. Since the RPC response\n * only provides the index of the failed instruction, the transaction message is required to\n * determine its program address\n * @param programAddress The address of the program from which the error is expected to have\n * originated\n * @param code The expected error code of the custom program error. When provided, the function will\n * check that the custom program error code matches the given value.\n *\n * @example\n * ```ts\n * try {\n * // Send and confirm your transaction.\n * } catch (error) {\n * if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {\n * // Handle custom program error 42 from this program.\n * } else if (isProgramError(error, transactionMessage, myProgramAddress)) {\n * // Handle all other custom program errors from this program.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isProgramError<TProgramErrorCode extends number>(\n error: unknown,\n transactionMessage: { instructions: Record<number, { programAddress: Address }> },\n programAddress: Address,\n code?: TProgramErrorCode,\n): error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> &\n SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> {\n if (!isSolanaError(error, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {\n return false;\n }\n const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;\n if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {\n return false;\n }\n return typeof code === 'undefined' || error.context.code === code;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/programs",
3
- "version": "5.1.0-canary-20251202172407",
3
+ "version": "5.1.0-canary-20251202174830",
4
4
  "description": "Helpers for defining programs and resolving program errors",
5
5
  "homepage": "https://www.solanakit.com/api#solanaprograms",
6
6
  "exports": {
@@ -55,8 +55,8 @@
55
55
  "maintained node versions"
56
56
  ],
57
57
  "dependencies": {
58
- "@solana/addresses": "5.1.0-canary-20251202172407",
59
- "@solana/errors": "5.1.0-canary-20251202172407"
58
+ "@solana/addresses": "5.1.0-canary-20251202174830",
59
+ "@solana/errors": "5.1.0-canary-20251202174830"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "typescript": ">=5.3.3"