WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/**
* SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
*
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
*
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
* @module
* @deprecated
*/
import {
SHA224 as SHA224n,
sha224 as sha224n,
SHA256 as SHA256n,
sha256 as sha256n,
} from './sha2.ts';
/** @deprecated Use import from `noble/hashes/sha2` module */
export const SHA256: typeof SHA256n = SHA256n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export const sha256: typeof sha256n = sha256n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export const SHA224: typeof SHA224n = SHA224n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export const sha224: typeof sha224n = sha224n;

View File

@@ -0,0 +1,18 @@
"use strict";
module.exports = function ({ ruleIds, language }) {
return `
The following rules do not support the language "${language}":
${ruleIds.map(id => `\t- "${id}"`).join("\n")}
To fix this error, either:
- Remove the rule from your configuration, or set its severity to "off".
- Use the "files" option to apply the rule only to files of the supported language, for example:
{
files: ["**/*.js"],
rules: { "${ruleIds[0]}": "error" }
}
See https://eslint.org/docs/latest/use/configure/rules for more information.
`.trimStart();
};

View File

@@ -0,0 +1,38 @@
{
"name": "ms",
"version": "2.1.3",
"description": "Tiny millisecond conversion utility",
"repository": "vercel/ms",
"main": "./index",
"files": [
"index.js"
],
"scripts": {
"precommit": "lint-staged",
"lint": "eslint lib/* bin/*",
"test": "mocha tests.js"
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
}
},
"lint-staged": {
"*.js": [
"npm run lint",
"prettier --single-quote --write",
"git add"
]
},
"license": "MIT",
"devDependencies": {
"eslint": "4.18.2",
"expect.js": "0.3.1",
"husky": "0.14.3",
"lint-staged": "5.0.0",
"mocha": "4.0.1",
"prettier": "2.0.5"
}
}

View File

@@ -0,0 +1,6 @@
function _tagged_template_literal(strings, raw) {
if (!raw) raw = strings.slice(0);
return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } }));
}
export { _tagged_template_literal as _ };

View File

@@ -0,0 +1,14 @@
{
"pkg": {
"assets": [
"../custom-worker.js",
"../to-file.js"
],
"targets": [
"node20",
"node22",
"node24"
],
"outputPath": "test/pkg"
}
}

View File

@@ -0,0 +1,116 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-literal-enum-member',
meta: {
type: 'suggestion',
docs: {
description: 'Require all enum members to be literal values',
recommended: 'strict',
requiresTypeChecking: false,
},
messages: {
notLiteral: `Explicit enum value must only be a literal value (string or number).`,
notLiteralOrBitwiseExpression: `Explicit enum value must only be a literal value (string or number) or a bitwise expression.`,
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
allowBitwiseExpressions: {
type: 'boolean',
description: 'Whether to allow using bitwise expressions in enum initializers.',
},
},
},
],
},
defaultOptions: [
{
allowBitwiseExpressions: false,
},
],
create(context, [{ allowBitwiseExpressions }]) {
function isIdentifierWithName(node, name) {
return node.type === utils_1.AST_NODE_TYPES.Identifier && node.name === name;
}
function hasEnumMember(decl, name) {
return decl.body.members.some(member => isIdentifierWithName(member.id, name) ||
(member.id.type === utils_1.AST_NODE_TYPES.Literal &&
(0, util_1.getStaticStringValue)(member.id) === name));
}
function isSelfEnumMember(decl, node) {
if (node.type === utils_1.AST_NODE_TYPES.Identifier) {
return hasEnumMember(decl, node.name);
}
if (node.type === utils_1.AST_NODE_TYPES.MemberExpression &&
isIdentifierWithName(node.object, decl.id.name)) {
if (node.property.type === utils_1.AST_NODE_TYPES.Identifier) {
return hasEnumMember(decl, node.property.name);
}
if (node.computed) {
const propertyName = (0, util_1.getStaticStringValue)(node.property);
if (propertyName) {
return hasEnumMember(decl, propertyName);
}
}
}
return false;
}
return {
TSEnumMember(node) {
// If there is no initializer, then this node is just the name of the member, so ignore.
if (node.initializer == null) {
return;
}
const declaration = node.parent.parent;
function isAllowedInitializerExpressionRecursive(node, partOfBitwiseComputation) {
// You can only refer to an enum member if it's part of a bitwise computation.
// so C = B isn't allowed (special case), but C = A | B is.
if (partOfBitwiseComputation && isSelfEnumMember(declaration, node)) {
return true;
}
switch (node.type) {
// any old literal
case utils_1.AST_NODE_TYPES.Literal:
return true;
// TemplateLiteral without expressions
case utils_1.AST_NODE_TYPES.TemplateLiteral:
return node.expressions.length === 0;
case utils_1.AST_NODE_TYPES.UnaryExpression:
// +123, -123, etc.
if (['-', '+'].includes(node.operator)) {
return isAllowedInitializerExpressionRecursive(node.argument, partOfBitwiseComputation);
}
if (allowBitwiseExpressions) {
return (node.operator === '~' &&
isAllowedInitializerExpressionRecursive(node.argument, true));
}
return false;
case utils_1.AST_NODE_TYPES.BinaryExpression:
if (allowBitwiseExpressions) {
return (['&', '^', '<<', '>>', '>>>', '|'].includes(node.operator) &&
isAllowedInitializerExpressionRecursive(node.left, true) &&
isAllowedInitializerExpressionRecursive(node.right, true));
}
return false;
default:
return false;
}
}
if (isAllowedInitializerExpressionRecursive(node.initializer, false)) {
return;
}
context.report({
node: node.id,
messageId: allowBitwiseExpressions
? 'notLiteralOrBitwiseExpression'
: 'notLiteral',
});
},
};
},
});

View File

