@solana/errors 2.0.0-experimental.025ef21 → 2.0.0-experimental.080a7d1
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 +261 -5
- package/dist/index.browser.cjs +578 -6
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +449 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +449 -7
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +578 -6
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +449 -7
- package/dist/index.node.js.map +1 -1
- package/dist/types/codes.d.ts +132 -4
- package/dist/types/codes.d.ts.map +1 -1
- package/dist/types/context.d.ts +107 -5
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instruction-error.d.ts +5 -0
- package/dist/types/instruction-error.d.ts.map +1 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/rpc-enum-errors.d.ts +31 -0
- package/dist/types/rpc-enum-errors.d.ts.map +1 -0
- package/dist/types/transaction-error.d.ts +5 -0
- package/dist/types/transaction-error.d.ts.map +1 -0
- package/package.json +11 -34
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SolanaErrorCode } from './codes.js';
|
|
2
|
+
import { SolanaErrorContext } from './context.js';
|
|
3
|
+
import { SolanaError } from './error.js';
|
|
4
|
+
type Config = Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain.
|
|
7
|
+
*
|
|
8
|
+
* One of the goals of `@solana/errors` is to allow errors that are not interesting to your
|
|
9
|
+
* application to shake out of your app bundle in production. This means that we must never
|
|
10
|
+
* export large hardcoded maps of error codes/messages.
|
|
11
|
+
*
|
|
12
|
+
* Unfortunately, where instruction and transaction errors from the RPC are concerned, we have
|
|
13
|
+
* no choice but to keep a map between the RPC `rpcEnumError` enum name and its corresponding
|
|
14
|
+
* `SolanaError` code. In the interest of implementing that map in as few bytes of source code
|
|
15
|
+
* as possible, we do the following:
|
|
16
|
+
*
|
|
17
|
+
* 1. Reserve a block of sequential error codes for the enum in question
|
|
18
|
+
* 2. Hardcode the list of enum names in that same order
|
|
19
|
+
* 3. Match the enum error name from the RPC with its index in that list, and reconstruct the
|
|
20
|
+
* `SolanaError` code by adding the `errorCodeBaseOffset` to that index
|
|
21
|
+
*/
|
|
22
|
+
errorCodeBaseOffset: number;
|
|
23
|
+
getErrorContext: (errorCode: SolanaErrorCode, rpcErrorName: string, rpcErrorContext?: unknown) => SolanaErrorContext[SolanaErrorCode];
|
|
24
|
+
orderedErrorNames: string[];
|
|
25
|
+
rpcEnumError: string | {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
export declare function getSolanaErrorFromRpcError({ errorCodeBaseOffset, getErrorContext, orderedErrorNames, rpcEnumError }: Config, constructorOpt: Function): SolanaError;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=rpc-enum-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-enum-errors.d.ts","sourceRoot":"","sources":["../../src/rpc-enum-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,KAAK,MAAM,GAAG,QAAQ,CAAC;IACnB;;;;;;;;;;;;;;;;OAgBG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,CACb,SAAS,EAAE,eAAe,EAC1B,YAAY,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,OAAO,KACxB,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACzC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACrD,CAAC,CAAC;AAEH,wBAAgB,0BAA0B,CACtC,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,EAAE,MAAM,EAEjF,cAAc,EAAE,QAAQ,GACzB,WAAW,CAiBb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-error.d.ts","sourceRoot":"","sources":["../../src/transaction-error.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAsDtC,wBAAgB,kCAAkC,CAAC,gBAAgB,EAAE,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,WAAW,CAiCrH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/errors",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.080a7d1",
|
|
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
|
-
"
|
|
54
|
-
"
|
|
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.025ef21",
|
|
76
|
-
"build-scripts": "0.0.0",
|
|
77
|
-
"test-config": "0.0.0",
|
|
78
|
-
"tsconfig": "0.0.0"
|
|
53
|
+
"chalk": "^5.3.0",
|
|
54
|
+
"commander": "^12.0.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-
|
|
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
|
}
|