Files
memecoin-botV2/.pnpm-store/v10/files/ce/a3caeea673bf28e027f026ff6a2c4b0c64964c7ef7e0e9c7e3759a91232a7bde374ec428c1b962822ffa65b75a35ff8fdca49059eebc27e5f73064924470a2

31 lines
1.7 KiB
Plaintext

import { SolanaErrorCode } from './codes';
import { SolanaErrorContext } from './context';
import { SolanaError } from './error';
type Config = Readonly<{
/**
* Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain.
*
* One of the goals of `@solana/errors` is to allow errors that are not interesting to your
* application to shake out of your app bundle in production. This means that we must never
* export large hardcoded maps of error codes/messages.
*
* Unfortunately, where instruction and transaction errors from the RPC are concerned, we have
* no choice but to keep a map between the RPC `rpcEnumError` enum name and its corresponding
* `SolanaError` code. In the interest of implementing that map in as few bytes of source code
* as possible, we do the following:
*
* 1. Reserve a block of sequential error codes for the enum in question
* 2. Hardcode the list of enum names in that same order
* 3. Match the enum error name from the RPC with its index in that list, and reconstruct the
* `SolanaError` code by adding the `errorCodeBaseOffset` to that index
*/
errorCodeBaseOffset: number;
getErrorContext: (errorCode: SolanaErrorCode, rpcErrorName: string, rpcErrorContext?: unknown) => SolanaErrorContext[SolanaErrorCode];
orderedErrorNames: string[];
rpcEnumError: string | {
[key: string]: unknown;
};
}>;
export declare function getSolanaErrorFromRpcError({ errorCodeBaseOffset, getErrorContext, orderedErrorNames, rpcEnumError }: Config, constructorOpt: Function): SolanaError;
export {};
//# sourceMappingURL=rpc-enum-errors.d.ts.map