
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@solana/programs
Advanced tools
Helpers for defining programs and resolving program errors
This package contains types for defining programs and helpers for resolving program errors. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK @solana/web3.js@experimental
.
Program
The Program
type defines a Solana program.
const myProgram: Program<'1234..5678'> = {
name: 'myProgramName',
address: '1234..5678' as Address<'1234..5678'>,
};
ProgramWithErrors
The ProgramWithErrors
type helps extend the Program
type by defining a getErrorFromCode
function that can be used to resolve a custom program error from a transaction error code.
enum MyProgramErrorCode {
UNINITIALIZED_ACCOUNT = 0,
INVALID_ACCOUNT_OWNER = 1,
INVALID_ACCOUNT_DATA = 2,
SOME_OTHER_ERROR = 3,
}
class MyProgramError extends Error {
// ...
}
const myProgram: Program<'1234..5678'> & ProgramWithErrors<MyProgramErrorCode, MyProgramError> = {
name: 'myProgramName',
address: '1234..5678' as Address<'1234..5678'>,
getErrorFromCode: (code: MyProgramErrorCode, originalError: Error): MyProgramError => {
// ...
},
};
resolveTransactionError()
This function takes a raw error caused by a transaction failure and attempts to resolve it into a custom program error.
For this to work, the resolveTransactionError
function also needs the following parameters:
transaction
object that failed to execute. This allows us to identify the failing instruction and correctly identify the program that caused the error.programs
that can be used to resolve the error. If the program that caused the error is not present in the array, the function won't be able to return a custom program error.Note that, if the error cannot be resolved into a custom program error, the original error is returned as-is.
// Store your programs.
const programs = [createSplSystemProgram(), createSplComputeBudgetProgram(), createSplAddressLookupTableProgram()];
try {
// Send and confirm your transaction.
} catch (error) {
throw resolveTransactionError(error, transaction, programs);
}
FAQs
Helpers for defining programs and resolving program errors
The npm package @solana/programs receives a total of 44,202 weekly downloads. As such, @solana/programs popularity was classified as popular.
We found that @solana/programs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.