@@ -0,0 +1,425 @@
/**
* @fileoverview Rule to flag statements without curly braces
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description:
"Enforce consistent brace style for all control statements",
recommended: false,
frozen: true,
url: "https://eslint.org/docs/latest/rules/curly",
},
schema: {
anyOf: [
{
type: "array",
items: [
{
enum: ["all"],
},
],
minItems: 0,
maxItems: 1,
},
{
type: "array",
items: [
{
enum: ["multi", "multi-line", "multi-or-nest"],
},
{
enum: ["consistent"],
},
],
minItems: 0,
maxItems: 2,
},
],
},
defaultOptions: ["all"],
fixable: "code",
messages: {
missingCurlyAfter: "Expected { after '{{name}}'.",
missingCurlyAfterCondition:
"Expected { after '{{name}}' condition.",
unexpectedCurlyAfter: "Unnecessary { after '{{name}}'.",
unexpectedCurlyAfterCondition:
"Unnecessary { after '{{name}}' condition.",
},
},
create(context) {
const multiOnly = context.options[0] === "multi";
const multiLine = context.options[0] === "multi-line";
const multiOrNest = context.options[0] === "multi-or-nest";
const consistent = context.options[1] === "consistent";
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
/**
* Determines if a given node is a one-liner that's on the same line as it's preceding code.
* @param {ASTNode} node The node to check.
* @returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code.
* @private
*/
function isCollapsedOneLiner(node) {
const before = sourceCode.getTokenBefore(node);
const last = sourceCode.getLastToken(node);
const lastExcludingSemicolon = astUtils.isSemicolonToken(last)
? sourceCode.getTokenBefore(last)
: last;
return (
before.loc.start.line === lastExcludingSemicolon.loc.end.line
);
}
/**
* Determines if a given node is a one-liner.
* @param {ASTNode} node The node to check.
* @returns {boolean} True if the node is a one-liner.
* @private
*/
function isOneLiner(node) {
if (node.type === "EmptyStatement") {
return true;
}
const first = sourceCode.getFirstToken(node);
const last = sourceCode.getLastToken(node);
const lastExcludingSemicolon = astUtils.isSemicolonToken(last)
? sourceCode.getTokenBefore(last)
: last;
return first.loc.start.line === lastExcludingSemicolon.loc.end.line;
}
/**
* Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError.
* @param {Token} closingBracket The } token
* @returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block.
*/
function needsSemicolon(closingBracket) {
const tokenBefore = sourceCode.getTokenBefore(closingBracket);
const tokenAfter = sourceCode.getTokenAfter(closingBracket);
const lastBlockNode = sourceCode.getNodeByRangeIndex(
tokenBefore.range[0],
);
if (astUtils.isSemicolonToken(tokenBefore)) {
// If the last statement already has a semicolon, don't add another one.
return false;
}
if (!tokenAfter) {
// If there are no statements after this block, there is no need to add a semicolon.
return false;
}
if (
lastBlockNode.type === "BlockStatement" &&
lastBlockNode.parent.type !== "FunctionExpression" &&
lastBlockNode.parent.type !== "ArrowFunctionExpression"
) {
/*
* If the last node surrounded by curly brackets is a BlockStatement (other than a FunctionExpression or an ArrowFunctionExpression),
* don't insert a semicolon. Otherwise, the semicolon would be parsed as a separate statement, which would cause
* a SyntaxError if it was followed by `else`.
*/
return false;
}
if (tokenBefore.loc.end.line === tokenAfter.loc.start.line) {
// If the next token is on the same line, insert a semicolon.
return true;
}
if (/^[([/`+-]/u.test(tokenAfter.value)) {
// If the next token starts with a character that would disrupt ASI, insert a semicolon.
return true;
}
if (
tokenBefore.type === "Punctuator" &&
(tokenBefore.value === "++" || tokenBefore.value === "--")
) {
// If the last token is ++ or --, insert a semicolon to avoid disrupting ASI.
return true;
}
// Otherwise, do not insert a semicolon.
return false;
}
/**
* Prepares to check the body of a node to see if it's a block statement.
* @param {ASTNode} node The node to report if there's a problem.
* @param {ASTNode} body The body node to check for blocks.
* @param {string} name The name to report if there's a problem.
* @param {{ condition: boolean }} opts Options to pass to the report functions
* @returns {Object} a prepared check object, with "actual", "expected", "check" properties.
* "actual" will be `true` or `false` whether the body is already a block statement.
* "expected" will be `true` or `false` if the body should be a block statement or not, or
* `null` if it doesn't matter, depending on the rule options. It can be modified to change
* the final behavior of "check".
* "check" will be a function reporting appropriate problems depending on the other
* properties.
*/
function prepareCheck(node, body, name, opts) {
const hasBlock = body.type === "BlockStatement";
let expected = null;
if (
hasBlock &&
(body.body.length !== 1 ||
astUtils.areBracesNecessary(body, sourceCode))
) {
expected = true;
} else if (multiOnly) {
expected = false;
} else if (multiLine) {
if (!isCollapsedOneLiner(body)) {
expected = true;
}
// otherwise, the body is allowed to have braces or not to have braces
} else if (multiOrNest) {
if (hasBlock) {
const statement = body.body[0];
const leadingCommentsInBlock =
sourceCode.getCommentsBefore(statement);
expected =
!isOneLiner(statement) ||
leadingCommentsInBlock.length > 0;
} else {
expected = !isOneLiner(body);
}
} else {
// default "all"
expected = true;
}
return {
actual: hasBlock,
expected,
check() {
if (
this.expected !== null &&
this.expected !== this.actual
) {
if (this.expected) {
context.report({
node,
loc: body.loc,
messageId:
opts && opts.condition
? "missingCurlyAfterCondition"
: "missingCurlyAfter",
data: {
name,
},
fix: fixer =>
fixer.replaceText(
body,
`{${sourceCode.getText(body)}}`,
),
});
} else {
context.report({
node,
loc: body.loc,
messageId:
opts && opts.condition
? "unexpectedCurlyAfterCondition"
: "unexpectedCurlyAfter",
data: {
name,
},
fix(fixer) {
/*
* `do while` expressions sometimes need a space to be inserted after `do`.
* e.g. `do{foo()} while (bar)` should be corrected to `do foo() while (bar)`
*/
const needsPrecedingSpace =
node.type === "DoWhileStatement" &&
sourceCode.getTokenBefore(body)
.range[1] === body.range[0] &&
!astUtils.canTokensBeAdjacent(
"do",
sourceCode.getFirstToken(body, {
skip: 1,
}),
);
const openingBracket =
sourceCode.getFirstToken(body);
const closingBracket =
sourceCode.getLastToken(body);
const lastTokenInBlock =
sourceCode.getTokenBefore(
closingBracket,
);
if (needsSemicolon(closingBracket)) {
/*
* If removing braces would cause a SyntaxError due to multiple statements on the same line (or
* change the semantics of the code due to ASI), don't perform a fix.
*/
return null;
}
const resultingBodyText =
sourceCode
.getText()
.slice(
openingBracket.range[1],
lastTokenInBlock.range[0],
) +
sourceCode.getText(lastTokenInBlock) +
sourceCode
.getText()
.slice(
lastTokenInBlock.range[1],
closingBracket.range[0],
);
return fixer.replaceText(
body,
(needsPrecedingSpace ? " " : "") +
resultingBodyText,
);
},
});
}
}
},
};
}
/**
* Prepares to check the bodies of a "if", "else if" and "else" chain.
* @param {ASTNode} node The first IfStatement node of the chain.
* @returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more
* information.
*/
function prepareIfChecks(node) {
const preparedChecks = [];
for (
let currentNode = node;
currentNode;
currentNode = currentNode.alternate
) {
preparedChecks.push(
prepareCheck(currentNode, currentNode.consequent, "if", {
condition: true,
}),
);
if (
currentNode.alternate &&
currentNode.alternate.type !== "IfStatement"
) {
preparedChecks.push(
prepareCheck(
currentNode,
currentNode.alternate,
"else",
),
);
break;
}
}
if (consistent) {
/*
* If any node should have or already have braces, make sure they
* all have braces.
* If all nodes shouldn't have braces, make sure they don't.
*/
const expected = preparedChecks.some(preparedCheck => {
if (preparedCheck.expected !== null) {
return preparedCheck.expected;
}
return preparedCheck.actual;
});
preparedChecks.forEach(preparedCheck => {
preparedCheck.expected = expected;
});
}
return preparedChecks;
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
IfStatement(node) {
const parent = node.parent;
const isElseIf =
parent.type === "IfStatement" && parent.alternate === node;
if (!isElseIf) {
// This is a top `if`, check the whole `if-else-if` chain
prepareIfChecks(node).forEach(preparedCheck => {
preparedCheck.check();
});
}
// Skip `else if`, it's already checked (when the top `if` was visited)
},
WhileStatement(node) {
prepareCheck(node, node.body, "while", {
condition: true,
}).check();
},
DoWhileStatement(node) {
prepareCheck(node, node.body, "do").check();
},
ForStatement(node) {
prepareCheck(node, node.body, "for", {
condition: true,
}).check();
},
ForInStatement(node) {
prepareCheck(node, node.body, "for-in").check();
},
ForOfStatement(node) {
prepareCheck(node, node.body, "for-of").check();
},
};
},
};

View File

@@ -0,0 +1,586 @@
import * as BufferLayout from '@solana/buffer-layout';
import {
encodeData,
decodeData,
InstructionType,
IInstructionInputData,
} from '../instruction';
import * as Layout from '../layout';
import {PublicKey} from '../publickey';
import {SystemProgram} from './system';
import {SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar';
import {Transaction, TransactionInstruction} from '../transaction';
import {toBuffer} from '../utils/to-buffer';
/**
* Vote account info
*/
export class VoteInit {
nodePubkey: PublicKey;
authorizedVoter: PublicKey;
authorizedWithdrawer: PublicKey;
commission: number; /** [0, 100] */
constructor(
nodePubkey: PublicKey,
authorizedVoter: PublicKey,
authorizedWithdrawer: PublicKey,
commission: number,
) {
this.nodePubkey = nodePubkey;
this.authorizedVoter = authorizedVoter;
this.authorizedWithdrawer = authorizedWithdrawer;
this.commission = commission;
}
}
/**
* Create vote account transaction params
*/
export type CreateVoteAccountParams = {
fromPubkey: PublicKey;
votePubkey: PublicKey;
voteInit: VoteInit;
lamports: number;
};
/**
* InitializeAccount instruction params
*/
export type InitializeAccountParams = {
votePubkey: PublicKey;
nodePubkey: PublicKey;
voteInit: VoteInit;
};
/**
* Authorize instruction params
*/
export type AuthorizeVoteParams = {
votePubkey: PublicKey;
/** Current vote or withdraw authority, depending on `voteAuthorizationType` */
authorizedPubkey: PublicKey;
newAuthorizedPubkey: PublicKey;
voteAuthorizationType: VoteAuthorizationType;
};
/**
* AuthorizeWithSeed instruction params
*/
export type AuthorizeVoteWithSeedParams = {
currentAuthorityDerivedKeyBasePubkey: PublicKey;
currentAuthorityDerivedKeyOwnerPubkey: PublicKey;
currentAuthorityDerivedKeySeed: string;
newAuthorizedPubkey: PublicKey;
voteAuthorizationType: VoteAuthorizationType;
votePubkey: PublicKey;
};
/**
* Withdraw from vote account transaction params
*/
export type WithdrawFromVoteAccountParams = {
votePubkey: PublicKey;
authorizedWithdrawerPubkey: PublicKey;
lamports: number;
toPubkey: PublicKey;
};
/**
* Update validator identity (node pubkey) vote account instruction params.
*/
export type UpdateValidatorIdentityParams = {
votePubkey: PublicKey;
authorizedWithdrawerPubkey: PublicKey;
nodePubkey: PublicKey;
};
/**
* Vote Instruction class
*/
export class VoteInstruction {
/**
* @internal
*/
constructor() {}
/**
* Decode a vote instruction and retrieve the instruction type.
*/
static decodeInstructionType(
instruction: TransactionInstruction,
): VoteInstructionType {
this.checkProgramId(instruction.programId);
const instructionTypeLayout = BufferLayout.u32('instruction');
const typeIndex = instructionTypeLayout.decode(instruction.data);
let type: VoteInstructionType | undefined;
for (const [ixType, layout] of Object.entries(VOTE_INSTRUCTION_LAYOUTS)) {
if (layout.index == typeIndex) {
type = ixType as VoteInstructionType;
break;
}
}
if (!type) {
throw new Error('Instruction type incorrect; not a VoteInstruction');
}
return type;
}
/**
* Decode an initialize vote instruction and retrieve the instruction params.
*/
static decodeInitializeAccount(
instruction: TransactionInstruction,
): InitializeAccountParams {
this.checkProgramId(instruction.programId);
this.checkKeyLength(instruction.keys, 4);
const {voteInit} = decodeData(
VOTE_INSTRUCTION_LAYOUTS.InitializeAccount,
instruction.data,
);
return {
votePubkey: instruction.keys[0].pubkey,
nodePubkey: instruction.keys[3].pubkey,
voteInit: new VoteInit(
new PublicKey(voteInit.nodePubkey),
new PublicKey(voteInit.authorizedVoter),
new PublicKey(voteInit.authorizedWithdrawer),
voteInit.commission,
),
};
}
/**
* Decode an authorize instruction and retrieve the instruction params.
*/
static decodeAuthorize(
instruction: TransactionInstruction,
): AuthorizeVoteParams {
this.checkProgramId(instruction.programId);
this.checkKeyLength(instruction.keys, 3);
const {newAuthorized, voteAuthorizationType} = decodeData(
VOTE_INSTRUCTION_LAYOUTS.Authorize,
instruction.data,
);
return {
votePubkey: instruction.keys[0].pubkey,
authorizedPubkey: instruction.keys[2].pubkey,
newAuthorizedPubkey: new PublicKey(newAuthorized),
voteAuthorizationType: {
index: voteAuthorizationType,
},
};
}
/**
* Decode an authorize instruction and retrieve the instruction params.
*/
static decodeAuthorizeWithSeed(
instruction: TransactionInstruction,
): AuthorizeVoteWithSeedParams {
this.checkProgramId(instruction.programId);
this.checkKeyLength(instruction.keys, 3);
const {
voteAuthorizeWithSeedArgs: {
currentAuthorityDerivedKeyOwnerPubkey,
currentAuthorityDerivedKeySeed,
newAuthorized,
voteAuthorizationType,
},
} = decodeData(
VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed,
instruction.data,
);
return {
currentAuthorityDerivedKeyBasePubkey: instruction.keys[2].pubkey,
currentAuthorityDerivedKeyOwnerPubkey: new PublicKey(
currentAuthorityDerivedKeyOwnerPubkey,
),
currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,
newAuthorizedPubkey: new PublicKey(newAuthorized),
voteAuthorizationType: {
index: voteAuthorizationType,
},
votePubkey: instruction.keys[0].pubkey,
};
}
/**
* Decode a withdraw instruction and retrieve the instruction params.
*/
static decodeWithdraw(
instruction: TransactionInstruction,
): WithdrawFromVoteAccountParams {
this.checkProgramId(instruction.programId);
this.checkKeyLength(instruction.keys, 3);
const {lamports} = decodeData(
VOTE_INSTRUCTION_LAYOUTS.Withdraw,
instruction.data,
);
return {
votePubkey: instruction.keys[0].pubkey,
authorizedWithdrawerPubkey: instruction.keys[2].pubkey,
lamports,
toPubkey: instruction.keys[1].pubkey,
};
}
/**
* @internal
*/
static checkProgramId(programId: PublicKey) {
if (!programId.equals(VoteProgram.programId)) {
throw new Error('invalid instruction; programId is not VoteProgram');
}
}
/**
* @internal
*/
static checkKeyLength(keys: Array<any>, expectedLength: number) {
if (keys.length < expectedLength) {
throw new Error(
`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,
);
}
}
}
/**
* An enumeration of valid VoteInstructionType's
*/
export type VoteInstructionType =
// FIXME
// It would be preferable for this type to be `keyof VoteInstructionInputData`
// but Typedoc does not transpile `keyof` expressions.
// See https://github.com/TypeStrong/typedoc/issues/1894
| 'Authorize'
| 'AuthorizeWithSeed'
| 'InitializeAccount'
| 'Withdraw'
| 'UpdateValidatorIdentity';
/** @internal */
export type VoteAuthorizeWithSeedArgs = Readonly<{
currentAuthorityDerivedKeyOwnerPubkey: Uint8Array;
currentAuthorityDerivedKeySeed: string;
newAuthorized: Uint8Array;
voteAuthorizationType: number;
}>;
type VoteInstructionInputData = {
Authorize: IInstructionInputData & {
newAuthorized: Uint8Array;
voteAuthorizationType: number;
};
AuthorizeWithSeed: IInstructionInputData & {
voteAuthorizeWithSeedArgs: VoteAuthorizeWithSeedArgs;
};
InitializeAccount: IInstructionInputData & {
voteInit: Readonly<{
authorizedVoter: Uint8Array;
authorizedWithdrawer: Uint8Array;
commission: number;
nodePubkey: Uint8Array;
}>;
};
Withdraw: IInstructionInputData & {
lamports: number;
};
UpdateValidatorIdentity: IInstructionInputData;
};
const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
[Instruction in VoteInstructionType]: InstructionType<
VoteInstructionInputData[Instruction]
>;
}>({
InitializeAccount: {
index: 0,
layout: BufferLayout.struct<VoteInstructionInputData['InitializeAccount']>([
BufferLayout.u32('instruction'),
Layout.voteInit(),
]),
},
Authorize: {
index: 1,
layout: BufferLayout.struct<VoteInstructionInputData['Authorize']>([
BufferLayout.u32('instruction'),
Layout.publicKey('newAuthorized'),
BufferLayout.u32('voteAuthorizationType'),
]),
},
Withdraw: {
index: 3,
layout: BufferLayout.struct<VoteInstructionInputData['Withdraw']>([
BufferLayout.u32('instruction'),
BufferLayout.ns64('lamports'),
]),
},
UpdateValidatorIdentity: {
index: 4,
layout: BufferLayout.struct<
VoteInstructionInputData['UpdateValidatorIdentity']
>([BufferLayout.u32('instruction')]),
},
AuthorizeWithSeed: {
index: 10,
layout: BufferLayout.struct<VoteInstructionInputData['AuthorizeWithSeed']>([
BufferLayout.u32('instruction'),
Layout.voteAuthorizeWithSeedArgs(),
]),
},
});
/**
* VoteAuthorize type
*/
export type VoteAuthorizationType = {
/** The VoteAuthorize index (from solana-vote-program) */
index: number;
};
/**
* An enumeration of valid VoteAuthorization layouts.
*/
export const VoteAuthorizationLayout = Object.freeze({
Voter: {
index: 0,
},
Withdrawer: {
index: 1,
},
});
/**
* Factory class for transactions to interact with the Vote program
*/
export class VoteProgram {
/**
* @internal
*/
constructor() {}
/**
* Public key that identifies the Vote program
*/
static programId: PublicKey = new PublicKey(
'Vote111111111111111111111111111111111111111',
);
/**
* Max space of a Vote account
*
* This is generated from the solana-vote-program VoteState struct as
* `VoteState::size_of()`:
* https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
*
* KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342
*/
static space: number = 3762;
/**
* Generate an Initialize instruction.
*/
static initializeAccount(
params: InitializeAccountParams,
): TransactionInstruction {
const {votePubkey, nodePubkey, voteInit} = params;
const type = VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;
const data = encodeData(type, {
voteInit: {
nodePubkey: toBuffer(voteInit.nodePubkey.toBuffer()),
authorizedVoter: toBuffer(voteInit.authorizedVoter.toBuffer()),
authorizedWithdrawer: toBuffer(
voteInit.authorizedWithdrawer.toBuffer(),
),
commission: voteInit.commission,
},
});
const instructionData = {
keys: [
{pubkey: votePubkey, isSigner: false, isWritable: true},
{pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},
{pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
{pubkey: nodePubkey, isSigner: true, isWritable: false},
],
programId: this.programId,
data,
};
return new TransactionInstruction(instructionData);
}
/**
* Generate a transaction that creates a new Vote account.
*/
static createAccount(params: CreateVoteAccountParams): Transaction {
const transaction = new Transaction();
transaction.add(
SystemProgram.createAccount({
fromPubkey: params.fromPubkey,
newAccountPubkey: params.votePubkey,
lamports: params.lamports,
space: this.space,
programId: this.programId,
}),
);
return transaction.add(
this.initializeAccount({
votePubkey: params.votePubkey,
nodePubkey: params.voteInit.nodePubkey,
voteInit: params.voteInit,
}),
);
}
/**
* Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
*/
static authorize(params: AuthorizeVoteParams): Transaction {
const {
votePubkey,
authorizedPubkey,
newAuthorizedPubkey,
voteAuthorizationType,
} = params;
const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
const data = encodeData(type, {
newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
voteAuthorizationType: voteAuthorizationType.index,
});
const keys = [
{pubkey: votePubkey, isSigner: false, isWritable: true},
{pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
{pubkey: authorizedPubkey, isSigner: true, isWritable: false},
];
return new Transaction().add({
keys,
programId: this.programId,
data,
});
}
/**
* Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
* where the current Voter or Withdrawer authority is a derived key.
*/
static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction {
const {
currentAuthorityDerivedKeyBasePubkey,
currentAuthorityDerivedKeyOwnerPubkey,
currentAuthorityDerivedKeySeed,
newAuthorizedPubkey,
voteAuthorizationType,
votePubkey,
} = params;
const type = VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;
const data = encodeData(type, {
voteAuthorizeWithSeedArgs: {
currentAuthorityDerivedKeyOwnerPubkey: toBuffer(
currentAuthorityDerivedKeyOwnerPubkey.toBuffer(),
),
currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,
newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
voteAuthorizationType: voteAuthorizationType.index,
},
});
const keys = [
{pubkey: votePubkey, isSigner: false, isWritable: true},
{pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
{
pubkey: currentAuthorityDerivedKeyBasePubkey,
isSigner: true,
isWritable: false,
},
];
return new Transaction().add({
keys,
programId: this.programId,
data,
});
}
/**
* Generate a transaction to withdraw from a Vote account.
*/
static withdraw(params: WithdrawFromVoteAccountParams): Transaction {
const {votePubkey, authorizedWithdrawerPubkey, lamports, toPubkey} = params;
const type = VOTE_INSTRUCTION_LAYOUTS.Withdraw;
const data = encodeData(type, {lamports});
const keys = [
{pubkey: votePubkey, isSigner: false, isWritable: true},
{pubkey: toPubkey, isSigner: false, isWritable: true},
{pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
];
return new Transaction().add({
keys,
programId: this.programId,
data,
});
}
/**
* Generate a transaction to withdraw safely from a Vote account.
*
* This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
* checks that the withdraw amount will not exceed the specified balance while leaving enough left
* to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
* `withdraw` method directly.
*/
static safeWithdraw(
params: WithdrawFromVoteAccountParams,
currentVoteAccountBalance: number,
rentExemptMinimum: number,
): Transaction {
if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
throw new Error(
'Withdraw will leave vote account with insufficient funds.',
);
}
return VoteProgram.withdraw(params);
}
/**
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
*/
static updateValidatorIdentity(
params: UpdateValidatorIdentityParams,
): Transaction {
const {votePubkey, authorizedWithdrawerPubkey, nodePubkey} = params;
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
const data = encodeData(type);
const keys = [
{pubkey: votePubkey, isSigner: false, isWritable: true},
{pubkey: nodePubkey, isSigner: true, isWritable: false},
{pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
];
return new Transaction().add({
keys,
programId: this.programId,
data,
});
}
}

View File

@@ -0,0 +1,20 @@
import { unsafeStringify } from './stringify.js';
import v1 from './v1.js';
import v1ToV6 from './v1ToV6.js';
function v6(options, buf, offset) {
options ??= {};
offset ??= 0;
let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
bytes = v1ToV6(bytes);
if (buf) {
if (offset < 0 || offset + 16 > buf.length) {
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
}
for (let i = 0; i < 16; i++) {
buf[offset + i] = bytes[i];
}
return buf;
}
return unsafeStringify(bytes);
}
export default v6;

View File

@@ -0,0 +1,2 @@
import type { LibDefinition } from '../variable';
export declare const esnext_temporal: LibDefinition;

View File

@@ -0,0 +1 @@
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":";;;AAoCa,QAAA,aAAa,GAAmB;IAC3C,IAAI,EAAE,eAAe;IACrB,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P,OAAO,CAAoB;QAE7B,SAAI,GAAG,QAAQ,CAAA;IAD5B,CAAC;CAkBL;AAtBD,sCAsBC"}

View File

@@ -0,0 +1,24 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference lib="es2023" />
/// <reference lib="es2024.arraybuffer" />
/// <reference lib="es2024.collection" />
/// <reference lib="es2024.object" />
/// <reference lib="es2024.promise" />
/// <reference lib="es2024.regexp" />
/// <reference lib="es2024.sharedmemory" />
/// <reference lib="es2024.string" />

View File

@@ -0,0 +1,117 @@
/*
Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
var estraverse = require('estraverse');
function isNode(node) {
if (node == null) {
return false;
}
return typeof node === 'object' && typeof node.type === 'string';
}
function isProperty(nodeType, key) {
return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
}
function Visitor(visitor, options) {
options = options || {};
this.__visitor = visitor || this;
this.__childVisitorKeys = options.childVisitorKeys
? Object.assign({}, estraverse.VisitorKeys, options.childVisitorKeys)
: estraverse.VisitorKeys;
if (options.fallback === 'iteration') {
this.__fallback = Object.keys;
} else if (typeof options.fallback === 'function') {
this.__fallback = options.fallback;
}
}
/* Default method for visiting children.
* When you need to call default visiting operation inside custom visiting
* operation, you can use it with `this.visitChildren(node)`.
*/
Visitor.prototype.visitChildren = function (node) {
var type, children, i, iz, j, jz, child;
if (node == null) {
return;
}
type = node.type || estraverse.Syntax.Property;
children = this.__childVisitorKeys[type];
if (!children) {
if (this.__fallback) {
children = this.__fallback(node);
} else {
throw new Error('Unknown node type ' + type + '.');
}
}
for (i = 0, iz = children.length; i < iz; ++i) {
child = node[children[i]];
if (child) {
if (Array.isArray(child)) {
for (j = 0, jz = child.length; j < jz; ++j) {
if (child[j]) {
if (isNode(child[j]) || isProperty(type, children[i])) {
this.visit(child[j]);
}
}
}
} else if (isNode(child)) {
this.visit(child);
}
}
}
};
/* Dispatching node. */
Visitor.prototype.visit = function (node) {
var type;
if (node == null) {
return;
}
type = node.type || estraverse.Syntax.Property;
if (this.__visitor[type]) {
this.__visitor[type].call(this, node);
return;
}
this.visitChildren(node);
};
exports.version = require('./package.json').version;
exports.Visitor = Visitor;
exports.visit = function (node, visitor, options) {
var v = new Visitor(visitor, options);
v.visit(node);
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */

View File

@@ -0,0 +1 @@
{"version":3,"file":"completionItemKind.enum.d.ts","sourceRoot":"","sources":["../../src/enums/completionItemKind.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,kBAAkB;IAC1B,IAAI,IAAI;IACR,MAAM,IAAI;IACV,QAAQ,IAAI;IACZ,WAAW,IAAI;IACf,KAAK,IAAI;IACT,QAAQ,IAAI;IACZ,KAAK,IAAI;IACT,SAAS,IAAI;IACb,MAAM,IAAI;IACV,QAAQ,KAAK;IACb,IAAI,KAAK;IACT,KAAK,KAAK;IACV,IAAI,KAAK;IACT,OAAO,KAAK;IACZ,OAAO,KAAK;IACZ,KAAK,KAAK;IACV,IAAI,KAAK;IACT,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,KAAK;IACf,QAAQ,KAAK;IACb,MAAM,KAAK;IACX,KAAK,KAAK;IACV,QAAQ,KAAK;IACb,aAAa,KAAK;CACrB"}

View File

@@ -0,0 +1,2 @@
import type { LibDefinition } from '../variable';
export declare const es2018_regexp: LibDefinition;

View File

@@ -0,0 +1,327 @@
// Generated by LiveScript 1.6.0
(function(){
var parsedTypeCheck, types, toString$ = {}.toString;
parsedTypeCheck = require('type-check').parsedTypeCheck;
types = {
'*': function(value, options){
switch (toString$.call(value).slice(8, -1)) {
case 'Array':
return typeCast(value, {
type: 'Array'
}, options);
case 'Object':
return typeCast(value, {
type: 'Object'
}, options);
default:
return {
type: 'Just',
value: typesCast(value, [
{
type: 'Undefined'
}, {
type: 'Null'
}, {
type: 'NaN'
}, {
type: 'Boolean'
}, {
type: 'Number'
}, {
type: 'Date'
}, {
type: 'RegExp'
}, {
type: 'Array'
}, {
type: 'Object'
}, {
type: 'String'
}
], (options.explicit = true, options))
};
}
},
Undefined: function(it){
if (it === 'undefined' || it === void 8) {
return {
type: 'Just',
value: void 8
};
} else {
return {
type: 'Nothing'
};
}
},
Null: function(it){
if (it === 'null') {
return {
type: 'Just',
value: null
};
} else {
return {
type: 'Nothing'
};
}
},
NaN: function(it){
if (it === 'NaN') {
return {
type: 'Just',
value: NaN
};
} else {
return {
type: 'Nothing'
};
}
},
Boolean: function(it){
if (it === 'true') {
return {
type: 'Just',
value: true
};
} else if (it === 'false') {
return {
type: 'Just',
value: false
};
} else {
return {
type: 'Nothing'
};
}
},
Number: function(it){
return {
type: 'Just',
value: +it
};
},
Int: function(it){
return {
type: 'Just',
value: +it
};
},
Float: function(it){
return {
type: 'Just',
value: +it
};
},
Date: function(value, options){
var that;
if (that = /^\#([\s\S]*)\#$/.exec(value)) {
return {
type: 'Just',
value: new Date(+that[1] || that[1])
};
} else if (options.explicit) {
return {
type: 'Nothing'
};
} else {
return {
type: 'Just',
value: new Date(+value || value)
};
}
},
RegExp: function(value, options){
var that;
if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
return {
type: 'Just',
value: new RegExp(that[1], that[2])
};
} else if (options.explicit) {
return {
type: 'Nothing'
};
} else {
return {
type: 'Just',
value: new RegExp(value)
};
}
},
Array: function(value, options){
return castArray(value, {
of: [{
type: '*'
}]
}, options);
},
Object: function(value, options){
return castFields(value, {
of: {}
}, options);
},
String: function(it){
var replace, that;
if (toString$.call(it).slice(8, -1) !== 'String') {
return {
type: 'Nothing'
};
}
replace = function(value, quote){
return value.replace(/\\([^u]|u[0-9a-fA-F]{4})/g, function(all, escaped){
switch (escaped[0]) {
case quote:
return quote;
case '\\':
return '\\';
case 'b':
return '\b';
case 'f':
return '\f';
case 'n':
return '\n';
case 'r':
return '\r';
case 't':
return '\t';
case 'u':
return JSON.parse("\"" + all + "\"");
default:
return escaped;
}
});
};
if (that = it.match(/^'([\s\S]*)'$/)) {
return {
type: 'Just',
value: replace(that[1], "'")
};
} else if (that = it.match(/^"([\s\S]*)"$/)) {
return {
type: 'Just',
value: replace(that[1], '"')
};
} else {
return {
type: 'Just',
value: it
};
}
}
};
function castArray(node, type, options){
var typeOf, element;
if (toString$.call(node).slice(8, -1) !== 'Array') {
return {
type: 'Nothing'
};
}
typeOf = type.of;
return {
type: 'Just',
value: (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
element = ref$[i$];
results$.push(typesCast(element, typeOf, options));
}
return results$;
}())
};
}
function castTuple(node, type, options){
var result, i, i$, ref$, len$, types, cast;
if (toString$.call(node).slice(8, -1) !== 'Array') {
return {
type: 'Nothing'
};
}
result = [];
i = 0;
for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
types = ref$[i$];
cast = typesCast(node[i], types, options);
if (toString$.call(cast).slice(8, -1) !== 'Undefined') {
result.push(cast);
}
i++;
}
if (node.length <= i) {
return {
type: 'Just',
value: result
};
} else {
return {
type: 'Nothing'
};
}
}
function castFields(node, type, options){
var typeOf, key, value;
if (toString$.call(node).slice(8, -1) !== 'Object') {
return {
type: 'Nothing'
};
}
typeOf = type.of;
return {
type: 'Just',
value: (function(){
var ref$, resultObj$ = {};
for (key in ref$ = node) {
value = ref$[key];
resultObj$[typesCast(key, [{
type: 'String'
}], options)] = typesCast(value, typeOf[key] || [{
type: '*'
}], options);
}
return resultObj$;
}())
};
}
function typeCast(node, typeObj, options){
var type, structure, castFunc, ref$;
type = typeObj.type, structure = typeObj.structure;
if (type) {
castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type];
if (!castFunc) {
throw new Error("Type not defined: " + type + ".");
}
return castFunc(node, options, typesCast);
} else {
switch (structure) {
case 'array':
return castArray(node, typeObj, options);
case 'tuple':
return castTuple(node, typeObj, options);
case 'fields':
return castFields(node, typeObj, options);
}
}
}
function typesCast(node, types, options){
var i$, len$, type, ref$, valueType, value;
for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
type = types[i$];
ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
if (valueType === 'Nothing') {
continue;
}
if (parsedTypeCheck([type], value, {
customTypes: options.customTypes
})) {
return value;
}
}
throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
}
module.exports = function(node, types, options){
if (!options.explicit && types.length === 1 && types[0].type === 'String') {
return node;
}
return typesCast(node, types, options);
};
}).call(this);

