@solana/errors 2.0.0-experimental.2d1d49c → 2.0.0-experimental.34c3228

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.
package/dist/cli.js CHANGED
@@ -10,10 +10,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
10
10
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
11
11
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
12
12
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
13
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
14
+ var SOLANA_ERROR__NONCE_INVALID = 6;
15
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
13
16
 
14
17
  // src/messages.ts
15
18
  var SolanaErrorMessages = {
19
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
16
20
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
21
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
22
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
17
23
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
18
24
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
19
25
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -8,10 +8,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
8
8
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
9
9
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
10
10
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
11
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
12
+ var SOLANA_ERROR__NONCE_INVALID = 6;
13
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
11
14
 
12
15
  // src/messages.ts
13
16
  var SolanaErrorMessages = {
17
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
14
18
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
19
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
20
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
15
21
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
16
22
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
17
23
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -94,7 +100,10 @@ var SolanaError = class extends Error {
94
100
  }
95
101
  };
96
102
 
103
+ exports.SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED;
97
104
  exports.SOLANA_ERROR__INVALID_KEYPAIR_BYTES = SOLANA_ERROR__INVALID_KEYPAIR_BYTES;
105
+ exports.SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
106
+ exports.SOLANA_ERROR__NONCE_INVALID = SOLANA_ERROR__NONCE_INVALID;
98
107
  exports.SOLANA_ERROR__RPC_INTEGER_OVERFLOW = SOLANA_ERROR__RPC_INTEGER_OVERFLOW;
99
108
  exports.SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES;
100
109
  exports.SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;;;ACI5C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AC1BA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA;AAAA,QAAgB;AAAA,MAAQ;AAAA,MACnB;AAAA;AAAA,EAElB,WAAW,OAAO,UAAU,UAAU;AAClC,WAAO,GAAG,KAAK;AAAA,EACnB,OAAO;AACH,WAAO;AAAA,MACH;AAAA,QACI,OAAO,eAAe,KAAK,MAAM;AAAA;A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P;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
1
+ {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;;;ACI9C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAChC;AAAA,EACJ,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,qCAAqC,GAAG;AAAA,EACzC,CAAC,2BAA2B,GACxB;AAAA,EACJ,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AClCA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA;AAAA,QAAgB;AAAA,MAAQ;AAAA,MACnB;AAAA;AAAA,EAElB,WAAW,OAAO,UAAU,UAAU;AAClC,WAAO,GAAG,KAAK;AAAA,EACnB,OAAO;AACH,WAAO;AAAA,MACH;AAAA,QACI,OAAO,eAAe,KAAK,MAAM;AAAA;AAAA;AAAA,UAG3B,EAAE,GAAI,MAAiB;AAAA,YACvB;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ;AAEA,SAAS,yBAAyB,CAAC,KAAK,KAAK,GAAiD;AAC1F,SAAO,GAAG,GAAG,IAAI,YAAY,KAAK,CAAC;AACvC;AAEA,SAAS,oBAAoB,SAAiB;AAC1C,SAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,wBAAwB,EAAE,KAAK,GAAG;AACzE;AAEO,SAAS,6BACZ,MACA,UAAkB,CAAC,GACb;AACN,QAAM,sBAAsB,oBAAoB,IAAI;AACpD,QAAM,UAAU,oBAAoB;AAAA,IAAQ;AAAA,IAAmB,CAAC,WAAW,iBACvE,gBAAgB,UAAU,GAAG,QAAQ,YAAoC,CAAC,KAAK;AAAA,EACnF;AACA,SAAO;AACX;AAEO,SAAS,gBAAoD,MAAkB,UAAkB,CAAC,GAAW;AAChH,MAAI,SAAS;AACT,WAAO,6BAA6B,MAAM,OAAO;AAAA,EACrD,OAAO;AACH,QAAI,wBAAwB,iBAAiB,IAAI,8DAA8D,IAAI;AACnH,QAAI,OAAO,KAAK,OAAO,EAAE,QAAQ;AAM7B,+BAAyB,MAAM,oBAAoB,OAAO,CAAC;AAAA,IAC/D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
@@ -6,10 +6,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
6
6
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
7
7
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
8
8
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
9
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
10
+ var SOLANA_ERROR__NONCE_INVALID = 6;
11
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
9
12
 
10
13
  // src/messages.ts
11
14
  var SolanaErrorMessages = {
15
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
12
16
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
17
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
18
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
13
19
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
14
20
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
15
21
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -92,6 +98,6 @@ var SolanaError = class extends Error {
92
98
  }
93
99
  };
94
100
 
95
- export { SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
101
+ export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
96
102
  //# sourceMappingURL=out.js.map
97
103
  //# sourceMappingURL=index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;;;ACI5C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AC1BA,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7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
1
+ {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;;;ACI9C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAChC;AAAA,EACJ,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,qCAAqC,GAAG;AAAA,EACzC,CAAC,2BAA2B,GACxB;AAAA,EACJ,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AClCA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA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AAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
@@ -6,10 +6,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
6
6
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
7
7
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
8
8
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
9
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
10
+ var SOLANA_ERROR__NONCE_INVALID = 6;
11
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
9
12
 
10
13
  // src/messages.ts
11
14
  var SolanaErrorMessages = {
15
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
12
16
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
17
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
18
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
13
19
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
14
20
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
15
21
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -92,6 +98,6 @@ var SolanaError = class extends Error {
92
98
  }
93
99
  };
94
100
 
95
- export { SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
101
+ export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
96
102
  //# sourceMappingURL=out.js.map
97
103
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;;;ACI5C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AC1BA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA;AAAA,QAAgB;AAAA,MAAQ;AAAA,MACnB;AAAA;AAAA,EAElB,WAAW,OAAO,UAAU,UAAU;AAClC,WAAO,GAAG,KAAK;AAAA,EACnB,OAAO;AACH,WAAO;AAAA,MACH;AAAA,QACI,OAAO,eAAe,KAAK,MAAM;AAAA;AAAA;AAAA,UAG3B,EAAE,GAAI,MAAiB;AAAA,YACvB;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ;AAEA,SAAS,yBAAyB,CAAC,KAAK,KAAK,GAAiD;AAC1F,SAAO,GAAG,GAAG,IAAI,YAAY,KAAK,CAAC;AACvC;AAEA,SAAS,oBAAoB,SAAiB;AAC1C,SAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,wBAAwB,EAAE,KAAK,GAAG;AACzE;AAEO,SAAS,6BACZ,MACA,UAAkB,CAAC,GACb;AACN,QAAM,sBAAsB,oBAAoB,IAAI;AACpD,QAAM,UAAU,oBAAoB;AAAA,IAAQ;AAAA,IAAmB,CAAC,WAAW,iBACvE,gBAAgB,UAAU,GAAG,QAAQ,YAAoC,CAAC,KAAK;AAAA,EACnF;AACA,SAAO;AACX;AAEO,SAAS,gBAAoD,MAAkB,UAAkB,CAAC,GAAW;AAChH,MAAI,SAAS;AACT,WAAO,6BAA6B,MAAM,OAAO;AAAA,EACrD,OAAO;AACH,QAAI,wBAAwB,iBAAiB,IAAI,8DAA8D,IAAI;AACnH,QAAI,OAAO,KAAK,OAAO,EAAE,QAAQ;AAM7B,+BAAyB,MAAM,oBAAoB,OAAO,CAAC;AAAA,IAC/D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
1
+ {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;;;ACI9C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAChC;AAAA,EACJ,CAAC,mCAAmC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I,wBAAwB,iBAAiB,IAAI,8DAA8D,IAAI;AACnH,QAAI,OAAO,KAAK,OAAO,EAAE,QAAQ;AAM7B,+BAAyB,MAAM,oBAAoB,OAAO,CAAC;AAAA,IAC/D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
@@ -8,10 +8,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
8
8
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
9
9
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
10
10
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
11
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
12
+ var SOLANA_ERROR__NONCE_INVALID = 6;
13
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
11
14
 
12
15
  // src/messages.ts
13
16
  var SolanaErrorMessages = {
17
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
14
18
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
19
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
20
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
15
21
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
16
22
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
17
23
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -94,7 +100,10 @@ var SolanaError = class extends Error {
94
100
  }
95
101
  };
96
102
 
103
+ exports.SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED;
97
104
  exports.SOLANA_ERROR__INVALID_KEYPAIR_BYTES = SOLANA_ERROR__INVALID_KEYPAIR_BYTES;
105
+ exports.SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
106
+ exports.SOLANA_ERROR__NONCE_INVALID = SOLANA_ERROR__NONCE_INVALID;
98
107
  exports.SOLANA_ERROR__RPC_INTEGER_OVERFLOW = SOLANA_ERROR__RPC_INTEGER_OVERFLOW;
99
108
  exports.SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES;
100
109
  exports.SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;;;ACI5C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AC1BA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA;AAAA,QAAgB;AAAA,MAAQ;AAAA,MACnB;AAAA;AAAA,EAElB,WAAW,OAAO,UAAU,UAAU;AAClC,WAAO,GAAG,KAAK;AAAA,EACnB,OAAO;AACH,WAAO;A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K,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
1
+ {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;;;ACI9C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAChC;AAAA,EACJ,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,qCAAqC,GAAG;AAAA,EACzC,CAAC,2BAA2B,GACxB;AAAA,EACJ,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AClCA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG,IACtD,YAAY,OAAO;AAAA,MAC7B,EACC;AAAA;AAAA,QAAgB;AAAA,MAAQ;AAAA,MACnB;AAAA;AAAA,EAElB,WAAW,OAAO,UAAU,UAAU;AAClC,WAAO,GAAG,KAAK;AAAA,EACnB,OAAO;AACH,WAAO;AAAA,MACH;AAAA,QACI,OAAO,eAAe,KAAK,MAAM;AAAA;AAAA;AAAA,UAG3B,EAAE,GAAI,MAAiB;AAAA,YACvB;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ;AAEA,SAAS,yBAAyB,CAAC,KAAK,KAAK,GAAiD;AAC1F,SAAO,GAAG,GAAG,IAAI,YAAY,KAAK,CAAC;AACvC;AAEA,SAAS,oBAAoB,SAAiB;AAC1C,SAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,wBAAwB,EAAE,KAAK,GAAG;AACzE;AAEO,SAAS,6BACZ,MACA,UAAkB,CAAC,GACb;AACN,QAAM,sBAAsB,oBAAoB,IAAI;AACpD,QAAM,UAAU,oBAAoB;AAAA,IAAQ;AAAA,IAAmB,CAAC,WAAW,iBACvE,gBAAgB,UAAU,GAAG,QAAQ,YAAoC,CAAC,KAAK;AAAA,EACnF;AACA,SAAO;AACX;AAEO,SAAS,gBAAoD,MAAkB,UAAkB,CAAC,GAAW;AAChH,MAAI,SAAS;AACT,WAAO,6BAA6B,MAAM,OAAO;AAAA,EACrD,OAAO;AACH,QAAI,wBAAwB,iBAAiB,IAAI,8DAA8D,IAAI;AACnH,QAAI,OAAO,KAAK,OAAO,EAAE,QAAQ;AAM7B,+BAAyB,MAAM,oBAAoB,OAAO,CAAC;AAAA,IAC/D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
@@ -6,10 +6,16 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
6
6
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
7
7
  var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
8
8
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
9
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
10
+ var SOLANA_ERROR__NONCE_INVALID = 6;
11
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
9
12
 
10
13
  // src/messages.ts
11
14
  var SolanaErrorMessages = {
15
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
12
16
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
17
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
18
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
13
19
  [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
14
20
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
15
21
  [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
@@ -92,6 +98,6 @@ var SolanaError = class extends Error {
92
98
  }
93
99
  };
94
100
 
95
- export { SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
101
+ export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError };
96
102
  //# sourceMappingURL=out.js.map
97
103
  //# sourceMappingURL=index.node.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;;;ACI5C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAA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D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
1
+ {"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;;;ACI9C,IAAM,sBAIR;AAAA,EACD,CAAC,mCAAmC,GAChC;AAAA,EACJ,CAAC,mCAAmC,GAAG;AAAA,EACvC,CAAC,qCAAqC,GAAG;AAAA,EACzC,CAAC,2BAA2B,GACxB;AAAA,EACJ,CAAC,kCAAkC,GAC/B;AAAA,EAGJ,CAAC,4CAA4C,GAAG;AAAA,EAChD,CAAC,kDAAkD,GAC/C;AAER;;;AClCA,SAAS,YAAY,OAAwB;AACzC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB;AAAA;AAAA,MACc,QACV,MACK;AAAA,QAAI,aACD,OAAO,YAAY,WACb,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,KAAK,CA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AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
@@ -10,6 +10,9 @@ export declare const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES: 1;
10
10
  export declare const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE: 2;
11
11
  export declare const SOLANA_ERROR__RPC_INTEGER_OVERFLOW: 3;
12
12
  export declare const SOLANA_ERROR__INVALID_KEYPAIR_BYTES: 4;
13
+ export declare const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED: 5;
14
+ export declare const SOLANA_ERROR__NONCE_INVALID: 6;
15
+ export declare const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND: 7;
13
16
  /**
14
17
  * A union of every Solana error code
15
18
  *
@@ -25,5 +28,5 @@ export declare const SOLANA_ERROR__INVALID_KEYPAIR_BYTES: 4;
25
28
  * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`
26
29
  * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850
27
30
  */
28
- export type SolanaErrorCode = typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;
31
+ export type SolanaErrorCode = typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED | typeof SOLANA_ERROR__NONCE_INVALID | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
29
32
  //# sourceMappingURL=codes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,4CAA4C,GAAa,CAAC;AACvE,eAAO,MAAM,kDAAkD,GAAa,CAAC;AAC7E,eAAO,MAAM,kCAAkC,GAAa,CAAC;AAC7D,eAAO,MAAM,mCAAmC,GAAa,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,GACrB,OAAO,4CAA4C,GACnD,OAAO,kDAAkD,GACzD,OAAO,kCAAkC,GACzC,OAAO,mCAAmC,CAAC"}
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,4CAA4C,GAAa,CAAC;AACvE,eAAO,MAAM,kDAAkD,GAAa,CAAC;AAC7E,eAAO,MAAM,kCAAkC,GAAa,CAAC;AAC7D,eAAO,MAAM,mCAAmC,GAAa,CAAC;AAC9D,eAAO,MAAM,mCAAmC,GAAa,CAAC;AAC9D,eAAO,MAAM,2BAA2B,GAAa,CAAC;AACtD,eAAO,MAAM,qCAAqC,GAAa,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,GACrB,OAAO,4CAA4C,GACnD,OAAO,kDAAkD,GACzD,OAAO,kCAAkC,GACzC,OAAO,mCAAmC,GAC1C,OAAO,mCAAmC,GAC1C,OAAO,2BAA2B,GAClC,OAAO,qCAAqC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SolanaErrorCode } from './codes.js';
1
+ import { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SolanaErrorCode } from './codes.js';
2
2
  export type DefaultUnspecifiedErrorContextToUndefined<T> = {
3
3
  [P in SolanaErrorCode]: P extends keyof T ? T[P] : undefined;
4
4
  };
@@ -10,6 +10,10 @@ export type DefaultUnspecifiedErrorContextToUndefined<T> = {
10
10
  * - Don't change or remove members of an error's context.
11
11
  */
12
12
  export type SolanaErrorContext = DefaultUnspecifiedErrorContextToUndefined<{
13
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: {
14
+ currentBlockHeight: bigint;
15
+ lastValidBlockHeight: bigint;
16
+ };
13
17
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: {
14
18
  addresses: string[];
15
19
  };
@@ -24,5 +28,12 @@ export type SolanaErrorContext = DefaultUnspecifiedErrorContextToUndefined<{
24
28
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: {
25
29
  byteLength: number;
26
30
  };
31
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: {
32
+ nonceAccountAddress: string;
33
+ };
34
+ [SOLANA_ERROR__NONCE_INVALID]: {
35
+ actualNonceValue: string;
36
+ expectedNonceValue: string;
37
+ };
27
38
  }>;
28
39
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mCAAmC,EACnC,kCAAkC,EAClC,4CAA4C,EAC5C,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,yCAAyC,CAAC,CAAC,IAAI;KACtD,CAAC,IAAI,eAAe,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CAC/D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,yCAAyC,CAAC;IACvE,CAAC,4CAA4C,CAAC,EAAE;QAC5C,SAAS,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;IACF,CAAC,kCAAkC,CAAC,EAAE;QAClC,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;QAC/C,UAAU,EAAE,MAAM,CAAC;QACnB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,CAAC,mCAAmC,CAAC,EAAE;QACnC,UAAU,EAAE,MAAM,CAAC;KACtB,CAAC;CACL,CAAC,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mCAAmC,EACnC,mCAAmC,EACnC,qCAAqC,EACrC,2BAA2B,EAC3B,kCAAkC,EAClC,4CAA4C,EAC5C,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,yCAAyC,CAAC,CAAC,IAAI;KACtD,CAAC,IAAI,eAAe,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CAC/D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,yCAAyC,CAAC;IACvE,CAAC,mCAAmC,CAAC,EAAE;QACnC,kBAAkB,EAAE,MAAM,CAAC;QAC3B,oBAAoB,EAAE,MAAM,CAAC;KAChC,CAAC;IACF,CAAC,4CAA4C,CAAC,EAAE;QAC5C,SAAS,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;IACF,CAAC,kCAAkC,CAAC,EAAE;QAClC,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;QAC/C,UAAU,EAAE,MAAM,CAAC;QACnB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,CAAC,mCAAmC,CAAC,EAAE;QACnC,UAAU,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,CAAC,qCAAqC,CAAC,EAAE;QACrC,mBAAmB,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,CAAC,2BAA2B,CAAC,EAAE;QAC3B,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;KAC9B,CAAC;CACL,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC;KAGtC,CAAC,IAAI,eAAe,GAAG,MAAM;CACjC,CAUA,CAAC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC;KAGtC,CAAC,IAAI,eAAe,GAAG,MAAM;CACjC,CAeA,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/errors",
3
- "version": "2.0.0-experimental.2d1d49c",
3
+ "version": "2.0.0-experimental.34c3228",
4
4
  "description": "Throw, identify, and decode Solana JavaScript errors",
5
5
  "exports": {
6
6
  "browser": {
@@ -50,32 +50,8 @@
50
50
  "node": ">=17.4"
51
51
  },
52
52
  "dependencies": {
53
- "commander": "^11.1.0",
54
- "chalk": "^5.3.0"
55
- },
56
- "devDependencies": {
57
- "@solana/eslint-config-solana": "^1.0.2",
58
- "@swc/jest": "^0.2.29",
59
- "@types/jest": "^29.5.11",
60
- "@types/node": "18.11.19",
61
- "@typescript-eslint/eslint-plugin": "^6.13.2",
62
- "@typescript-eslint/parser": "^6.3.0",
63
- "agadoo": "^3.0.0",
64
- "eslint": "^8.45.0",
65
- "eslint-plugin-jest": "^27.4.2",
66
- "eslint-plugin-sort-keys-fix": "^1.1.2",
67
- "jest": "^29.7.0",
68
- "jest-environment-jsdom": "^29.7.0",
69
- "jest-runner-eslint": "^2.1.2",
70
- "jest-runner-prettier": "^1.0.0",
71
- "prettier": "^3.1",
72
- "tsup": "^8.0.1",
73
- "typescript": "^5.2.2",
74
- "version-from-git": "^1.1.1",
75
- "@solana/addresses": "2.0.0-experimental.2d1d49c",
76
- "build-scripts": "0.0.0",
77
- "test-config": "0.0.0",
78
- "tsconfig": "0.0.0"
53
+ "chalk": "^5.3.0",
54
+ "commander": "^11.1.0"
79
55
  },
80
56
  "bundlewatch": {
81
57
  "defaultCompression": "gzip",
@@ -87,17 +63,18 @@
87
63
  },
88
64
  "scripts": {
89
65
  "compile:js": "tsup --config build-scripts/tsup.config.package.ts && tsup src/cli.ts --format esm",
90
- "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
91
- "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
92
- "publish-packages": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks",
66
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
67
+ "dev": "jest -c node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
68
+ "publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks",
69
+ "publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
93
70
  "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
94
- "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
95
- "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
71
+ "test:lint": "jest -c node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
72
+ "test:prettier": "jest -c node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
96
73
  "test:treeshakability:browser": "agadoo dist/index.browser.js",
97
74
  "test:treeshakability:native": "agadoo dist/index.native.js",
98
75
  "test:treeshakability:node": "agadoo dist/index.node.js",
99
76
  "test:typecheck": "tsc --noEmit",
100
- "test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
101
- "test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
77
+ "test:unit:browser": "jest -c node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
78
+ "test:unit:node": "jest -c node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
102
79
  }
103
80
  }