WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag usage of __iterator__ property
|
||||
* @author Ian Christian Myers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const { getStaticPropertyName } = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow the use of the `__iterator__` property",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-iterator",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
noIterator: "Reserved name '__iterator__'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
if (getStaticPropertyName(node) === "__iterator__") {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "noIterator",
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { builtinModules } from 'node:module';
|
||||
|
||||
// copied from vite
|
||||
// https://github.com/vitejs/vite/blob/814120f2ad387ca3d1e16c7dd403b04ca4b97f75/packages/vite/src/node/utils.ts#L106
|
||||
// Supported by Node, Deno, Bun
|
||||
const NODE_BUILTIN_NAMESPACE = "node:";
|
||||
// Supported by Deno
|
||||
const NPM_BUILTIN_NAMESPACE = "npm:";
|
||||
// Supported by Bun
|
||||
const BUN_BUILTIN_NAMESPACE = "bun:";
|
||||
// Some runtimes like Bun injects namespaced modules here, which is not a node builtin
|
||||
const nodeBuiltins = builtinModules.filter((id) => !id.includes(":"));
|
||||
const { bun: isBun, deno: isDeno } = process.versions;
|
||||
// TODO: Use `isBuiltin` from `node:module`, but Deno doesn't support it
|
||||
function isBuiltin(id) {
|
||||
if (isDeno && id.startsWith(NPM_BUILTIN_NAMESPACE)) return true;
|
||||
if (isBun && id.startsWith(BUN_BUILTIN_NAMESPACE)) return true;
|
||||
return isNodeBuiltin(id);
|
||||
}
|
||||
function isNodeBuiltin(id) {
|
||||
if (id.startsWith(NODE_BUILTIN_NAMESPACE)) return true;
|
||||
return nodeBuiltins.includes(id);
|
||||
}
|
||||
const browserExternalId = "__vite-browser-external";
|
||||
const browserExternalLength = 24;
|
||||
function isBrowserExternal(id) {
|
||||
return id.startsWith(browserExternalId);
|
||||
}
|
||||
function toBuiltin(id) {
|
||||
if (id.startsWith(browserExternalId)) id = id.slice(browserExternalLength);
|
||||
if (id.startsWith(NPM_BUILTIN_NAMESPACE) || id.startsWith(BUN_BUILTIN_NAMESPACE) || id.startsWith(NODE_BUILTIN_NAMESPACE)) return id;
|
||||
if (isDeno || isBun) return id;
|
||||
return `node:${id}`;
|
||||
}
|
||||
|
||||
export { isBrowserExternal as a, isBuiltin as i, toBuiltin as t };
|
||||
@@ -0,0 +1,251 @@
|
||||
# obug
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![JSR][jsr-badge-src]][jsr-badge-href]
|
||||
[![Unit Test][unit-test-src]][unit-test-href]
|
||||
|
||||
A lightweight JavaScript debugging utility, forked from [debug](https://www.npmjs.com/package/debug), featuring TypeScript and ESM support.
|
||||
|
||||
> [!NOTE]
|
||||
> obug v1 retains most of the compatibility with [debug](https://github.com/debug-js/debug), but drops support for older browsers and Node.js, making it a drop-in replacement.
|
||||
>
|
||||
> obug v2 refactors some API imports and usage for better support of ESM and TypeScript, easier customization, and an even smaller package size.
|
||||
|
||||
## Key Differences from `debug`
|
||||
|
||||
- ✨ Minimal footprint
|
||||
- 7.7 kB package size
|
||||
- 1.4 KB minified + gzipped for browsers
|
||||
- 📦 Zero dependencies
|
||||
- 📝 Full TypeScript support
|
||||
- 🚀 Native ESM compatibility
|
||||
- 🌐 Optimized for modern runtimes
|
||||
- ES2015+ browsers
|
||||
- Modern Node.js versions
|
||||
- 🎨 Customizable formatting
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install obug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { createDebug, disable, enable, enabled, namespaces } from 'obug'
|
||||
|
||||
// Get the currently enabled namespaces
|
||||
console.log(namespaces())
|
||||
|
||||
const debug = createDebug('my-namespace', {
|
||||
// All options are optional
|
||||
|
||||
useColors: true, // false, true, undefined for auto-detect
|
||||
color: 2, // custom color
|
||||
// custom formatArgs
|
||||
formatArgs(args) {},
|
||||
formatters: {},
|
||||
// Node.js only
|
||||
inspectOpts: {},
|
||||
|
||||
// custom log
|
||||
log: console.log,
|
||||
})
|
||||
|
||||
debug('This is a debug message')
|
||||
console.log(
|
||||
debug.namespace, // 'my-namespace'
|
||||
debug.enabled, // Check if enabled
|
||||
debug.useColors, // true
|
||||
debug.color, // 2
|
||||
debug.formatArgs, // custom formatArgs
|
||||
debug.formatters, // {}
|
||||
debug.inspectOpts, // {}
|
||||
debug.log, // implemented log function
|
||||
)
|
||||
|
||||
// Create a sub-namespace, and it will inherit options from the parent debugger
|
||||
const sub = debug.extend('sub-namespace')
|
||||
sub('This is a sub-namespace debug message')
|
||||
console.log(sub.namespace) // 'my-namespace:sub-namespace'
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
### Enabling debug output
|
||||
|
||||
obug picks up enabled namespaces from the `DEBUG` environment variable in Node.js, or from `localStorage.debug` in browsers.
|
||||
|
||||
In Node.js:
|
||||
|
||||
```bash
|
||||
DEBUG=app:* node app.js
|
||||
```
|
||||
|
||||
On Windows (CMD):
|
||||
|
||||
```cmd
|
||||
set DEBUG=app:* & node app.js
|
||||
```
|
||||
|
||||
On Windows (PowerShell):
|
||||
|
||||
```powershell
|
||||
$env:DEBUG='app:*'; node app.js
|
||||
```
|
||||
|
||||
In the browser, set the value in DevTools and refresh the page:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'app:*'
|
||||
```
|
||||
|
||||
### Wildcards and exclusion
|
||||
|
||||
The `*` character is a wildcard. Suppose your library has debuggers named `connect:bodyParser`, `connect:compress`, and `connect:session` — instead of listing each one, use `DEBUG=connect:*`. Use `DEBUG=*` to enable everything.
|
||||
|
||||
Exclude namespaces by prefixing them with `-`:
|
||||
|
||||
```bash
|
||||
DEBUG=*,-connect:* node app.js
|
||||
```
|
||||
|
||||
### Namespace conventions
|
||||
|
||||
If you're using obug in a library, prefix your namespaces with the library name and use `:` to separate features (e.g. `connect:bodyParser`). This lets users opt into the parts they care about without guessing names.
|
||||
|
||||
### Extending a namespace
|
||||
|
||||
Use `.extend()` to create a sub-namespace that inherits options from its parent:
|
||||
|
||||
```ts
|
||||
const log = createDebug('auth')
|
||||
const logSign = log.extend('sign') // 'auth:sign'
|
||||
const logLogin = log.extend('login') // 'auth:login'
|
||||
|
||||
log('hello') // auth hello
|
||||
logSign('hello') // auth:sign hello
|
||||
logLogin('hello') // auth:login hello
|
||||
```
|
||||
|
||||
### Formatters
|
||||
|
||||
obug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Built-in formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
| --------- | -------------------------------------------------- |
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%%` | Single percent sign. Does not consume an argument. |
|
||||
|
||||
Other format specifiers supported by Node's `util.format` (`%s`, `%d`, `%j`, …) and the browser console pass through to the underlying logger.
|
||||
|
||||
#### Custom formatters
|
||||
|
||||
Register custom formatters via the `formatters` option. For example, to render a `Buffer` as hex with `%h`:
|
||||
|
||||
```ts
|
||||
const debug = createDebug('foo', {
|
||||
formatters: {
|
||||
h: (v) => v.toString('hex'),
|
||||
},
|
||||
})
|
||||
|
||||
debug('this is hex: %h', Buffer.from('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c64 +0ms
|
||||
```
|
||||
|
||||
### Dynamic enable / disable
|
||||
|
||||
You can toggle namespaces at runtime:
|
||||
|
||||
```ts
|
||||
import { disable, enable, enabled, namespaces } from 'obug'
|
||||
|
||||
enable('app:*')
|
||||
console.log(enabled('app:server')) // true
|
||||
|
||||
const previous = disable()
|
||||
console.log(enabled('app:server')) // false
|
||||
|
||||
// Restore later
|
||||
enable(previous)
|
||||
```
|
||||
|
||||
`namespaces()` returns the string of currently enabled namespaces. Note that calling `enable()` overrides the value initially read from `DEBUG`.
|
||||
|
||||
### Checking whether a debugger is enabled
|
||||
|
||||
Guard expensive work behind the `enabled` property:
|
||||
|
||||
```ts
|
||||
const debug = createDebug('http')
|
||||
|
||||
if (debug.enabled) {
|
||||
// expensive computation only when enabled
|
||||
}
|
||||
```
|
||||
|
||||
You can also force the state by assigning to `debug.enabled` directly.
|
||||
|
||||
### Custom output
|
||||
|
||||
By default, obug writes to `stderr` in Node.js and to the console in browsers. Override the `log` option to redirect output per-namespace:
|
||||
|
||||
```ts
|
||||
const log = createDebug('app:log', {
|
||||
log: console.log,
|
||||
})
|
||||
|
||||
const error = createDebug('app:error') // still goes to stderr
|
||||
```
|
||||
|
||||
### Environment variables (Node.js)
|
||||
|
||||
| Name | Purpose |
|
||||
| ------------------- | ----------------------------------------------- |
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS` | Whether to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
Variables prefixed with `DEBUG_` are converted to camelCase keys on the options object passed to Node's [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) for the `%o` / `%O` formatters.
|
||||
|
||||
## Original Authors
|
||||
|
||||
As obug is a fork of debug with significant modifications, we would like to acknowledge the original authors:
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
- Josh Junon
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)
|
||||
|
||||
[The MIT License](./LICENSE) Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
[The MIT License](./LICENSE) Copyright (c) 2018-2021 Josh Junon
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/obug.svg
|
||||
[npm-version-href]: https://npmjs.com/package/obug
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/obug
|
||||
[npm-downloads-href]: https://www.npmcharts.com/compare/obug?interval=30
|
||||
[unit-test-src]: https://github.com/sxzz/obug/actions/workflows/unit-test.yml/badge.svg
|
||||
[unit-test-href]: https://github.com/sxzz/obug/actions/workflows/unit-test.yml
|
||||
[jsr-badge-src]: https://jsr.io/badges/@sxzz/obug
|
||||
[jsr-badge-href]: https://jsr.io/@sxzz/obug
|
||||
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
let Input = require('./input')
|
||||
let Parser = require('./parser')
|
||||
|
||||
function parse(css, opts) {
|
||||
let input = new Input(css, opts)
|
||||
let parser = new Parser(input)
|
||||
try {
|
||||
parser.parse()
|
||||
} catch (e) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (e.name === 'CssSyntaxError' && opts && opts.from) {
|
||||
if (/\.scss$/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse SCSS with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-scss parser'
|
||||
} else if (/\.sass/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse Sass with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-sass parser'
|
||||
} else if (/\.less$/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse Less with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-less parser'
|
||||
}
|
||||
}
|
||||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
return parser.root
|
||||
}
|
||||
|
||||
module.exports = parse
|
||||
parse.default = parse
|
||||
|
||||
Container.registerParse(parse)
|
||||
@@ -0,0 +1,30 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function del(targetPath) {
|
||||
if (!fs.existsSync(targetPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (fs.statSync(targetPath).isDirectory()) {
|
||||
// If it's a directory, delete its contents first
|
||||
fs.readdirSync(targetPath).forEach(file => {
|
||||
const curPath = path.join(targetPath, file);
|
||||
|
||||
if (fs.statSync(curPath).isFile()) {
|
||||
fs.unlinkSync(curPath); // Delete file
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(targetPath); // Delete the now-empty directory
|
||||
} else {
|
||||
fs.unlinkSync(targetPath); // If it's a file, delete it directly
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(`Error while deleting ${targetPath}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { del };
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { Version7Options } from './types.js';
|
||||
type V7State = {
|
||||
msecs?: number;
|
||||
seq?: number;
|
||||
};
|
||||
declare function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
|
||||
declare function v7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
|
||||
export declare function updateV7State(state: V7State, now: number, rnds: Uint8Array): V7State;
|
||||
export default v7;
|
||||
@@ -0,0 +1,80 @@
|
||||
import Benchmark from "benchmark";
|
||||
|
||||
import { z } from "zod/v3";
|
||||
|
||||
const doubleSuite = new Benchmark.Suite("z.union: double");
|
||||
const manySuite = new Benchmark.Suite("z.union: many");
|
||||
|
||||
const aSchema = z.object({
|
||||
type: z.literal("a"),
|
||||
});
|
||||
const objA = {
|
||||
type: "a",
|
||||
};
|
||||
|
||||
const bSchema = z.object({
|
||||
type: z.literal("b"),
|
||||
});
|
||||
const objB = {
|
||||
type: "b",
|
||||
};
|
||||
|
||||
const cSchema = z.object({
|
||||
type: z.literal("c"),
|
||||
});
|
||||
const objC = {
|
||||
type: "c",
|
||||
};
|
||||
|
||||
const dSchema = z.object({
|
||||
type: z.literal("d"),
|
||||
});
|
||||
|
||||
const double = z.union([aSchema, bSchema]);
|
||||
const many = z.union([aSchema, bSchema, cSchema, dSchema]);
|
||||
|
||||
doubleSuite
|
||||
.add("valid: a", () => {
|
||||
double.parse(objA);
|
||||
})
|
||||
.add("valid: b", () => {
|
||||
double.parse(objB);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
double.parse(null);
|
||||
} catch (_err) {}
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
double.parse(objC);
|
||||
} catch (_err) {}
|
||||
})
|
||||
.on("cycle", (e: Benchmark.Event) => {
|
||||
console.log(`${(doubleSuite as any).name}: ${e.target}`);
|
||||
});
|
||||
|
||||
manySuite
|
||||
.add("valid: a", () => {
|
||||
many.parse(objA);
|
||||
})
|
||||
.add("valid: c", () => {
|
||||
many.parse(objC);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
many.parse(null);
|
||||
} catch (_err) {}
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
many.parse({ type: "unknown" });
|
||||
} catch (_err) {}
|
||||
})
|
||||
.on("cycle", (e: Benchmark.Event) => {
|
||||
console.log(`${(manySuite as any).name}: ${e.target}`);
|
||||
});
|
||||
|
||||
export default {
|
||||
suites: [doubleSuite, manySuite],
|
||||
};
|
||||
@@ -0,0 +1,204 @@
|
||||
import {
|
||||
Document,
|
||||
Node,
|
||||
Plugin,
|
||||
ProcessOptions,
|
||||
Root,
|
||||
SourceMap,
|
||||
TransformCallback,
|
||||
Warning,
|
||||
WarningOptions
|
||||
} from './postcss.js'
|
||||
import Processor from './processor.js'
|
||||
|
||||
declare namespace Result {
|
||||
export interface Message {
|
||||
[others: string]: any
|
||||
|
||||
/**
|
||||
* Source PostCSS plugin name.
|
||||
*/
|
||||
plugin?: string
|
||||
|
||||
/**
|
||||
* Message type.
|
||||
*/
|
||||
type: string
|
||||
}
|
||||
|
||||
export interface ResultOptions extends ProcessOptions {
|
||||
/**
|
||||
* The CSS node that was the source of the warning.
|
||||
*/
|
||||
node?: Node
|
||||
|
||||
/**
|
||||
* Name of plugin that created this warning. `Result#warn` will fill it
|
||||
* automatically with `Plugin#postcssPlugin` value.
|
||||
*/
|
||||
plugin?: string
|
||||
}
|
||||
|
||||
export { Result_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the result of the PostCSS transformations.
|
||||
*
|
||||
* A Result instance is returned by `LazyResult#then`
|
||||
* or `Root#toResult` methods.
|
||||
*
|
||||
* ```js
|
||||
* postcss([autoprefixer]).process(css).then(result => {
|
||||
* console.log(result.css)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const result2 = postcss.parse(css).toResult()
|
||||
* ```
|
||||
*/
|
||||
declare class Result_<RootNode = Document | Root> {
|
||||
/**
|
||||
* A CSS string representing of `Result#root`.
|
||||
*
|
||||
* ```js
|
||||
* postcss.parse('a{}').toResult().css //=> "a{}"
|
||||
* ```
|
||||
*/
|
||||
css: string
|
||||
|
||||
/**
|
||||
* Last runned PostCSS plugin.
|
||||
*/
|
||||
lastPlugin: Plugin | TransformCallback
|
||||
|
||||
/**
|
||||
* An instance of `SourceMapGenerator` class from the `source-map` library,
|
||||
* representing changes to the `Result#root` instance.
|
||||
*
|
||||
* ```js
|
||||
* result.map.toJSON() //=> { version: 3, file: 'a.css', … }
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* if (result.map) {
|
||||
* fs.writeFileSync(result.opts.to + '.map', result.map.toString())
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
map: SourceMap
|
||||
|
||||
/**
|
||||
* Contains messages from plugins (e.g., warnings or custom messages).
|
||||
* Each message should have type and plugin properties.
|
||||
*
|
||||
* ```js
|
||||
* AtRule: {
|
||||
* import: (atRule, { result }) {
|
||||
* const importedFile = parseImport(atRule)
|
||||
* result.messages.push({
|
||||
* type: 'dependency',
|
||||
* plugin: 'postcss-import',
|
||||
* file: importedFile,
|
||||
* parent: result.opts.from
|
||||
* })
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
messages: Result.Message[]
|
||||
|
||||
/**
|
||||
* Options from the `Processor#process` or `Root#toResult` call
|
||||
* that produced this Result instance.]
|
||||
*
|
||||
* ```js
|
||||
* root.toResult(opts).opts === opts
|
||||
* ```
|
||||
*/
|
||||
opts: Result.ResultOptions
|
||||
|
||||
/**
|
||||
* The Processor instance used for this transformation.
|
||||
*
|
||||
* ```js
|
||||
* for (const plugin of result.processor.plugins) {
|
||||
* if (plugin.postcssPlugin === 'postcss-bad') {
|
||||
* throw 'postcss-good is incompatible with postcss-bad'
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
processor: Processor
|
||||
|
||||
/**
|
||||
* Root node after all transformations.
|
||||
*
|
||||
* ```js
|
||||
* root.toResult().root === root
|
||||
* ```
|
||||
*/
|
||||
root: RootNode
|
||||
|
||||
/**
|
||||
* An alias for the `Result#css` property.
|
||||
* Use it with syntaxes that generate non-CSS output.
|
||||
*
|
||||
* ```js
|
||||
* result.css === result.content
|
||||
* ```
|
||||
*/
|
||||
get content(): string
|
||||
|
||||
/**
|
||||
* @param processor Processor used for this transformation.
|
||||
* @param root Root node after all transformations.
|
||||
* @param opts Options from the `Processor#process` or `Root#toResult`.
|
||||
*/
|
||||
constructor(processor: Processor, root: RootNode, opts: Result.ResultOptions)
|
||||
|
||||
/**
|
||||
* Returns for `Result#css` content.
|
||||
*
|
||||
* ```js
|
||||
* result + '' === result.css
|
||||
* ```
|
||||
*
|
||||
* @return String representing of `Result#root`.
|
||||
*/
|
||||
toString(): string
|
||||
|
||||
/**
|
||||
* Creates an instance of `Warning` and adds it to `Result#messages`.
|
||||
*
|
||||
* ```js
|
||||
* if (decl.important) {
|
||||
* result.warn('Avoid !important', { node: decl, word: '!important' })
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param text Warning message.
|
||||
* @param opts Warning options.
|
||||
* @return Created warning.
|
||||
*/
|
||||
warn(message: string, options?: WarningOptions): Warning
|
||||
|
||||
/**
|
||||
* Returns warnings from plugins. Filters `Warning` instances
|
||||
* from `Result#messages`.
|
||||
*
|
||||
* ```js
|
||||
* result.warnings().forEach(warn => {
|
||||
* console.warn(warn.toString())
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @return Warnings from plugins.
|
||||
*/
|
||||
warnings(): Warning[]
|
||||
}
|
||||
|
||||
declare class Result<RootNode = Document | Root> extends Result_<RootNode> {}
|
||||
|
||||
export = Result
|
||||
@@ -0,0 +1,58 @@
|
||||
<h1 align="center">Welcome to atomic-sleep ⏱️</h1>
|
||||
<p>
|
||||
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
|
||||
<a href="#" target="_blank">
|
||||
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
|
||||
</a>
|
||||
<a href="https://twitter.com/davidmarkclem" target="_blank">
|
||||
<img alt="Twitter: davidmarkclem" src="https://img.shields.io/twitter/follow/davidmarkclem.svg?style=social" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
> Zero CPU overhead, zero dependency, true event-loop blocking sleep
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const sleep = require('atomic-sleep')
|
||||
|
||||
console.time('sleep')
|
||||
setTimeout(() => { console.timeEnd('sleep') }, 100)
|
||||
sleep(1000)
|
||||
```
|
||||
|
||||
The `console.time` will report a time of just over 1000ms despite the `setTimeout`
|
||||
being 100ms. This is because the event loop is paused for 1000ms and the setTimeout
|
||||
fires immediately after the event loop is no longer blocked (as more than 100ms have passed).
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Node and Browser versions that support both `SharedArrayBuffer` and `Atomics` will have (virtually) zero CPU overhead sleep.
|
||||
|
||||
For Node, Atomic Sleep can provide zero CPU overhead sleep from Node 8 and up.
|
||||
|
||||
For browser support see https://caniuse.com/#feat=sharedarraybuffer and https://caniuse.com/#feat=mdn-javascript_builtins_atomics.
|
||||
|
||||
|
||||
For older Node versions and olders browsers we fall back to blocking the event loop in a way that will cause a CPU spike.
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
👤 **David Mark Clements (@davidmarkclem)**
|
||||
|
||||
* Twitter: [@davidmarkclem](https://twitter.com/davidmarkclem)
|
||||
* Github: [@davidmarkclements](https://github.com/davidmarkclements)
|
||||
@@ -0,0 +1,323 @@
|
||||
import bs58 from 'bs58';
|
||||
import {Buffer} from 'buffer';
|
||||
import * as BufferLayout from '@solana/buffer-layout';
|
||||
|
||||
import {PublicKey, PUBLIC_KEY_LENGTH} from '../publickey';
|
||||
import type {Blockhash} from '../blockhash';
|
||||
import * as Layout from '../layout';
|
||||
import {PACKET_DATA_SIZE, VERSION_PREFIX_MASK} from '../transaction/constants';
|
||||
import * as shortvec from '../utils/shortvec-encoding';
|
||||
import {toBuffer} from '../utils/to-buffer';
|
||||
import {
|
||||
MessageHeader,
|
||||
MessageAddressTableLookup,
|
||||
MessageCompiledInstruction,
|
||||
} from './index';
|
||||
import {TransactionInstruction} from '../transaction';
|
||||
import {CompiledKeys} from './compiled-keys';
|
||||
import {MessageAccountKeys} from './account-keys';
|
||||
import {guardedShift, guardedSplice} from '../utils/guarded-array-utils';
|
||||
|
||||
/**
|
||||
* An instruction to execute by a program
|
||||
*
|
||||
* @property {number} programIdIndex
|
||||
* @property {number[]} accounts
|
||||
* @property {string} data
|
||||
*/
|
||||
export type CompiledInstruction = {
|
||||
/** Index into the transaction keys array indicating the program account that executes this instruction */
|
||||
programIdIndex: number;
|
||||
/** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
|
||||
accounts: number[];
|
||||
/** The program input data encoded as base 58 */
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Message constructor arguments
|
||||
*/
|
||||
export type MessageArgs = {
|
||||
/** The message header, identifying signed and read-only `accountKeys` */
|
||||
header: MessageHeader;
|
||||
/** All the account keys used by this transaction */
|
||||
accountKeys: string[] | PublicKey[];
|
||||
/** The hash of a recent ledger block */
|
||||
recentBlockhash: Blockhash;
|
||||
/** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
|
||||
instructions: CompiledInstruction[];
|
||||
};
|
||||
|
||||
export type CompileLegacyArgs = {
|
||||
payerKey: PublicKey;
|
||||
instructions: Array<TransactionInstruction>;
|
||||
recentBlockhash: Blockhash;
|
||||
};
|
||||
|
||||
/**
|
||||
* List of instructions to be processed atomically
|
||||
*/
|
||||
export class Message {
|
||||
header: MessageHeader;
|
||||
accountKeys: PublicKey[];
|
||||
recentBlockhash: Blockhash;
|
||||
instructions: CompiledInstruction[];
|
||||
|
||||
private indexToProgramIds: Map<number, PublicKey> = new Map<
|
||||
number,
|
||||
PublicKey
|
||||
>();
|
||||
|
||||
constructor(args: MessageArgs) {
|
||||
this.header = args.header;
|
||||
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
||||
this.recentBlockhash = args.recentBlockhash;
|
||||
this.instructions = args.instructions;
|
||||
this.instructions.forEach(ix =>
|
||||
this.indexToProgramIds.set(
|
||||
ix.programIdIndex,
|
||||
this.accountKeys[ix.programIdIndex],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
get version(): 'legacy' {
|
||||
return 'legacy';
|
||||
}
|
||||
|
||||
get staticAccountKeys(): Array<PublicKey> {
|
||||
return this.accountKeys;
|
||||
}
|
||||
|
||||
get compiledInstructions(): Array<MessageCompiledInstruction> {
|
||||
return this.instructions.map(
|
||||
(ix): MessageCompiledInstruction => ({
|
||||
programIdIndex: ix.programIdIndex,
|
||||
accountKeyIndexes: ix.accounts,
|
||||
data: bs58.decode(ix.data),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
get addressTableLookups(): Array<MessageAddressTableLookup> {
|
||||
return [];
|
||||
}
|
||||
|
||||
getAccountKeys(): MessageAccountKeys {
|
||||
return new MessageAccountKeys(this.staticAccountKeys);
|
||||
}
|
||||
|
||||
static compile(args: CompileLegacyArgs): Message {
|
||||
const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);
|
||||
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
||||
const accountKeys = new MessageAccountKeys(staticAccountKeys);
|
||||
const instructions = accountKeys.compileInstructions(args.instructions).map(
|
||||
(ix: MessageCompiledInstruction): CompiledInstruction => ({
|
||||
programIdIndex: ix.programIdIndex,
|
||||
accounts: ix.accountKeyIndexes,
|
||||
data: bs58.encode(ix.data),
|
||||
}),
|
||||
);
|
||||
return new Message({
|
||||
header,
|
||||
accountKeys: staticAccountKeys,
|
||||
recentBlockhash: args.recentBlockhash,
|
||||
instructions,
|
||||
});
|
||||
}
|
||||
|
||||
isAccountSigner(index: number): boolean {
|
||||
return index < this.header.numRequiredSignatures;
|
||||
}
|
||||
|
||||
isAccountWritable(index: number): boolean {
|
||||
const numSignedAccounts = this.header.numRequiredSignatures;
|
||||
if (index >= this.header.numRequiredSignatures) {
|
||||
const unsignedAccountIndex = index - numSignedAccounts;
|
||||
const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;
|
||||
const numWritableUnsignedAccounts =
|
||||
numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
|
||||
return unsignedAccountIndex < numWritableUnsignedAccounts;
|
||||
} else {
|
||||
const numWritableSignedAccounts =
|
||||
numSignedAccounts - this.header.numReadonlySignedAccounts;
|
||||
return index < numWritableSignedAccounts;
|
||||
}
|
||||
}
|
||||
|
||||
isProgramId(index: number): boolean {
|
||||
return this.indexToProgramIds.has(index);
|
||||
}
|
||||
|
||||
programIds(): PublicKey[] {
|
||||
return [...this.indexToProgramIds.values()];
|
||||
}
|
||||
|
||||
nonProgramIds(): PublicKey[] {
|
||||
return this.accountKeys.filter((_, index) => !this.isProgramId(index));
|
||||
}
|
||||
|
||||
serialize(): Buffer {
|
||||
const numKeys = this.accountKeys.length;
|
||||
|
||||
let keyCount: number[] = [];
|
||||
shortvec.encodeLength(keyCount, numKeys);
|
||||
|
||||
const instructions = this.instructions.map(instruction => {
|
||||
const {accounts, programIdIndex} = instruction;
|
||||
const data = Array.from(bs58.decode(instruction.data));
|
||||
|
||||
let keyIndicesCount: number[] = [];
|
||||
shortvec.encodeLength(keyIndicesCount, accounts.length);
|
||||
|
||||
let dataCount: number[] = [];
|
||||
shortvec.encodeLength(dataCount, data.length);
|
||||
|
||||
return {
|
||||
programIdIndex,
|
||||
keyIndicesCount: Buffer.from(keyIndicesCount),
|
||||
keyIndices: accounts,
|
||||
dataLength: Buffer.from(dataCount),
|
||||
data,
|
||||
};
|
||||
});
|
||||
|
||||
let instructionCount: number[] = [];
|
||||
shortvec.encodeLength(instructionCount, instructions.length);
|
||||
let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);
|
||||
Buffer.from(instructionCount).copy(instructionBuffer);
|
||||
let instructionBufferLength = instructionCount.length;
|
||||
|
||||
instructions.forEach(instruction => {
|
||||
const instructionLayout = BufferLayout.struct<
|
||||
Readonly<{
|
||||
data: number[];
|
||||
dataLength: Uint8Array;
|
||||
keyIndices: number[];
|
||||
keyIndicesCount: Uint8Array;
|
||||
programIdIndex: number;
|
||||
}>
|
||||
>([
|
||||
BufferLayout.u8('programIdIndex'),
|
||||
|
||||
BufferLayout.blob(
|
||||
instruction.keyIndicesCount.length,
|
||||
'keyIndicesCount',
|
||||
),
|
||||
BufferLayout.seq(
|
||||
BufferLayout.u8('keyIndex'),
|
||||
instruction.keyIndices.length,
|
||||
'keyIndices',
|
||||
),
|
||||
BufferLayout.blob(instruction.dataLength.length, 'dataLength'),
|
||||
BufferLayout.seq(
|
||||
BufferLayout.u8('userdatum'),
|
||||
instruction.data.length,
|
||||
'data',
|
||||
),
|
||||
]);
|
||||
const length = instructionLayout.encode(
|
||||
instruction,
|
||||
instructionBuffer,
|
||||
instructionBufferLength,
|
||||
);
|
||||
instructionBufferLength += length;
|
||||
});
|
||||
instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
|
||||
|
||||
const signDataLayout = BufferLayout.struct<
|
||||
Readonly<{
|
||||
keyCount: Uint8Array;
|
||||
keys: Uint8Array[];
|
||||
numReadonlySignedAccounts: Uint8Array;
|
||||
numReadonlyUnsignedAccounts: Uint8Array;
|
||||
numRequiredSignatures: Uint8Array;
|
||||
recentBlockhash: Uint8Array;
|
||||
}>
|
||||
>([
|
||||
BufferLayout.blob(1, 'numRequiredSignatures'),
|
||||
BufferLayout.blob(1, 'numReadonlySignedAccounts'),
|
||||
BufferLayout.blob(1, 'numReadonlyUnsignedAccounts'),
|
||||
BufferLayout.blob(keyCount.length, 'keyCount'),
|
||||
BufferLayout.seq(Layout.publicKey('key'), numKeys, 'keys'),
|
||||
Layout.publicKey('recentBlockhash'),
|
||||
]);
|
||||
|
||||
const transaction = {
|
||||
numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),
|
||||
numReadonlySignedAccounts: Buffer.from([
|
||||
this.header.numReadonlySignedAccounts,
|
||||
]),
|
||||
numReadonlyUnsignedAccounts: Buffer.from([
|
||||
this.header.numReadonlyUnsignedAccounts,
|
||||
]),
|
||||
keyCount: Buffer.from(keyCount),
|
||||
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
||||
recentBlockhash: bs58.decode(this.recentBlockhash),
|
||||
};
|
||||
|
||||
let signData = Buffer.alloc(2048);
|
||||
const length = signDataLayout.encode(transaction, signData);
|
||||
instructionBuffer.copy(signData, length);
|
||||
return signData.slice(0, length + instructionBuffer.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a compiled message into a Message object.
|
||||
*/
|
||||
static from(buffer: Buffer | Uint8Array | Array<number>): Message {
|
||||
// Slice up wire data
|
||||
let byteArray = [...buffer];
|
||||
|
||||
const numRequiredSignatures = guardedShift(byteArray);
|
||||
if (
|
||||
numRequiredSignatures !==
|
||||
(numRequiredSignatures & VERSION_PREFIX_MASK)
|
||||
) {
|
||||
throw new Error(
|
||||
'Versioned messages must be deserialized with VersionedMessage.deserialize()',
|
||||
);
|
||||
}
|
||||
|
||||
const numReadonlySignedAccounts = guardedShift(byteArray);
|
||||
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
||||
|
||||
const accountCount = shortvec.decodeLength(byteArray);
|
||||
let accountKeys = [];
|
||||
for (let i = 0; i < accountCount; i++) {
|
||||
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
||||
accountKeys.push(new PublicKey(Buffer.from(account)));
|
||||
}
|
||||
|
||||
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
||||
|
||||
const instructionCount = shortvec.decodeLength(byteArray);
|
||||
let instructions: CompiledInstruction[] = [];
|
||||
for (let i = 0; i < instructionCount; i++) {
|
||||
const programIdIndex = guardedShift(byteArray);
|
||||
const accountCount = shortvec.decodeLength(byteArray);
|
||||
const accounts = guardedSplice(byteArray, 0, accountCount);
|
||||
const dataLength = shortvec.decodeLength(byteArray);
|
||||
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
||||
const data = bs58.encode(Buffer.from(dataSlice));
|
||||
instructions.push({
|
||||
programIdIndex,
|
||||
accounts,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
const messageArgs = {
|
||||
header: {
|
||||
numRequiredSignatures,
|
||||
numReadonlySignedAccounts,
|
||||
numReadonlyUnsignedAccounts,
|
||||
},
|
||||
recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),
|
||||
accountKeys,
|
||||
instructions,
|
||||
};
|
||||
|
||||
return new Message(messageArgs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./dist/utils";
|
||||
@@ -0,0 +1,59 @@
|
||||
declare module "node:test/reporters" {
|
||||
import { Transform, TransformOptions } from "node:stream";
|
||||
import { EventData } from "node:test";
|
||||
type TestEvent =
|
||||
| { type: "test:coverage"; data: EventData.TestCoverage }
|
||||
| { type: "test:complete"; data: EventData.TestComplete }
|
||||
| { type: "test:dequeue"; data: EventData.TestDequeue }
|
||||
| { type: "test:diagnostic"; data: EventData.TestDiagnostic }
|
||||
| { type: "test:enqueue"; data: EventData.TestEnqueue }
|
||||
| { type: "test:fail"; data: EventData.TestFail }
|
||||
| { type: "test:interrupted"; data: EventData.TestInterrupted }
|
||||
| { type: "test:pass"; data: EventData.TestPass }
|
||||
| { type: "test:plan"; data: EventData.TestPlan }
|
||||
| { type: "test:start"; data: EventData.TestStart }
|
||||
| { type: "test:stderr"; data: EventData.TestStderr }
|
||||
| { type: "test:stdout"; data: EventData.TestStdout }
|
||||
| { type: "test:summary"; data: EventData.TestSummary }
|
||||
| { type: "test:watch:drained"; data: undefined }
|
||||
| { type: "test:watch:restarted"; data: undefined };
|
||||
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
|
||||
new(...args: ConstructorParameters<T>): InstanceType<T>;
|
||||
(...args: ConstructorParameters<T>): InstanceType<T>;
|
||||
}
|
||||
/**
|
||||
* The `dot` reporter outputs the test results in a compact format,
|
||||
* where each passing test is represented by a `.`,
|
||||
* and each failing test is represented by a `X`.
|
||||
* @since v20.0.0
|
||||
*/
|
||||
function dot(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
||||
/**
|
||||
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
|
||||
* @since v20.0.0
|
||||
*/
|
||||
function tap(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
||||
class SpecReporter extends Transform {
|
||||
constructor();
|
||||
}
|
||||
/**
|
||||
* The `spec` reporter outputs the test results in a human-readable format.
|
||||
* @since v20.0.0
|
||||
*/
|
||||
const spec: ReporterConstructorWrapper<typeof SpecReporter>;
|
||||
/**
|
||||
* The `junit` reporter outputs test results in a jUnit XML format.
|
||||
* @since v21.0.0
|
||||
*/
|
||||
function junit(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
||||
class LcovReporter extends Transform {
|
||||
constructor(options?: Omit<TransformOptions, "writableObjectMode">);
|
||||
}
|
||||
/**
|
||||
* The `lcov` reporter outputs test coverage when used with the
|
||||
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--experimental-test-coverage) flag.
|
||||
* @since v22.0.0
|
||||
*/
|
||||
const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
|
||||
export { dot, junit, lcov, spec, tap, TestEvent };
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,574 @@
|
||||
import chalk from 'chalk';
|
||||
import { Command, InvalidArgumentError } from 'commander';
|
||||
|
||||
// src/cli.ts
|
||||
|
||||
// package.json
|
||||
var version = "2.3.0";
|
||||
|
||||
// src/context.ts
|
||||
function decodeEncodedContext(encodedContext) {
|
||||
const decodedUrlString = Buffer.from(encodedContext, "base64").toString("utf8") ;
|
||||
return Object.fromEntries(new URLSearchParams(decodedUrlString).entries());
|
||||
}
|
||||
|
||||
// src/codes.ts
|
||||
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
||||
var SOLANA_ERROR__INVALID_NONCE = 2;
|
||||
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 3;
|
||||
var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 4;
|
||||
var SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = 5;
|
||||
var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 6;
|
||||
var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 7;
|
||||
var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 8;
|
||||
var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 9;
|
||||
var SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR = 10;
|
||||
var SOLANA_ERROR__JSON_RPC__PARSE_ERROR = -32700;
|
||||
var SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = -32603;
|
||||
var SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = -32602;
|
||||
var SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND = -32601;
|
||||
var SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = -32600;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION = -32015;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET = -32014;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH = -32013;
|
||||
var SOLANA_ERROR__JSON_RPC__SCAN_ERROR = -32012;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE = -32011;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX = -32010;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED = -32009;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT = -32008;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED = -32007;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE = -32006;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY = -32005;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE = -32004;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE = -32003;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE = -32002;
|
||||
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP = -32001;
|
||||
var SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH = 28e5;
|
||||
var SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE = 2800001;
|
||||
var SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS = 2800002;
|
||||
var SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY = 2800003;
|
||||
var SOLANA_ERROR__ADDRESSES__MALFORMED_PDA = 2800004;
|
||||
var SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE = 2800005;
|
||||
var SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED = 2800006;
|
||||
var SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED = 2800007;
|
||||
var SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE = 2800008;
|
||||
var SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED = 2800009;
|
||||
var SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER = 2800010;
|
||||
var SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS = 2800011;
|
||||
var SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = 323e4;
|
||||
var SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND = 32300001;
|
||||
var SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT = 3230002;
|
||||
var SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = 3230003;
|
||||
var SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = 3230004;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = 361e4;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = 3610001;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = 3610002;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED = 3610003;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
|
||||
var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
|
||||
var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
|
||||
var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
|
||||
var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
|
||||
var SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH = 3704002;
|
||||
var SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704003;
|
||||
var SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY = 3704004;
|
||||
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
|
||||
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA = 4128001;
|
||||
var SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH = 4128002;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN = 4615e3;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR = 4615001;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT = 4615002;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA = 4615003;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA = 4615004;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL = 4615005;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS = 4615006;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID = 4615007;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE = 4615008;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED = 4615009;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT = 4615010;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION = 4615011;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID = 4615012;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE = 4615015;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED = 4615016;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX = 4615017;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED = 4615018;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED = 4615019;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED = 4615021;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE = 4615022;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED = 4615023;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 4615024;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM = 4615026;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR = 4615027;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED = 4615028;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE = 4615029;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID = 4615031;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH = 4615032;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT = 4615033;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED = 4615034;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4615035;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS = 4615036;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC = 4615037;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION = 4615039;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE = 4615041;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE = 4615042;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE = 4615043;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY = 4615044;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR = 4615045;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT = 4615046;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER = 4615047;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW = 4615048;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR = 4615049;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER = 4615050;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED = 4615052;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
|
||||
var SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
|
||||
var SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER = 5508001;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER = 5508002;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER = 5508005;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
|
||||
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
|
||||
var SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
|
||||
var SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
|
||||
var SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = 5508011;
|
||||
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
|
||||
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
|
||||
var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
|
||||
var SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = 5663003;
|
||||
var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = 5663004;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663005;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663006;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663007;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663008;
|
||||
var SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = 5663009;
|
||||
var SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = 5663010;
|
||||
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = 5663011;
|
||||
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = 5663012;
|
||||
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = 5663013;
|
||||
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = 5663014;
|
||||
var SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = 5663015;
|
||||
var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
|
||||
var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
|
||||
var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
|
||||
var SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = 5663020;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND = 7050003;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE = 7050006;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED = 7050007;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND = 7050008;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP = 7050009;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE = 7050010;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX = 7050011;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE = 7050012;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION = 7050013;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE = 7050014;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE = 7050015;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 7050016;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION = 7050018;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT = 7050019;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS = 7050022;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT = 7050027;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION = 7050030;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED = 7050034;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
|
||||
var SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION = 7050036;
|
||||
var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
|
||||
var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
|
||||
var SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH = 8078002;
|
||||
var SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH = 8078003;
|
||||
var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
|
||||
var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
|
||||
var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
|
||||
var SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = 8078007;
|
||||
var SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
|
||||
var SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT = 8078009;
|
||||
var SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT = 8078010;
|
||||
var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
|
||||
var SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = 8078012;
|
||||
var SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH = 8078013;
|
||||
var SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE = 8078014;
|
||||
var SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT = 8078015;
|
||||
var SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = 8078016;
|
||||
var SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE = 8078017;
|
||||
var SOLANA_ERROR__CODECS__INVALID_CONSTANT = 8078018;
|
||||
var SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE = 8078019;
|
||||
var SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL = 8078020;
|
||||
var SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = 8078021;
|
||||
var SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS = 8078022;
|
||||
var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
|
||||
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
|
||||
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
|
||||
var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
|
||||
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
|
||||
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
|
||||
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
|
||||
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
|
||||
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
|
||||
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
|
||||
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
|
||||
var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
|
||||
var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
|
||||
var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
|
||||
|
||||
// src/messages.ts
|
||||
var SolanaErrorMessages = {
|
||||
[SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
|
||||
[SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
|
||||
[SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT]: "Expected decoded account at address: $address",
|
||||
[SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT]: "Failed to decode account data at address: $address",
|
||||
[SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND]: "Accounts not found at addresses: $addresses",
|
||||
[SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED]: "Unable to find a viable program address bump seed.",
|
||||
[SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS]: "$putativeAddress is not a base58-encoded address.",
|
||||
[SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY]: "The `CryptoKey` must be an `Ed25519` public key.",
|
||||
[SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS]: "$putativeOffCurveAddress is not a base58-encoded off-curve address.",
|
||||
[SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE]: "Invalid seeds; point must fall off the Ed25519 curve.",
|
||||
[SOLANA_ERROR__ADDRESSES__MALFORMED_PDA]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
|
||||
[SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED]: "A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",
|
||||
[SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
|
||||
[SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
|
||||
[SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER]: "Program address cannot end with PDA marker.",
|
||||
[SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
|
||||
[SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY]: "Codec [$codecDescription] cannot decode empty byte arrays.",
|
||||
[SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS]: "Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",
|
||||
[SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL]: "Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",
|
||||
[SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
|
||||
[SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
|
||||
[SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH]: "Encoder and decoder must either both be fixed-size or variable-size.",
|
||||
[SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE]: "Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",
|
||||
[SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH]: "Expected a fixed-size codec, got a variable-size one.",
|
||||
[SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH]: "Codec [$codecDescription] expected a positive byte length, got $bytesLength.",
|
||||
[SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH]: "Expected a variable-size codec, got a fixed-size one.",
|
||||
[SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE]: "Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",
|
||||
[SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
|
||||
[SOLANA_ERROR__CODECS__INVALID_CONSTANT]: "Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",
|
||||
[SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT]: "Invalid discriminated union variant. Expected one of [$variants], got $value.",
|
||||
[SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT]: "Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",
|
||||
[SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT]: "Invalid literal union variant. Expected one of [$variants], got $value.",
|
||||
[SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS]: "Expected [$codecDescription] to have $expected items, got $actual.",
|
||||
[SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE]: "Invalid value $value for base $base with alphabet $alphabet.",
|
||||
[SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE]: "Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
|
||||
[SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
|
||||
[SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE]: "Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",
|
||||
[SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
|
||||
[SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
|
||||
[SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED]: "No random values implementation could be found.",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED]: "program other than the account's owner changed the size of the account data",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL]: "account data too small for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE]: "instruction expected an executable account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT]: "An account does not have enough lamports to be rent-exempt",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW]: "Program arithmetic overflowed",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR]: "Failed to serialize or deserialize account data: $encodedData",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS]: "Builtin programs must consume compute units",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH]: "Cross-program invocation call depth too deep",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED]: "Computational budget exceeded",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM]: "custom program error: #$code",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX]: "instruction contains duplicate accounts",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC]: "instruction modifications of multiply-passed account differ",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT]: "executable accounts must be rent exempt",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED]: "instruction changed executable accounts data",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE]: "instruction changed the balance of an executable account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED]: "instruction changed executable bit of an account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED]: "instruction modified data of an account it does not own",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND]: "instruction spent from the balance of an account it does not own",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR]: "generic instruction error",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER]: "Provided owner is not allowed",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE]: "Account is immutable",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY]: "Incorrect authority provided",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID]: "incorrect program id for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS]: "insufficient funds for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA]: "invalid account data for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER]: "Invalid account owner",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT]: "invalid program argument",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR]: "program returned invalid error code",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA]: "invalid instruction data",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC]: "Failed to reallocate account data",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS]: "Provided seeds do not result in a valid address",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED]: "Accounts data allocations exceeded the maximum allowed per transaction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED]: "Max accounts exceeded",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED]: "Max instruction trace length exceeded",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED]: "Length of the seed is too long for address generation",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT]: "An account required by the instruction is missing",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE]: "missing required signature for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID]: "instruction illegally modified the program id of an account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: "insufficient account keys for instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION]: "Cross-program invocation with unauthorized signer or writable account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE]: "Failed to create program execution environment",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE]: "Program failed to compile",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE]: "Program failed to complete",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED]: "instruction modified data of a read-only account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE]: "instruction changed the balance of a read-only account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED]: "Cross-program invocation reentrancy not allowed for this instruction",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED]: "instruction modified rent epoch of an account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION]: "sum of account balances before and after instruction do not match",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT]: "instruction requires an initialized account",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN]: "",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
|
||||
[SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
|
||||
[SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS]: "The instruction does not have any accounts.",
|
||||
[SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA]: "The instruction does not have any data.",
|
||||
[SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
|
||||
[SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
|
||||
[SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING]: "Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
||||
[SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED]: "Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",
|
||||
[SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
||||
[SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
||||
[SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE]: "Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
||||
[SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
|
||||
[SOLANA_ERROR__JSON_RPC__INVALID_PARAMS]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
|
||||
[SOLANA_ERROR__JSON_RPC__INVALID_REQUEST]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
|
||||
[SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND]: "JSON-RPC error: The method does not exist / is not available ($__serverMessage)",
|
||||
[SOLANA_ERROR__JSON_RPC__PARSE_ERROR]: "JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",
|
||||
[SOLANA_ERROR__JSON_RPC__SCAN_ERROR]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED]: "Minimum context slot has not been reached",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY]: "Node is unhealthy; behind by $numSlotsBehind slots",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT]: "No snapshot",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE]: "Transaction simulation failed",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE]: "Transaction history is not available from this node",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE]: "$__serverMessage",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH]: "Transaction signature length mismatch",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE]: "Transaction signature verification failure",
|
||||
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION]: "$__serverMessage",
|
||||
[SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH]: "Key pair bytes must be of length 64, got $byteLength.",
|
||||
[SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH]: "Expected private key bytes with length 32. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY]: "The provided private key does not match the provided public key.",
|
||||
[SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
|
||||
[SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE]: "Lamports value must be in the range [0, 2e64-1]",
|
||||
[SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
|
||||
[SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR]: "$message",
|
||||
[SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
|
||||
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
|
||||
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN]: "The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",
|
||||
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
|
||||
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED]: "WebSocket connection closed",
|
||||
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT]: "WebSocket failed to connect",
|
||||
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
|
||||
[SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD]: "Could not find an API plan for RPC method: `$method`",
|
||||
[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`.",
|
||||
[SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
|
||||
[SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
|
||||
[SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS]: "Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER]: "The provided value does not implement the `KeyPairSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER]: "The provided value does not implement the `MessageModifyingSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER]: "The provided value does not implement the `MessagePartialSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER]: "The provided value does not implement any of the `MessageSigner` interfaces",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER]: "The provided value does not implement the `TransactionModifyingSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER]: "The provided value does not implement the `TransactionPartialSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER]: "The provided value does not implement the `TransactionSendingSigner` interface",
|
||||
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER]: "The provided value does not implement any of the `TransactionSigner` interfaces",
|
||||
[SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
|
||||
[SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",
|
||||
[SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED]: "No signature verification implementation could be found.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
|
||||
[SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
|
||||
[SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED]: "This transaction has already been processed",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND]: "Blockhash not found",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED]: "ResanitizationNeeded",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN]: "The transaction failed with the error `$errorName`",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION]: "Transaction version is unsupported",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
|
||||
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
|
||||
[SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION]: "Attempted to sign a transaction with an address that is not a signer for it",
|
||||
[SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING]: "Transaction is missing an address at index: $index.",
|
||||
[SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES]: "Transaction has no expected signers therefore it cannot be encoded",
|
||||
[SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT]: "Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",
|
||||
[SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
|
||||
[SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE]: "Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT]: "Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",
|
||||
[SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT]: "Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",
|
||||
[SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
|
||||
[SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
|
||||
[SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
|
||||
[SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING]: "Transaction with no instructions cannot be durable nonce transaction.",
|
||||
[SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES]: "This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",
|
||||
[SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE]: "This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",
|
||||
[SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH]: "The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",
|
||||
[SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING]: "Transaction is missing signatures for addresses: $addresses.",
|
||||
[SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given"
|
||||
};
|
||||
|
||||
// src/message-formatter.ts
|
||||
var START_INDEX = "i";
|
||||
var TYPE = "t";
|
||||
function getHumanReadableErrorMessage(code, context = {}) {
|
||||
const messageFormatString = SolanaErrorMessages[code];
|
||||
if (messageFormatString.length === 0) {
|
||||
return "";
|
||||
}
|
||||
let state;
|
||||
function commitStateUpTo(endIndex) {
|
||||
if (state[TYPE] === 2 /* Variable */) {
|
||||
const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex);
|
||||
fragments.push(
|
||||
variableName in context ? (
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
`${context[variableName]}`
|
||||
) : `$${variableName}`
|
||||
);
|
||||
} else if (state[TYPE] === 1 /* Text */) {
|
||||
fragments.push(messageFormatString.slice(state[START_INDEX], endIndex));
|
||||
}
|
||||
}
|
||||
const fragments = [];
|
||||
messageFormatString.split("").forEach((char, ii) => {
|
||||
if (ii === 0) {
|
||||
state = {
|
||||
[START_INDEX]: 0,
|
||||
[TYPE]: messageFormatString[0] === "\\" ? 0 /* EscapeSequence */ : messageFormatString[0] === "$" ? 2 /* Variable */ : 1 /* Text */
|
||||
};
|
||||
return;
|
||||
}
|
||||
let nextState;
|
||||
switch (state[TYPE]) {
|
||||
case 0 /* EscapeSequence */:
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 1 /* Text */ };
|
||||
break;
|
||||
case 1 /* Text */:
|
||||
if (char === "\\") {
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 0 /* EscapeSequence */ };
|
||||
} else if (char === "$") {
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 2 /* Variable */ };
|
||||
}
|
||||
break;
|
||||
case 2 /* Variable */:
|
||||
if (char === "\\") {
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 0 /* EscapeSequence */ };
|
||||
} else if (char === "$") {
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 2 /* Variable */ };
|
||||
} else if (!char.match(/\w/)) {
|
||||
nextState = { [START_INDEX]: ii, [TYPE]: 1 /* Text */ };
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (nextState) {
|
||||
if (state !== nextState) {
|
||||
commitStateUpTo(ii);
|
||||
}
|
||||
state = nextState;
|
||||
}
|
||||
});
|
||||
commitStateUpTo();
|
||||
return fragments.join("");
|
||||
}
|
||||
|
||||
// src/cli.ts
|
||||
var program = new Command();
|
||||
program.name("@solana/errors").description("Decode Solana JavaScript errors thrown in production").version(version);
|
||||
program.command("decode").description("Decode a `SolanaErrorCode` to a human-readable message").argument("<code>", "numeric error code to decode", (rawCode) => {
|
||||
const code = parseInt(rawCode, 10);
|
||||
if (isNaN(code) || `${code}` !== rawCode) {
|
||||
throw new InvalidArgumentError("It must be an integer");
|
||||
}
|
||||
if (!(code in SolanaErrorMessages)) {
|
||||
throw new InvalidArgumentError("There exists no error with that code");
|
||||
}
|
||||
return code;
|
||||
}).argument("[encodedContext]", "encoded context to interpolate into the error message", (encodedContext) => {
|
||||
try {
|
||||
return decodeEncodedContext(encodedContext);
|
||||
} catch {
|
||||
throw new InvalidArgumentError("Encoded context malformed");
|
||||
}
|
||||
}).action((code, context) => {
|
||||
const message = getHumanReadableErrorMessage(code, context);
|
||||
console.log(`
|
||||
${chalk.bold(
|
||||
chalk.rgb(154, 71, 255)("[") + chalk.rgb(144, 108, 244)("D") + chalk.rgb(134, 135, 233)("e") + chalk.rgb(122, 158, 221)("c") + chalk.rgb(110, 178, 209)("o") + chalk.rgb(95, 195, 196)("d") + chalk.rgb(79, 212, 181)("e") + chalk.rgb(57, 227, 166)("d") + chalk.rgb(19, 241, 149)("]")
|
||||
) + chalk.rgb(19, 241, 149)(" Solana error code #" + code)}
|
||||
- ${message}`);
|
||||
if (context) {
|
||||
console.log(`
|
||||
${chalk.yellowBright(chalk.bold("[Context]"))}
|
||||
${JSON.stringify(context, null, 4).split("\n").join("\n ")}`);
|
||||
}
|
||||
});
|
||||
function run(argv) {
|
||||
program.parse(argv);
|
||||
}
|
||||
|
||||
export { run };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i64.d.ts","sourceRoot":"","sources":["../../src/i64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAO5F,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAMnF,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,WAAW,GAAI,SAAQ,iBAAsB,KAAG,cAAc,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CACxC,CAAC"}
|
||||
@@ -0,0 +1,6 @@
|
||||
//#region src/plugin/parallel-plugin-implementation.ts
|
||||
function defineParallelPluginImplementation(plugin) {
|
||||
return plugin;
|
||||
}
|
||||
//#endregion
|
||||
export { defineParallelPluginImplementation };
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_to_property_key.js";
|
||||
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
const isWin = process.platform === 'win32';
|
||||
|
||||
function notFoundError(original, syscall) {
|
||||
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
||||
code: 'ENOENT',
|
||||
errno: 'ENOENT',
|
||||
syscall: `${syscall} ${original.command}`,
|
||||
path: original.command,
|
||||
spawnargs: original.args,
|
||||
});
|
||||
}
|
||||
|
||||
function hookChildProcess(cp, parsed) {
|
||||
if (!isWin) {
|
||||
return;
|
||||
}
|
||||
|
||||
const originalEmit = cp.emit;
|
||||
|
||||
cp.emit = function (name, arg1) {
|
||||
// If emitting "exit" event and exit code is 1, we need to check if
|
||||
// the command exists and emit an "error" instead
|
||||
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
if (name === 'exit') {
|
||||
const err = verifyENOENT(arg1, parsed);
|
||||
|
||||
if (err) {
|
||||
return originalEmit.call(cp, 'error', err);
|
||||
}
|
||||
}
|
||||
|
||||
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
||||
};
|
||||
}
|
||||
|
||||
function verifyENOENT(status, parsed) {
|
||||
if (isWin && status === 1 && !parsed.file) {
|
||||
return notFoundError(parsed.original, 'spawn');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function verifyENOENTSync(status, parsed) {
|
||||
if (isWin && status === 1 && !parsed.file) {
|
||||
return notFoundError(parsed.original, 'spawnSync');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hookChildProcess,
|
||||
verifyENOENT,
|
||||
verifyENOENTSync,
|
||||
notFoundError,
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znaků", verb: "mít" },
|
||||
file: { unit: "bajtů", verb: "mít" },
|
||||
array: { unit: "prvků", verb: "mít" },
|
||||
set: { unit: "prvků", verb: "mít" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "regulární výraz",
|
||||
email: "e-mailová adresa",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "datum a čas ve formátu ISO",
|
||||
date: "datum ve formátu ISO",
|
||||
time: "čas ve formátu ISO",
|
||||
duration: "doba trvání ISO",
|
||||
ipv4: "IPv4 adresa",
|
||||
ipv6: "IPv6 adresa",
|
||||
cidrv4: "rozsah IPv4",
|
||||
cidrv6: "rozsah IPv6",
|
||||
base64: "řetězec zakódovaný ve formátu base64",
|
||||
base64url: "řetězec zakódovaný ve formátu base64url",
|
||||
json_string: "řetězec ve formátu JSON",
|
||||
e164: "číslo E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "vstup",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "číslo",
|
||||
string: "řetězec",
|
||||
function: "funkce",
|
||||
array: "pole",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Neplatný vstup: očekáváno instanceof ${issue.expected}, obdrženo ${received}`;
|
||||
}
|
||||
return `Neplatný vstup: očekáváno ${expected}, obdrženo ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Neplatný řetězec: musí končit na "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`;
|
||||
return `Neplatný formát ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Neplatné číslo: musí být násobkem ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Neplatný klíč v ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Neplatný vstup";
|
||||
case "invalid_element":
|
||||
return `Neplatná hodnota v ${issue.origin}`;
|
||||
default:
|
||||
return `Neplatný vstup`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user