Socket
Socket
Sign inDemoInstall

@solana/rpc-transport

Package Overview
Dependencies
Maintainers
13
Versions
602
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-transport - npm Package Compare versions

Comparing version 0.0.0-experimental.2 to 2.0.0-experimental.044c967

dist/types/http-request-errors.d.ts.map

60

dist/index.browser.js

@@ -39,3 +39,3 @@ import 'node-fetch';

// src/json-rpc-errors.ts
// src/json-rpc-transport/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -53,3 +53,3 @@ constructor(details) {

// src/json-rpc-message-id.ts
// src/json-rpc-transport/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -62,3 +62,3 @@ function getNextMessageId() {

// src/json-rpc-message.ts
// src/json-rpc-transport/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -100,3 +100,42 @@ return {

// src/json-rpc-transport.ts
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getInflationReward: [[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 in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(value[propName], 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(response, methodName) {
return visitNode2(response, (methodName && ALLOWED_NUMERIC_KEYPATHS[methodName]) ?? []);
}
// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingMessage) {

@@ -150,7 +189,12 @@ const { url } = transportConfig;

}
function processResponse(response) {
function processResponse(response, methodName) {
if ("error" in response) {
throw new SolanaJsonRpcError(response.error);
} else {
return response.result;
const patchedResponse = patchResponseForSolanaLabsRpc(
response.result,
methodName
// FIXME: Untangle these types by moving the patcher into `rpc-core`
);
return patchedResponse;
}

@@ -165,5 +209,5 @@ }

const requestOrder = payload.map((p) => p.id);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map(processResponse);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map((response, ii) => processResponse(response, payload[ii].method));
} else {
return processResponse(responseOrResponses);
return processResponse(responseOrResponses, payload.method);
}

@@ -170,0 +214,0 @@ }

@@ -39,3 +39,3 @@ import 'node-fetch';

// src/json-rpc-errors.ts
// src/json-rpc-transport/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -53,3 +53,3 @@ constructor(details) {

// src/json-rpc-message-id.ts
// src/json-rpc-transport/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -62,3 +62,3 @@ function getNextMessageId() {

// src/json-rpc-message.ts
// src/json-rpc-transport/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -100,3 +100,42 @@ return {

// src/json-rpc-transport.ts
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getInflationReward: [[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 in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(value[propName], 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(response, methodName) {
return visitNode2(response, (methodName && ALLOWED_NUMERIC_KEYPATHS[methodName]) ?? []);
}
// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingMessage) {

@@ -150,7 +189,12 @@ const { url } = transportConfig;

}
function processResponse(response) {
function processResponse(response, methodName) {
if ("error" in response) {
throw new SolanaJsonRpcError(response.error);
} else {
return response.result;
const patchedResponse = patchResponseForSolanaLabsRpc(
response.result,
methodName
// FIXME: Untangle these types by moving the patcher into `rpc-core`
);
return patchedResponse;
}

@@ -165,5 +209,5 @@ }

const requestOrder = payload.map((p) => p.id);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map(processResponse);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map((response, ii) => processResponse(response, payload[ii].method));
} else {
return processResponse(responseOrResponses);
return processResponse(responseOrResponses, payload.method);
}

@@ -170,0 +214,0 @@ }

@@ -35,3 +35,3 @@ import fetchImplNode from 'node-fetch';

// src/json-rpc-errors.ts
// src/json-rpc-transport/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -49,3 +49,3 @@ constructor(details) {

// src/json-rpc-message-id.ts
// src/json-rpc-transport/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -58,3 +58,3 @@ function getNextMessageId() {

// src/json-rpc-message.ts
// src/json-rpc-transport/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -96,3 +96,42 @@ return {

// src/json-rpc-transport.ts
// src/response-patcher-types.ts
var KEYPATH_WILDCARD = {};
// src/response-patcher-allowed-numeric-values.ts
var ALLOWED_NUMERIC_KEYPATHS = {
getInflationReward: [[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 in value) {
if (Object.prototype.hasOwnProperty.call(value, propName)) {
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
out[propName] = visitNode2(value[propName], 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(response, methodName) {
return visitNode2(response, (methodName && ALLOWED_NUMERIC_KEYPATHS[methodName]) ?? []);
}
// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingMessage) {

@@ -146,7 +185,12 @@ const { url } = transportConfig;

}
function processResponse(response) {
function processResponse(response, methodName) {
if ("error" in response) {
throw new SolanaJsonRpcError(response.error);
} else {
return response.result;
const patchedResponse = patchResponseForSolanaLabsRpc(
response.result,
methodName
// FIXME: Untangle these types by moving the patcher into `rpc-core`
);
return patchedResponse;
}

@@ -161,5 +205,5 @@ }

const requestOrder = payload.map((p) => p.id);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map(processResponse);
return responseOrResponses.sort((a, b) => requestOrder.indexOf(a.id) - requestOrder.indexOf(b.id)).map((response, ii) => processResponse(response, payload[ii].method));
} else {
return processResponse(responseOrResponses);
return processResponse(responseOrResponses, payload.method);
}

@@ -166,0 +210,0 @@ }

20

package.json
{
"name": "@solana/rpc-transport",
"version": "0.0.0-experimental.2",
"version": "2.0.0-experimental.044c967",
"description": "Network transports for accessing the Solana JSON RPC API",

@@ -64,3 +64,3 @@ "exports": {

"jest-fetch-mock": "^3.0.3",
"jest-runner-eslint": "^1.1.0",
"jest-runner-eslint": "^2.0.0",
"jest-runner-prettier": "^1.0.0",

@@ -70,5 +70,6 @@ "postcss": "^8.4.12",

"ts-node": "^10.9.1",
"tsup": "6.5.0",
"tsup": "6.7.0",
"turbo": "^1.6.3",
"typescript": "^4.9",
"version-from-git": "^1.1.1",
"@solana/fetch-impl-browser": "0.0.0-development",

@@ -88,5 +89,5 @@ "build-scripts": "0.0.0",

"dependencies": {
"@solana/keys": "^0.0.0-experimental.1",
"@solana/rpc-core": "^0.0.0-experimental.2",
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.7",
"@solana/keys": "2.0.0-experimental.044c967",
"@solana/rpc-core": "2.0.0-experimental.044c967"
},

@@ -96,3 +97,4 @@ "scripts": {

"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",
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",

@@ -104,5 +106,5 @@ "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",

"test:typecheck": "tsc --noEmit",
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
"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