@solana/errors 2.0.0-experimental.b93299a → 2.0.0-experimental.bea19d2
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/bin/cli.js +7 -0
- package/dist/cli.js +306 -0
- package/dist/index.browser.cjs +559 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +436 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +436 -6
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +559 -5
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +436 -6
- package/dist/index.node.js.map +1 -1
- package/dist/types/codes.d.ts +126 -4
- package/dist/types/codes.d.ts.map +1 -1
- package/dist/types/context.d.ts +114 -4
- 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 +13 -35
- package/bin/cli.ts +0 -55
|
@@ -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.bea19d2",
|
|
4
4
|
"description": "Throw, identify, and decode Solana JavaScript errors",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"solana",
|
|
33
33
|
"web3"
|
|
34
34
|
],
|
|
35
|
-
"bin": "./bin/cli.
|
|
35
|
+
"bin": "./bin/cli.js",
|
|
36
36
|
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
@@ -49,32 +49,9 @@
|
|
|
49
49
|
"engine": {
|
|
50
50
|
"node": ">=17.4"
|
|
51
51
|
},
|
|
52
|
-
"
|
|
53
|
-
"@solana/eslint-config-solana": "^1.0.2",
|
|
54
|
-
"@swc/jest": "^0.2.29",
|
|
55
|
-
"@types/jest": "^29.5.11",
|
|
56
|
-
"@types/node": "18.11.19",
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
58
|
-
"@typescript-eslint/parser": "^6.3.0",
|
|
59
|
-
"agadoo": "^3.0.0",
|
|
52
|
+
"dependencies": {
|
|
60
53
|
"chalk": "^5.3.0",
|
|
61
|
-
"commander": "^
|
|
62
|
-
"eslint": "^8.45.0",
|
|
63
|
-
"eslint-plugin-jest": "^27.4.2",
|
|
64
|
-
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
65
|
-
"jest": "^29.7.0",
|
|
66
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
67
|
-
"jest-runner-eslint": "^2.1.2",
|
|
68
|
-
"jest-runner-prettier": "^1.0.0",
|
|
69
|
-
"prettier": "^3.1",
|
|
70
|
-
"tsup": "^8.0.1",
|
|
71
|
-
"tsx": "^4.7.0",
|
|
72
|
-
"typescript": "^5.2.2",
|
|
73
|
-
"version-from-git": "^1.1.1",
|
|
74
|
-
"@solana/addresses": "2.0.0-experimental.b93299a",
|
|
75
|
-
"build-scripts": "0.0.0",
|
|
76
|
-
"test-config": "0.0.0",
|
|
77
|
-
"tsconfig": "0.0.0"
|
|
54
|
+
"commander": "^12.0.0"
|
|
78
55
|
},
|
|
79
56
|
"bundlewatch": {
|
|
80
57
|
"defaultCompression": "gzip",
|
|
@@ -85,18 +62,19 @@
|
|
|
85
62
|
]
|
|
86
63
|
},
|
|
87
64
|
"scripts": {
|
|
88
|
-
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
|
|
89
|
-
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
|
|
90
|
-
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
|
|
91
|
-
"publish-
|
|
65
|
+
"compile:js": "tsup --config build-scripts/tsup.config.package.ts && tsup src/cli.ts --format esm",
|
|
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",
|
|
92
70
|
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
|
|
93
|
-
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
|
|
94
|
-
"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",
|
|
95
73
|
"test:treeshakability:browser": "agadoo dist/index.browser.js",
|
|
96
74
|
"test:treeshakability:native": "agadoo dist/index.native.js",
|
|
97
75
|
"test:treeshakability:node": "agadoo dist/index.node.js",
|
|
98
76
|
"test:typecheck": "tsc --noEmit",
|
|
99
|
-
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
|
|
100
|
-
"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"
|
|
101
79
|
}
|
|
102
80
|
}
|
package/bin/cli.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S tsx
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { Command, InvalidArgumentError } from 'commander';
|
|
5
|
-
|
|
6
|
-
import { version } from '../package.json';
|
|
7
|
-
import { SolanaErrorCode } from '../src/codes';
|
|
8
|
-
import { getHumanReadableErrorMessage } from '../src/message-formatter';
|
|
9
|
-
import { SolanaErrorMessages } from '../src/messages';
|
|
10
|
-
|
|
11
|
-
const program = new Command();
|
|
12
|
-
|
|
13
|
-
program.name('@solana/errors').description('Decode Solana JavaScript errors thrown in production').version(version);
|
|
14
|
-
|
|
15
|
-
program
|
|
16
|
-
.command('decode')
|
|
17
|
-
.description('Decode a `SolanaErrorCode` to a human-readable message')
|
|
18
|
-
.argument('<code>', 'numeric error code to decode', rawCode => {
|
|
19
|
-
const code = parseInt(rawCode, 10);
|
|
20
|
-
if (isNaN(code) || `${code}` !== rawCode) {
|
|
21
|
-
throw new InvalidArgumentError('It must be an integer');
|
|
22
|
-
}
|
|
23
|
-
if (!(code in SolanaErrorMessages)) {
|
|
24
|
-
throw new InvalidArgumentError('There exists no error with that code');
|
|
25
|
-
}
|
|
26
|
-
return code;
|
|
27
|
-
})
|
|
28
|
-
.argument('[encodedContext]', 'encoded context to interpolate into the error message', encodedContext =>
|
|
29
|
-
Object.fromEntries(new URLSearchParams(encodedContext).entries()),
|
|
30
|
-
)
|
|
31
|
-
.action((code: number, context) => {
|
|
32
|
-
const message = getHumanReadableErrorMessage(code as SolanaErrorCode, context);
|
|
33
|
-
console.log(`
|
|
34
|
-
${
|
|
35
|
-
chalk.bold(
|
|
36
|
-
chalk.rgb(154, 71, 255)('[') +
|
|
37
|
-
chalk.rgb(144, 108, 244)('D') +
|
|
38
|
-
chalk.rgb(134, 135, 233)('e') +
|
|
39
|
-
chalk.rgb(122, 158, 221)('c') +
|
|
40
|
-
chalk.rgb(110, 178, 209)('o') +
|
|
41
|
-
chalk.rgb(95, 195, 196)('d') +
|
|
42
|
-
chalk.rgb(79, 212, 181)('e') +
|
|
43
|
-
chalk.rgb(57, 227, 166)('d') +
|
|
44
|
-
chalk.rgb(19, 241, 149)(']'),
|
|
45
|
-
) + chalk.rgb(19, 241, 149)(' Solana error code #' + code)
|
|
46
|
-
}
|
|
47
|
-
- ${message}`);
|
|
48
|
-
if (context) {
|
|
49
|
-
console.log(`
|
|
50
|
-
${chalk.yellowBright(chalk.bold('[Context]'))}
|
|
51
|
-
${JSON.stringify(context, null, 4).split('\n').join('\n ')}`);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
program.parse();
|