View File

@@ -0,0 +1,438 @@
import * as BufferLayout from '@solana/buffer-layout';
import {getU64Encoder} from '@solana/codecs-numbers';
import * as Layout from '../../layout';
import {PublicKey} from '../../publickey';
import * as bigintLayout from '../../utils/bigint';
import {SystemProgram} from '../system';
import {TransactionInstruction} from '../../transaction';
import {decodeData, encodeData, IInstructionInputData} from '../../instruction';
export * from './state';
export type CreateLookupTableParams = {
/** Account used to derive and control the new address lookup table. */
authority: PublicKey;
/** Account that will fund the new address lookup table. */
payer: PublicKey;
/** A recent slot must be used in the derivation path for each initialized table. */
recentSlot: bigint | number;
};
export type FreezeLookupTableParams = {
/** Address lookup table account to freeze. */
lookupTable: PublicKey;
/** Account which is the current authority. */
authority: PublicKey;
};
export type ExtendLookupTableParams = {
/** Address lookup table account to extend. */
lookupTable: PublicKey;
/** Account which is the current authority. */
authority: PublicKey;
/** Account that will fund the table reallocation.
* Not required if the reallocation has already been funded. */
payer?: PublicKey;
/** List of Public Keys to be added to the lookup table. */
addresses: Array<PublicKey>;
};
export type DeactivateLookupTableParams = {
/** Address lookup table account to deactivate. */
lookupTable: PublicKey;
/** Account which is the current authority. */
authority: PublicKey;
};
export type CloseLookupTableParams = {
/** Address lookup table account to close. */
lookupTable: PublicKey;
/** Account which is the current authority. */
authority: PublicKey;
/** Recipient of closed account lamports. */
recipient: PublicKey;
};
/**
* An enumeration of valid LookupTableInstructionType's
*/
export type LookupTableInstructionType =
| 'CreateLookupTable'
| 'ExtendLookupTable'
| 'CloseLookupTable'
| 'FreezeLookupTable'
| 'DeactivateLookupTable';
type LookupTableInstructionInputData = {
CreateLookupTable: IInstructionInputData &
Readonly<{
recentSlot: bigint;
bumpSeed: number;
}>;
FreezeLookupTable: IInstructionInputData;
ExtendLookupTable: IInstructionInputData &
Readonly<{
numberOfAddresses: bigint;
addresses: Array<Uint8Array>;
}>;
DeactivateLookupTable: IInstructionInputData;
CloseLookupTable: IInstructionInputData;
};
/**
* An enumeration of valid address lookup table InstructionType's
* @internal
*/
export const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
CreateLookupTable: {
index: 0,
layout: BufferLayout.struct<
LookupTableInstructionInputData['CreateLookupTable']
>([
BufferLayout.u32('instruction'),
bigintLayout.u64('recentSlot'),
BufferLayout.u8('bumpSeed'),
]),
},
FreezeLookupTable: {
index: 1,
layout: BufferLayout.struct<
LookupTableInstructionInputData['FreezeLookupTable']
>([BufferLayout.u32('instruction')]),
},
ExtendLookupTable: {
index: 2,
layout: BufferLayout.struct<
LookupTableInstructionInputData['ExtendLookupTable']
>([
BufferLayout.u32('instruction'),
bigintLayout.u64(),
BufferLayout.seq(
Layout.publicKey(),
BufferLayout.offset(BufferLayout.u32(), -8),
'addresses',
),
]),
},
DeactivateLookupTable: {
index: 3,
layout: BufferLayout.struct<
LookupTableInstructionInputData['DeactivateLookupTable']
>([BufferLayout.u32('instruction')]),
},
CloseLookupTable: {
index: 4,
layout: BufferLayout.struct<
LookupTableInstructionInputData['CloseLookupTable']
>([BufferLayout.u32('instruction')]),
},
});
export class AddressLookupTableInstruction {
/**
* @internal
*/
constructor() {}
static decodeInstructionType(
instruction: TransactionInstruction,
): LookupTableInstructionType {
this.checkProgramId(instruction.programId);
const instructionTypeLayout = BufferLayout.u32('instruction');
const index = instructionTypeLayout.decode(instruction.data);
let type: LookupTableInstructionType | undefined;
for (const [layoutType, layout] of Object.entries(
LOOKUP_TABLE_INSTRUCTION_LAYOUTS,
)) {
if ((layout as any).index == index) {
type = layoutType as LookupTableInstructionType;
break;
}
}
if (!type) {
throw new Error(
'Invalid Instruction. Should be a LookupTable Instruction',
);
}
return type;
}
static decodeCreateLookupTable(
instruction: TransactionInstruction,
): CreateLookupTableParams {
this.checkProgramId(instruction.programId);
this.checkKeysLength(instruction.keys, 4);
const {recentSlot} = decodeData(
LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable,
instruction.data,
);
return {
authority: instruction.keys[1].pubkey,
payer: instruction.keys[2].pubkey,
recentSlot: Number(recentSlot),
};
}
static decodeExtendLookupTable(
instruction: TransactionInstruction,
): ExtendLookupTableParams {
this.checkProgramId(instruction.programId);
if (instruction.keys.length < 2) {
throw new Error(
`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`,
);
}
const {addresses} = decodeData(
LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable,
instruction.data,
);
return {
lookupTable: instruction.keys[0].pubkey,
authority: instruction.keys[1].pubkey,
payer:
instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
addresses: addresses.map(buffer => new PublicKey(buffer)),
};
}
static decodeCloseLookupTable(
instruction: TransactionInstruction,
): CloseLookupTableParams {
this.checkProgramId(instruction.programId);
this.checkKeysLength(instruction.keys, 3);
return {
lookupTable: instruction.keys[0].pubkey,
authority: instruction.keys[1].pubkey,
recipient: instruction.keys[2].pubkey,
};
}
static decodeFreezeLookupTable(
instruction: TransactionInstruction,
): FreezeLookupTableParams {
this.checkProgramId(instruction.programId);
this.checkKeysLength(instruction.keys, 2);
return {
lookupTable: instruction.keys[0].pubkey,
authority: instruction.keys[1].pubkey,
};
}
static decodeDeactivateLookupTable(
instruction: TransactionInstruction,
): DeactivateLookupTableParams {
this.checkProgramId(instruction.programId);
this.checkKeysLength(instruction.keys, 2);
return {
lookupTable: instruction.keys[0].pubkey,
authority: instruction.keys[1].pubkey,
};
}
/**
* @internal
*/
static checkProgramId(programId: PublicKey) {
if (!programId.equals(AddressLookupTableProgram.programId)) {
throw new Error(
'invalid instruction; programId is not AddressLookupTable Program',
);
}
}
/**
* @internal
*/
static checkKeysLength(keys: Array<any>, expectedLength: number) {
if (keys.length < expectedLength) {
throw new Error(
`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,
);
}
}
}
export class AddressLookupTableProgram {
/**
* @internal
*/
constructor() {}
static programId: PublicKey = new PublicKey(
'AddressLookupTab1e1111111111111111111111111',
);
static createLookupTable(params: CreateLookupTableParams) {
const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync(
[
params.authority.toBuffer(),
getU64Encoder().encode(params.recentSlot) as Uint8Array,
],
this.programId,
);
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
const data = encodeData(type, {
recentSlot: BigInt(params.recentSlot),
bumpSeed: bumpSeed,
});
const keys = [
{
pubkey: lookupTableAddress,
isSigner: false,
isWritable: true,
},
{
pubkey: params.authority,
isSigner: true,
isWritable: false,
},
{
pubkey: params.payer,
isSigner: true,
isWritable: true,
},
{
pubkey: SystemProgram.programId,
isSigner: false,
isWritable: false,
},
];
return [
new TransactionInstruction({
programId: this.programId,
keys: keys,
data: data,
}),
lookupTableAddress,
] as [TransactionInstruction, PublicKey];
}
static freezeLookupTable(params: FreezeLookupTableParams) {
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
const data = encodeData(type);
const keys = [
{
pubkey: params.lookupTable,
isSigner: false,
isWritable: true,
},
{
pubkey: params.authority,
isSigner: true,
isWritable: false,
},
];
return new TransactionInstruction({
programId: this.programId,
keys: keys,
data: data,
});
}
static extendLookupTable(params: ExtendLookupTableParams) {
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
const data = encodeData(type, {
addresses: params.addresses.map(addr => addr.toBytes()),
});
const keys = [
{
pubkey: params.lookupTable,
isSigner: false,
isWritable: true,
},
{
pubkey: params.authority,
isSigner: true,
isWritable: false,
},
];
if (params.payer) {
keys.push(
{
pubkey: params.payer,
isSigner: true,
isWritable: true,
},
{
pubkey: SystemProgram.programId,
isSigner: false,
isWritable: false,
},
);
}
return new TransactionInstruction({
programId: this.programId,
keys: keys,
data: data,
});
}
static deactivateLookupTable(params: DeactivateLookupTableParams) {
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
const data = encodeData(type);
const keys = [
{
pubkey: params.lookupTable,
isSigner: false,
isWritable: true,
},
{
pubkey: params.authority,
isSigner: true,
isWritable: false,
},
];
return new TransactionInstruction({
programId: this.programId,
keys: keys,
data: data,
});
}
static closeLookupTable(params: CloseLookupTableParams) {
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
const data = encodeData(type);
const keys = [
{
pubkey: params.lookupTable,
isSigner: false,
isWritable: true,
},
{
pubkey: params.authority,
isSigner: true,
isWritable: false,
},
{
pubkey: params.recipient,
isSigner: false,
isWritable: true,
},
];
return new TransactionInstruction({
programId: this.programId,
keys: keys,
data: data,
});
}
}

View File

@@ -0,0 +1,9 @@
'use strict'
const { join } = require('node:path')
const pino = require('../..')
const transport = pino.transport({
target: join(__dirname, 'transport-worker.js')
})
const logger = pino(transport)
logger.info('Hello')

View File

@@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----
Version: BSN Pgp v1.0.0.0
iQEcBAABCAAGBQJqTebQAAoJEOs+lK2+EinPblgH/2BOzf1BzBVbTd3OXCX29bdK
5uN+q3moUGjznK/FknvlEqlhxo7V7BX+kgTbL2WGcsmcq4jx1zcEDAQkjJM8xDlh
arpq1acM9rFWRbVyMwSUspKtOqNO83Rtk4WvPO90edmxdbVnOgHSMRNnvMbJCq0B
cQkVjNQEUu1WZJ0xdC154JmvqVoyJDz+kkN0iDocrKDNPI9uEaHmnAO7+yBItU3D
59IBlL6l6Wwx2vyLDyy/ns534wX8STJSsByz86cCr9pWtugSahC6seXhNflpDFZq
O3N+VtgpoHbBYRwXAtIbqqlR6Y04O2TCaYlxRoyYZwkCVd3RSTw6rCsHwB26QbQ=
=y9Bn
-----END PGP SIGNATURE-----

View File

@@ -0,0 +1,43 @@
'use strict';
const {Transform} = require('stream');
const defaultInitial = 0;
const defaultReducer = (acc, value) => value;
class Fold extends Transform {
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
this._accumulator = defaultInitial;
this._reducer = defaultReducer;
if (options) {
'initial' in options && (this._accumulator = options.initial);
'reducer' in options && (this._reducer = options.reducer);
}
}
_transform(chunk, encoding, callback) {
const result = this._reducer.call(this, this._accumulator, chunk);
if (result && typeof result.then == 'function') {
result.then(
value => {
this._accumulator = value;
callback(null);
},
error => callback(error)
);
} else {
this._accumulator = result;
callback(null);
}
}
_final(callback) {
this.push(this._accumulator);
callback(null);
}
static make(reducer, initial) {
return new Fold(typeof reducer == 'object' ? reducer : {reducer, initial});
}
}
Fold.make.Constructor = Fold;
module.exports = Fold.make;

View File

@@ -0,0 +1,30 @@
import Pool from './pool'
import Dispatcher from './dispatcher'
import { URL } from 'node:url'
export default BalancedPool
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
declare class BalancedPool extends Dispatcher {
constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
addUpstream (upstream: string | URL): BalancedPool
removeUpstream (upstream: string | URL): BalancedPool
getUpstream (upstream: string | URL): Pool | undefined
upstreams: Array<string>
/** `true` after `pool.close()` has been called. */
closed: boolean
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
destroyed: boolean
// Override dispatcher APIs.
override connect (
options: BalancedPoolConnectOptions
): Promise<Dispatcher.ConnectData>
override connect (
options: BalancedPoolConnectOptions,
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
): void
}

View File

@@ -0,0 +1,47 @@
/**
* Hand-written visitor implementations for nodes with runtime-dependent
* child ordering. Generated code in visitor.generated.ts and factory.generated.ts
* delegates to these functions.
*/
import { SyntaxKind } from "#enums/syntaxKind";
import { updateJSDocParameterTag, updateJSDocPropertyTag, } from "./factory.generated.js";
import { isEntityName, isIdentifier, isTypeNode, } from "./is.js";
import { visitNode, visitNodes, } from "./visitor.generated.js";
export { visitEachChild, visitNode, visitNodes, visitNodesArray } from "./visitor.generated.js";
// ── forEachChild helpers (same signature as forEachChildTable entries) ──
function visitNodeForEachChild(cbNode, node) {
return node ? cbNode(node) : undefined;
}
function visitNodesForEachChild(cbNode, cbNodes, nodes) {
if (!nodes)
return undefined;
if (cbNodes)
return cbNodes(nodes);
for (const node of nodes) {
const result = cbNode(node);
if (result)
return result;
}
return undefined;
}
// ── forEachChild implementations ──
function forEachChildOfJSDocParameterOrPropertyTag(data, cbNode, cbNodes) {
return visitNodeForEachChild(cbNode, data.tagName) ||
(data.isNameFirst
? visitNodeForEachChild(cbNode, data.name) || visitNodeForEachChild(cbNode, data.typeExpression)
: visitNodeForEachChild(cbNode, data.typeExpression) || visitNodeForEachChild(cbNode, data.name)) ||
visitNodesForEachChild(cbNode, cbNodes, data.comment);
}
export { forEachChildOfJSDocParameterOrPropertyTag as forEachChildOfJSDocParameterTag, forEachChildOfJSDocParameterOrPropertyTag as forEachChildOfJSDocPropertyTag };
// ── visitEachChild implementations ──
function visitEachChildOfJSDocParameterOrPropertyTag(node, visitor) {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _name = visitNode(node.name, visitor, isEntityName);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return node.kind === SyntaxKind.JSDocParameterTag
? updateJSDocParameterTag(node, _tagName, _name, _typeExpression, _comment)
: updateJSDocPropertyTag(node, _tagName, _name, _typeExpression, _comment);
}
export { visitEachChildOfJSDocParameterOrPropertyTag as visitEachChildOfJSDocParameterTag, visitEachChildOfJSDocParameterOrPropertyTag as visitEachChildOfJSDocPropertyTag };
//# sourceMappingURL=visitor.js.map

View File

@@ -0,0 +1,5 @@
export const version = {
major: 4,
minor: 4,
patch: 3 as number,
} as const;

View File

@@ -0,0 +1,7 @@
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
export default _default;
/**
* Contains all of `recommended`, as well as additional strict rules that can also catch bugs.
* @see {@link https://typescript-eslint.io/users/configs#strict}
*/
declare function _default(plugin: FlatConfig.Plugin, parser: FlatConfig.Parser): FlatConfig.ConfigArray;

View File

@@ -0,0 +1,26 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
// npx nx generate-lib repo
Object.defineProperty(exports, "__esModule", { value: true });
exports.es2022 = void 0;
const es2021_1 = require("./es2021");
const es2022_array_1 = require("./es2022.array");
const es2022_error_1 = require("./es2022.error");
const es2022_intl_1 = require("./es2022.intl");
const es2022_object_1 = require("./es2022.object");
const es2022_regexp_1 = require("./es2022.regexp");
const es2022_string_1 = require("./es2022.string");
exports.es2022 = {
libs: [
es2021_1.es2021,
es2022_array_1.es2022_array,
es2022_error_1.es2022_error,
es2022_intl_1.es2022_intl,
es2022_object_1.es2022_object,
es2022_regexp_1.es2022_regexp,
es2022_string_1.es2022_string,
],
variables: [],
};