Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-core

Package Overview
Dependencies
Maintainers
13
Versions
456
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-core - npm Package Compare versions

Comparing version 2.0.0-experimental.093f058 to 2.0.0-experimental.0b7dd02

dist/types/blockhash.d.ts

140

dist/index.browser.js

@@ -0,3 +1,143 @@

import bs58 from 'bs58';
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {
try {
if (
// Lowest value (32 bytes of zeroes)
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
putativeBlockhash.length > 44
) {
throw new Error("Expected input string to decode to a byte array of length 32.");
}
const bytes = bs58.decode(putativeBlockhash);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
}
} catch (e) {
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
cause: e
});
}
}
// src/params-patcher.ts
function visitNode(value, keyPath, onIntegerOverflow) {
if (Array.isArray(value)) {
return value.map(
(element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow)
);
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const propName in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);
}
}
return out;
} else if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
return Number(value);
} else {
return value;
}
}
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
return visitNode(params, [], onIntegerOverflow);
}
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getBlockTime: [[]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTransaction: [
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "header", "numReadonlySignedAccounts"],
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transaction", "message", "header", "numRequiredSignatures"]
],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
]
};
// src/response-patcher.ts
function getNextAllowedKeypaths(keyPaths, property) {
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
}
function visitNode2(value, allowedKeypaths) {
if (Array.isArray(value)) {
return value.map((element, ii) => {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);
return visitNode2(element, nextAllowedKeypaths);
});
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const [propName, innerValue] of Object.entries(value)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
}
return out;
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
// Upcast the value to `bigint` unless an allowed keypath is present.
allowedKeypaths.length === 0) {
return BigInt(value);
} else {
return value;
}
}
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
return visitNode2(rawResponse, allowedKeypaths ?? []);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
};
};
}
});
}
export { assertIsBlockhash, createSolanaRpcApi };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -0,3 +1,143 @@

import bs58 from 'bs58';
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {
try {
if (
// Lowest value (32 bytes of zeroes)
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
putativeBlockhash.length > 44
) {
throw new Error("Expected input string to decode to a byte array of length 32.");
}
const bytes = bs58.decode(putativeBlockhash);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
}
} catch (e) {
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
cause: e
});
}
}
// src/params-patcher.ts
function visitNode(value, keyPath, onIntegerOverflow) {
if (Array.isArray(value)) {
return value.map(
(element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow)
);
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const propName in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);
}
}
return out;
} else if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
return Number(value);
} else {
return value;
}
}
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
return visitNode(params, [], onIntegerOverflow);
}
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getBlockTime: [[]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTransaction: [
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "header", "numReadonlySignedAccounts"],
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transaction", "message", "header", "numRequiredSignatures"]
],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
]
};
// src/response-patcher.ts
function getNextAllowedKeypaths(keyPaths, property) {
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
}
function visitNode2(value, allowedKeypaths) {
if (Array.isArray(value)) {
return value.map((element, ii) => {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);
return visitNode2(element, nextAllowedKeypaths);
});
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const [propName, innerValue] of Object.entries(value)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
}
return out;
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
// Upcast the value to `bigint` unless an allowed keypath is present.
allowedKeypaths.length === 0) {
return BigInt(value);
} else {
return value;
}
}
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
return visitNode2(rawResponse, allowedKeypaths ?? []);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
};
};
}
});
}
export { assertIsBlockhash, createSolanaRpcApi };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -0,3 +1,143 @@

import bs58 from 'bs58';
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {
try {
if (
// Lowest value (32 bytes of zeroes)
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
putativeBlockhash.length > 44
) {
throw new Error("Expected input string to decode to a byte array of length 32.");
}
const bytes = bs58.decode(putativeBlockhash);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
}
} catch (e) {
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
cause: e
});
}
}
// src/params-patcher.ts
function visitNode(value, keyPath, onIntegerOverflow) {
if (Array.isArray(value)) {
return value.map(
(element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow)
);
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const propName in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);
}
}
return out;
} else if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
return Number(value);
} else {
return value;
}
}
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
return visitNode(params, [], onIntegerOverflow);
}
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getBlockTime: [[]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTransaction: [
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
["transaction", "message", "header", "numReadonlySignedAccounts"],
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transaction", "message", "header", "numRequiredSignatures"]
],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
]
};
// src/response-patcher.ts
function getNextAllowedKeypaths(keyPaths, property) {
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
}
function visitNode2(value, allowedKeypaths) {
if (Array.isArray(value)) {
return value.map((element, ii) => {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);
return visitNode2(element, nextAllowedKeypaths);
});
} else if (typeof value === "object" && value !== null) {
const out = {};
for (const [propName, innerValue] of Object.entries(value)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
}
return out;
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
// Upcast the value to `bigint` unless an allowed keypath is present.
allowedKeypaths.length === 0) {
return BigInt(value);
} else {
return value;
}
}
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
return visitNode2(rawResponse, allowedKeypaths ?? []);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
};
};
}
});
}
export { assertIsBlockhash, createSolanaRpcApi };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

3

dist/types/index.d.ts

@@ -1,2 +0,3 @@

export * from './types/jsonRpcApi';
export * from './blockhash';
export * from './rpc-methods';
//# sourceMappingURL=index.d.ts.map
{
"name": "@solana/rpc-core",
"version": "2.0.0-experimental.093f058",
"version": "2.0.0-experimental.0b7dd02",
"description": "A library for making calls to the Solana JSON RPC API",

@@ -49,13 +49,14 @@ "exports": {

"dependencies": {
"@solana/keys": "2.0.0-experimental.093f058"
"bs58": "^5.0.0",
"@solana/keys": "2.0.0-experimental.0b7dd02"
},
"devDependencies": {
"@solana/eslint-config-solana": "^0.0.4",
"@solana/eslint-config-solana": "^1.0.1",
"@swc/core": "^1.3.18",
"@swc/jest": "^0.2.23",
"@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"agadoo": "^2.0.0",
"eslint": "^8.27.0",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"agadoo": "^3.0.0",
"eslint": "^8.37.0",
"eslint-plugin-jest": "^27.1.5",

@@ -66,11 +67,12 @@ "eslint-plugin-react-hooks": "^4.6.0",

"jest-environment-jsdom": "^29.5.0",
"jest-fetch-mock-fork": "^3.0.4",
"jest-runner-eslint": "^2.0.0",
"jest-runner-prettier": "^1.0.0",
"postcss": "^8.4.12",
"prettier": "^2.7.1",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"tsup": "6.7.0",
"turbo": "^1.6.3",
"typescript": "^4.9",
"typescript": "^5.0.3",
"version-from-git": "^1.1.1",
"@solana/rpc-transport": "2.0.0-experimental.0b7dd02",
"build-scripts": "0.0.0",

@@ -91,3 +93,3 @@ "test-config": "0.0.0",

"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --watch",
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",

@@ -99,4 +101,6 @@ "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",

"test:treeshakability:node": "agadoo dist/index.native.js",
"test:typecheck": "tsc --noEmit"
"test:typecheck": "tsc --noEmit",
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --silent",
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --silent"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc