Socket
Socket
Sign inDemoInstall

@solana/rpc-core

Package Overview
Dependencies
Maintainers
14
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.b219d97 to 2.0.0-experimental.b315352

dist/types/index.d.ts.map

631

dist/index.browser.js

@@ -1,68 +0,3 @@

// 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 = {
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, 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/index.ts
function createSolanaRpcApi(config) {
// ../rpc-transport/dist/index.browser.js
function createJsonRpcApi(config) {
return new Proxy({}, {

@@ -79,11 +14,8 @@ defineProperty() {

return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
responseTransformer
};

@@ -94,5 +26,556 @@ };

}
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
export { createSolanaRpcApi };
// src/params-patcher-bigint-downcast.ts
function downcastNodeToNumberIfBigint(value) {
return typeof value === "bigint" ? (
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
// downcasting `bigints` to `numbers`.
Number(value)
) : value;
}
// src/params-patcher-integer-overflow.ts
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
return (value, { keyPath }) => {
if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
}
return value;
};
}
// src/tree-traversal.ts
var KEYPATH_WILDCARD = {};
function getTreeWalker(visitors) {
return function traverse(node, state) {
if (Array.isArray(node)) {
return node.map((element, ii) => {
const nextState = {
...state,
keyPath: [...state.keyPath, ii]
};
return traverse(element, nextState);
});
} else if (typeof node === "object" && node !== null) {
const out = {};
for (const propName in node) {
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
continue;
}
const nextState = {
...state,
keyPath: [...state.keyPath, propName]
};
out[propName] = traverse(node[propName], nextState);
}
return out;
} else {
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
}
};
}
// src/params-patcher.ts
function getParamsPatcherForSolanaLabsRpc(config) {
const handleIntegerOverflow = config?.onIntegerOverflow;
return (rawParams, methodName) => {
const traverse = getTreeWalker([
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
downcastNodeToNumberIfBigint
]);
const initialState = {
keyPath: []
};
return traverse(rawParams, initialState);
};
}
// src/response-patcher-allowed-numeric-values.ts
var jsonParsedTokenAccountsConfigs = [
// parsed Token/Token22 token account
["data", "parsed", "info", "tokenAmount", "decimals"],
["data", "parsed", "info", "tokenAmount", "uiAmount"],
["data", "parsed", "info", "rentExemptReserve", "decimals"],
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
["data", "parsed", "info", "delegatedAmount", "decimals"],
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
];
var jsonParsedAccountsConfigs = [
...jsonParsedTokenAccountsConfigs,
// parsed AddressTableLookup account
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
// parsed Config account
["data", "parsed", "info", "slashPenalty"],
["data", "parsed", "info", "warmupCooldownRate"],
// parsed Token/Token22 mint account
["data", "parsed", "info", "decimals"],
// parsed Token/Token22 multisig account
["data", "parsed", "info", "numRequiredSigners"],
["data", "parsed", "info", "numValidSigners"],
// parsed Stake account
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
// parsed Sysvar rent account
["data", "parsed", "info", "exemptionThreshold"],
["data", "parsed", "info", "burnPercent"],
// parsed Vote account
["data", "parsed", "info", "commission"],
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
];
var memoizedNotificationKeypaths;
var memoizedResponseKeypaths;
function getAllowedNumericKeypathsForNotification() {
if (!memoizedNotificationKeypaths) {
memoizedNotificationKeypaths = {
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
blockNotifications: [
["value", "block", "blockTime"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"index"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlySignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlyUnsignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numRequiredSignatures"
],
["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
],
programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
])
};
}
return memoizedNotificationKeypaths;
}
function getAllowedNumericKeypathsForResponse() {
if (!memoizedResponseKeypaths) {
memoizedResponseKeypaths = {
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
getBlock: [
["blockTime"],
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
["rewards", KEYPATH_WILDCARD, "commission"]
],
getBlockTime: [[]],
getClusterNodes: [
[KEYPATH_WILDCARD, "featureSet"],
[KEYPATH_WILDCARD, "shredVersion"]
],
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
getInflationRate: [["foundation"], ["total"], ["validator"]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
]),
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTokenAccountBalance: [
["value", "decimals"],
["value", "uiAmount"]
],
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenLargestAccounts: [
["value", KEYPATH_WILDCARD, "decimals"],
["value", KEYPATH_WILDCARD, "uiAmount"]
],
getTokenSupply: [
["value", "decimals"],
["value", "uiAmount"]
],
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"]
],
getVersion: [["feature-set"]],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
],
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
};
}
return memoizedResponseKeypaths;
}
// src/response-patcher-bigint-upcast.ts
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
if (prohibitedKeyPath.length !== keyPath.length) {
return false;
}
for (let ii = keyPath.length - 1; ii >= 0; ii--) {
const keyPathPart = keyPath[ii];
const prohibitedKeyPathPart = prohibitedKeyPath[ii];
if (prohibitedKeyPathPart !== keyPathPart && (prohibitedKeyPathPart !== KEYPATH_WILDCARD || typeof keyPathPart !== "number")) {
return false;
}
}
return true;
});
}
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
return BigInt(value);
} else {
return value;
}
};
}
// src/response-patcher.ts
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedNumericKeyPaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName) {
const allowedNumericKeyPaths = notificationName ? getAllowedNumericKeypathsForNotification()[notificationName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return createJsonRpcApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpc
});
}
// src/rpc-subscriptions/index.ts
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
return createJsonRpcSubscriptionsApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions,
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
});
}
function createSolanaRpcSubscriptionsApi(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -1,68 +0,3 @@

// 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 = {
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, 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/index.ts
function createSolanaRpcApi(config) {
// ../rpc-transport/dist/index.browser.js
function createJsonRpcApi(config) {
return new Proxy({}, {

@@ -79,11 +14,8 @@ defineProperty() {

return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
responseTransformer
};

@@ -94,5 +26,556 @@ };

}
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
export { createSolanaRpcApi };
// src/params-patcher-bigint-downcast.ts
function downcastNodeToNumberIfBigint(value) {
return typeof value === "bigint" ? (
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
// downcasting `bigints` to `numbers`.
Number(value)
) : value;
}
// src/params-patcher-integer-overflow.ts
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
return (value, { keyPath }) => {
if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
}
return value;
};
}
// src/tree-traversal.ts
var KEYPATH_WILDCARD = {};
function getTreeWalker(visitors) {
return function traverse(node, state) {
if (Array.isArray(node)) {
return node.map((element, ii) => {
const nextState = {
...state,
keyPath: [...state.keyPath, ii]
};
return traverse(element, nextState);
});
} else if (typeof node === "object" && node !== null) {
const out = {};
for (const propName in node) {
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
continue;
}
const nextState = {
...state,
keyPath: [...state.keyPath, propName]
};
out[propName] = traverse(node[propName], nextState);
}
return out;
} else {
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
}
};
}
// src/params-patcher.ts
function getParamsPatcherForSolanaLabsRpc(config) {
const handleIntegerOverflow = config?.onIntegerOverflow;
return (rawParams, methodName) => {
const traverse = getTreeWalker([
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
downcastNodeToNumberIfBigint
]);
const initialState = {
keyPath: []
};
return traverse(rawParams, initialState);
};
}
// src/response-patcher-allowed-numeric-values.ts
var jsonParsedTokenAccountsConfigs = [
// parsed Token/Token22 token account
["data", "parsed", "info", "tokenAmount", "decimals"],
["data", "parsed", "info", "tokenAmount", "uiAmount"],
["data", "parsed", "info", "rentExemptReserve", "decimals"],
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
["data", "parsed", "info", "delegatedAmount", "decimals"],
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
];
var jsonParsedAccountsConfigs = [
...jsonParsedTokenAccountsConfigs,
// parsed AddressTableLookup account
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
// parsed Config account
["data", "parsed", "info", "slashPenalty"],
["data", "parsed", "info", "warmupCooldownRate"],
// parsed Token/Token22 mint account
["data", "parsed", "info", "decimals"],
// parsed Token/Token22 multisig account
["data", "parsed", "info", "numRequiredSigners"],
["data", "parsed", "info", "numValidSigners"],
// parsed Stake account
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
// parsed Sysvar rent account
["data", "parsed", "info", "exemptionThreshold"],
["data", "parsed", "info", "burnPercent"],
// parsed Vote account
["data", "parsed", "info", "commission"],
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
];
var memoizedNotificationKeypaths;
var memoizedResponseKeypaths;
function getAllowedNumericKeypathsForNotification() {
if (!memoizedNotificationKeypaths) {
memoizedNotificationKeypaths = {
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
blockNotifications: [
["value", "block", "blockTime"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"index"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlySignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlyUnsignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numRequiredSignatures"
],
["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
],
programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
])
};
}
return memoizedNotificationKeypaths;
}
function getAllowedNumericKeypathsForResponse() {
if (!memoizedResponseKeypaths) {
memoizedResponseKeypaths = {
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
getBlock: [
["blockTime"],
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
["rewards", KEYPATH_WILDCARD, "commission"]
],
getBlockTime: [[]],
getClusterNodes: [
[KEYPATH_WILDCARD, "featureSet"],
[KEYPATH_WILDCARD, "shredVersion"]
],
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
getInflationRate: [["foundation"], ["total"], ["validator"]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
]),
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTokenAccountBalance: [
["value", "decimals"],
["value", "uiAmount"]
],
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenLargestAccounts: [
["value", KEYPATH_WILDCARD, "decimals"],
["value", KEYPATH_WILDCARD, "uiAmount"]
],
getTokenSupply: [
["value", "decimals"],
["value", "uiAmount"]
],
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"]
],
getVersion: [["feature-set"]],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
],
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
};
}
return memoizedResponseKeypaths;
}
// src/response-patcher-bigint-upcast.ts
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
if (prohibitedKeyPath.length !== keyPath.length) {
return false;
}
for (let ii = keyPath.length - 1; ii >= 0; ii--) {
const keyPathPart = keyPath[ii];
const prohibitedKeyPathPart = prohibitedKeyPath[ii];
if (prohibitedKeyPathPart !== keyPathPart && (prohibitedKeyPathPart !== KEYPATH_WILDCARD || typeof keyPathPart !== "number")) {
return false;
}
}
return true;
});
}
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
return BigInt(value);
} else {
return value;
}
};
}
// src/response-patcher.ts
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedNumericKeyPaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName) {
const allowedNumericKeyPaths = notificationName ? getAllowedNumericKeypathsForNotification()[notificationName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return createJsonRpcApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpc
});
}
// src/rpc-subscriptions/index.ts
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
return createJsonRpcSubscriptionsApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions,
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
});
}
function createSolanaRpcSubscriptionsApi(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -1,68 +0,5 @@

// 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);
}
import 'ws';
// 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, 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/index.ts
function createSolanaRpcApi(config) {
// ../rpc-transport/dist/index.node.js
function createJsonRpcApi(config) {
return new Proxy({}, {

@@ -79,11 +16,8 @@ defineProperty() {

return function(...rawParams) {
const handleIntegerOverflow = config?.onIntegerOverflow;
const params = patchParamsForSolanaLabsRpc(
rawParams,
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
);
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
responseTransformer
};

@@ -94,5 +28,556 @@ };

}
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
export { createSolanaRpcApi };
// src/params-patcher-bigint-downcast.ts
function downcastNodeToNumberIfBigint(value) {
return typeof value === "bigint" ? (
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
// downcasting `bigints` to `numbers`.
Number(value)
) : value;
}
// src/params-patcher-integer-overflow.ts
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
return (value, { keyPath }) => {
if (typeof value === "bigint") {
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
onIntegerOverflow(keyPath, value);
}
}
return value;
};
}
// src/tree-traversal.ts
var KEYPATH_WILDCARD = {};
function getTreeWalker(visitors) {
return function traverse(node, state) {
if (Array.isArray(node)) {
return node.map((element, ii) => {
const nextState = {
...state,
keyPath: [...state.keyPath, ii]
};
return traverse(element, nextState);
});
} else if (typeof node === "object" && node !== null) {
const out = {};
for (const propName in node) {
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
continue;
}
const nextState = {
...state,
keyPath: [...state.keyPath, propName]
};
out[propName] = traverse(node[propName], nextState);
}
return out;
} else {
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
}
};
}
// src/params-patcher.ts
function getParamsPatcherForSolanaLabsRpc(config) {
const handleIntegerOverflow = config?.onIntegerOverflow;
return (rawParams, methodName) => {
const traverse = getTreeWalker([
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
downcastNodeToNumberIfBigint
]);
const initialState = {
keyPath: []
};
return traverse(rawParams, initialState);
};
}
// src/response-patcher-allowed-numeric-values.ts
var jsonParsedTokenAccountsConfigs = [
// parsed Token/Token22 token account
["data", "parsed", "info", "tokenAmount", "decimals"],
["data", "parsed", "info", "tokenAmount", "uiAmount"],
["data", "parsed", "info", "rentExemptReserve", "decimals"],
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
["data", "parsed", "info", "delegatedAmount", "decimals"],
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
];
var jsonParsedAccountsConfigs = [
...jsonParsedTokenAccountsConfigs,
// parsed AddressTableLookup account
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
// parsed Config account
["data", "parsed", "info", "slashPenalty"],
["data", "parsed", "info", "warmupCooldownRate"],
// parsed Token/Token22 mint account
["data", "parsed", "info", "decimals"],
// parsed Token/Token22 multisig account
["data", "parsed", "info", "numRequiredSigners"],
["data", "parsed", "info", "numValidSigners"],
// parsed Stake account
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
// parsed Sysvar rent account
["data", "parsed", "info", "exemptionThreshold"],
["data", "parsed", "info", "burnPercent"],
// parsed Vote account
["data", "parsed", "info", "commission"],
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
];
var memoizedNotificationKeypaths;
var memoizedResponseKeypaths;
function getAllowedNumericKeypathsForNotification() {
if (!memoizedNotificationKeypaths) {
memoizedNotificationKeypaths = {
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
blockNotifications: [
["value", "block", "blockTime"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"accountIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"index"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlySignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numReadonlyUnsignedAccounts"
],
[
"value",
"block",
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"header",
"numRequiredSignatures"
],
["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
],
programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
])
};
}
return memoizedNotificationKeypaths;
}
function getAllowedNumericKeypathsForResponse() {
if (!memoizedResponseKeypaths) {
memoizedResponseKeypaths = {
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
getBlock: [
["blockTime"],
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"preTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"postTokenBalances",
KEYPATH_WILDCARD,
"uiTokenAmount",
"decimals"
],
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"meta",
"innerInstructions",
KEYPATH_WILDCARD,
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"writableIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"addressTableLookups",
KEYPATH_WILDCARD,
"readonlyIndexes",
KEYPATH_WILDCARD
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"programIdIndex"
],
[
"transactions",
KEYPATH_WILDCARD,
"transaction",
"message",
"instructions",
KEYPATH_WILDCARD,
"accounts",
KEYPATH_WILDCARD
],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
["rewards", KEYPATH_WILDCARD, "commission"]
],
getBlockTime: [[]],
getClusterNodes: [
[KEYPATH_WILDCARD, "featureSet"],
[KEYPATH_WILDCARD, "shredVersion"]
],
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
getInflationRate: [["foundation"], ["total"], ["validator"]],
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
["value", KEYPATH_WILDCARD, "account", ...c],
[KEYPATH_WILDCARD, "account", ...c]
]),
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
getTokenAccountBalance: [
["value", "decimals"],
["value", "uiAmount"]
],
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
"value",
KEYPATH_WILDCARD,
"account",
...c
]),
getTokenLargestAccounts: [
["value", KEYPATH_WILDCARD, "decimals"],
["value", KEYPATH_WILDCARD, "uiAmount"]
],
getTokenSupply: [
["value", "decimals"],
["value", "uiAmount"]
],
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"]
],
getVersion: [["feature-set"]],
getVoteAccounts: [
["current", KEYPATH_WILDCARD, "commission"],
["delinquent", KEYPATH_WILDCARD, "commission"]
],
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
};
}
return memoizedResponseKeypaths;
}
// src/response-patcher-bigint-upcast.ts
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
if (prohibitedKeyPath.length !== keyPath.length) {
return false;
}
for (let ii = keyPath.length - 1; ii >= 0; ii--) {
const keyPathPart = keyPath[ii];
const prohibitedKeyPathPart = prohibitedKeyPath[ii];
if (prohibitedKeyPathPart !== keyPathPart && (prohibitedKeyPathPart !== KEYPATH_WILDCARD || typeof keyPathPart !== "number")) {
return false;
}
}
return true;
});
}
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
return BigInt(value);
} else {
return value;
}
};
}
// src/response-patcher.ts
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
const allowedNumericKeyPaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName) {
const allowedNumericKeyPaths = notificationName ? getAllowedNumericKeypathsForNotification()[notificationName] : void 0;
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths ?? [])]);
const initialState = {
keyPath: []
};
return traverse(rawResponse, initialState);
}
// src/rpc-methods/index.ts
function createSolanaRpcApi(config) {
return createJsonRpcApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpc
});
}
// src/rpc-subscriptions/index.ts
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
return createJsonRpcSubscriptionsApi({
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions,
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
});
}
function createSolanaRpcSubscriptionsApi(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
}
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

15

dist/types/index.d.ts

@@ -1,13 +0,4 @@

import { IRpcApi } from '@solana/rpc-transport/dist/types/json-rpc-types';
import { GetAccountInfoApi } from './rpc-methods/getAccountInfo';
import { GetBlockHeightApi } from './rpc-methods/getBlockHeight';
import { GetBlocksApi } from './rpc-methods/getBlocks';
import { GetInflationRewardApi } from './rpc-methods/getInflationReward';
import { GetBalanceApi } from './rpc-methods/getBalance';
type Config = Readonly<{
onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;
}>;
export type SolanaRpcMethods = GetAccountInfoApi & GetBalanceApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;
export declare function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods>;
export {};
export * from './rpc-methods/index.js';
export * from './rpc-subscriptions/index.js';
export * from './transaction-error.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,7 +0,6 @@

type IntegerOverflowHandler = (keyPath: (number | string)[], value: bigint) => void;
type Patched<T> = T extends object ? {
[Property in keyof T]: Patched<T[Property]>;
} : T extends bigint ? number : T;
export declare function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T>;
export {};
import { KeyPath } from './tree-traversal.js';
export type ParamsPatcherConfig = Readonly<{
onIntegerOverflow?: (methodName: string, keyPath: KeyPath, value: bigint) => void;
}>;
export declare function getParamsPatcherForSolanaLabsRpc(config?: ParamsPatcherConfig): <T>(rawParams: T, methodName: string) => unknown;
//# sourceMappingURL=params-patcher.d.ts.map

@@ -1,3 +0,6 @@

import { createSolanaRpcApi } from './index';
import { KeyPath } from './response-patcher';
import type { IRpcSubscriptionsApi } from '@solana/rpc-transport';
import { createSolanaRpcApi } from './rpc-methods/index.js';
import { SolanaRpcSubscriptions, SolanaRpcSubscriptionsUnstable } from './rpc-subscriptions/index.js';
import { KeyPath } from './tree-traversal.js';
type AllowedNumericKeypaths<TApi> = Partial<Record<keyof TApi, readonly KeyPath[]>>;
/**

@@ -7,3 +10,9 @@ * These are keypaths at the end of which you will find a numeric value that should *not* be upcast

*/
export declare const ALLOWED_NUMERIC_KEYPATHS: Partial<Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>>;
export declare function getAllowedNumericKeypathsForNotification(): AllowedNumericKeypaths<IRpcSubscriptionsApi<SolanaRpcSubscriptions & SolanaRpcSubscriptionsUnstable>>;
/**
* These are keypaths at the end of which you will find a numeric value that should *not* be upcast
* to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.
*/
export declare function getAllowedNumericKeypathsForResponse(): AllowedNumericKeypaths<ReturnType<typeof createSolanaRpcApi>>;
export {};
//# sourceMappingURL=response-patcher-allowed-numeric-values.d.ts.map

@@ -1,5 +0,5 @@

import { createSolanaRpcApi } from './index';
import { KeyPathWildcard } from './response-patcher-types';
export type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;
import { createSolanaRpcApi } from './rpc-methods/index.js';
import { createSolanaRpcSubscriptionsApi } from './rpc-subscriptions/index.js';
export declare function patchResponseForSolanaLabsRpc<T>(rawResponse: unknown, methodName?: keyof ReturnType<typeof createSolanaRpcApi>): T;
export declare function patchResponseForSolanaLabsRpcSubscriptions<T>(rawResponse: unknown, notificationName?: keyof ReturnType<typeof createSolanaRpcSubscriptionsApi>): T;
//# sourceMappingURL=response-patcher.d.ts.map

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

export type Commitment = 'confirmed' | 'finalized' | 'processed';
import { Address } from '@solana/addresses';
import { LamportsUnsafeBeyond2Pow53Minus1, StringifiedBigInt, StringifiedNumber } from '@solana/rpc-types';
export type DataSlice = Readonly<{

@@ -6,4 +7,9 @@ offset: number;

}>;
export type MicroLamportsUnsafeBeyond2Pow53Minus1 = bigint & {
readonly __brand: unique symbol;
};
export type Slot = U64UnsafeBeyond2Pow53Minus1;
export type U64UnsafeBeyond2Pow53Minus1 = bigint;
export type SignedLamportsAsI64Unsafe = bigint;
export type F64UnsafeSeeDocumentation = number;
export type RpcResponse<TValue> = Readonly<{

@@ -15,2 +21,91 @@ context: Readonly<{

}>;
export type Base58EncodedBytes = string & {
readonly __brand: unique symbol;
};
export type Base64EncodedBytes = string & {
readonly __brand: unique symbol;
};
export type Base64EncodedZStdCompressedBytes = string & {
readonly __brand: unique symbol;
};
export type Base58EncodedDataResponse = [Base58EncodedBytes, 'base58'];
export type Base64EncodedDataResponse = [Base64EncodedBytes, 'base64'];
export type Base64EncodedZStdCompressedDataResponse = [Base64EncodedZStdCompressedBytes, 'base64+zstd'];
export type AccountInfoBase = Readonly<{
/** indicates if the account contains a program (and is strictly read-only) */
executable: boolean;
/** number of lamports assigned to this account */
lamports: LamportsUnsafeBeyond2Pow53Minus1;
/** pubkey of the program this account has been assigned to */
owner: Address;
/** the epoch at which this account will next owe rent */
rentEpoch: U64UnsafeBeyond2Pow53Minus1;
}>;
/** @deprecated */
export type AccountInfoWithBase58Bytes = Readonly<{
data: Base58EncodedBytes;
}>;
/** @deprecated */
export type AccountInfoWithBase58EncodedData = Readonly<{
data: Base58EncodedDataResponse;
}>;
export type AccountInfoWithBase64EncodedData = Readonly<{
data: Base64EncodedDataResponse;
}>;
export type AccountInfoWithBase64EncodedZStdCompressedData = Readonly<{
data: Base64EncodedZStdCompressedDataResponse;
}>;
export type AccountInfoWithJsonData = Readonly<{
data: Readonly<{
program: string;
parsed: {
info?: object;
type: string;
};
space: U64UnsafeBeyond2Pow53Minus1;
}> | Base64EncodedDataResponse;
}>;
export type AccountInfoWithPubkey<TAccount extends AccountInfoBase> = Readonly<{
account: TAccount;
pubkey: Address;
}>;
export type TokenAmount = Readonly<{
amount: StringifiedBigInt;
decimals: number;
uiAmount: number | null;
uiAmountString: StringifiedNumber;
}>;
export type TokenBalance = Readonly<{
/** Index of the account in which the token balance is provided for. */
accountIndex: number;
/** Pubkey of the token's mint. */
mint: Address;
/** Pubkey of token balance's owner. */
owner?: Address;
/** Pubkey of the Token program that owns the account. */
programId?: Address;
uiTokenAmount: TokenAmount;
}>;
type TokenAccountState = 'initialized' | 'uninitialized' | 'frozen';
export type TokenAccount = Readonly<{
mint: Address;
owner: Address;
tokenAmount: TokenAmount;
delegate?: Address;
state: TokenAccountState;
isNative: boolean;
rentExemptReserve?: TokenAmount;
delegatedAmount?: TokenAmount;
closeAuthority?: Address;
extensions?: unknown[];
}>;
export type GetProgramAccountsMemcmpFilter = Readonly<{
offset: U64UnsafeBeyond2Pow53Minus1;
bytes: string;
encoding: 'base58' | 'base64';
}>;
export type GetProgramAccountsDatasizeFilter = Readonly<{
dataSize: U64UnsafeBeyond2Pow53Minus1;
}>;
export {};
//# sourceMappingURL=common.d.ts.map

@@ -1,56 +0,9 @@

import { Base58EncodedAddress } from '@solana/keys';
import { Commitment, DataSlice, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common';
type Base58EncodedBytes = string & {
readonly __base58EncodedBytes: unique symbol;
};
type Base64EncodedBytes = string & {
readonly __base64EncodedBytes: unique symbol;
};
type Base64EncodedZStdCompressedBytes = string & {
readonly __base64EncodedZStdCompressedBytes: unique symbol;
};
type Base58EncodedDataResponse = [Base58EncodedBytes, 'base58'];
type Base64EncodedDataResponse = [Base64EncodedBytes, 'base64'];
type Base64EncodedZStdCompressedDataResponse = [Base64EncodedZStdCompressedBytes, 'base64+zstd'];
type GetAccountInfoApiResponseBase = Readonly<{
context: Readonly<{
slot: Slot;
}>;
value: Readonly<{
executable: boolean;
lamports: U64UnsafeBeyond2Pow53Minus1;
owner: Base58EncodedAddress;
rentEpoch: U64UnsafeBeyond2Pow53Minus1;
space: U64UnsafeBeyond2Pow53Minus1;
}> | null;
import { Address } from '@solana/addresses';
import type { IRpcApiMethods } from '@solana/rpc-transport';
import { Commitment } from '@solana/rpc-types';
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, DataSlice, RpcResponse, Slot } from './common.js';
type GetAccountInfoApiResponseBase = RpcResponse<AccountInfoBase | null>;
type NestInRpcResponseOrNull<T> = Readonly<{
value: T | null;
}>;
type GetAccountInfoApiResponseWithDefaultData = Readonly<{
value: Readonly<{
data: Base58EncodedBytes;
}> | null;
}>;
type GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED = Readonly<{
value: Readonly<{
data: Base58EncodedDataResponse;
}> | null;
}>;
type GetAccountInfoApiResponseWithBase64EncodedData = Readonly<{
value: Readonly<{
data: Base64EncodedDataResponse;
}> | null;
}>;
type GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData = Readonly<{
value: Readonly<{
data: Base64EncodedZStdCompressedDataResponse;
}> | null;
}>;
type GetAccountInfoApiResponseWithJsonData = Readonly<{
value: Readonly<{
data: Readonly<{
program: string;
parsed: unknown;
space: U64UnsafeBeyond2Pow53Minus1;
}> | Base64EncodedDataResponse;
}> | null;
}>;
type GetAccountInfoApiCommonConfig = Readonly<{

@@ -63,21 +16,21 @@ commitment?: Commitment;

}>;
export interface GetAccountInfoApi {
export interface GetAccountInfoApi extends IRpcApiMethods {
/**
* Returns all information associated with the account of provided public key
*/
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
encoding: 'base64';
}>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedData;
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase64EncodedData>;
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
encoding: 'base64+zstd';
}>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData;
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & Readonly<{
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase64EncodedZStdCompressedData>;
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & Readonly<{
encoding: 'jsonParsed';
}>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithJsonData;
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithJsonData>;
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{
encoding: 'base58';
}>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED;
getAccountInfo(address: Base58EncodedAddress, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithDefaultData;
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase58EncodedData>;
getAccountInfo(address: Address, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase58Bytes>;
}
export {};
//# sourceMappingURL=getAccountInfo.d.ts.map

@@ -1,9 +0,11 @@

import { Base58EncodedAddress } from '@solana/keys';
import { Commitment, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common';
type GetBalanceApiResponse = RpcResponse<U64UnsafeBeyond2Pow53Minus1>;
export interface GetBalanceApi {
import { Address } from '@solana/addresses';
import type { IRpcApiMethods } from '@solana/rpc-transport';
import { Commitment, LamportsUnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types';
import { RpcResponse, Slot } from './common.js';
type GetBalanceApiResponse = RpcResponse<LamportsUnsafeBeyond2Pow53Minus1>;
export interface GetBalanceApi extends IRpcApiMethods {
/**
* Returns the balance of the account of provided Pubkey
*/
getBalance(address: Base58EncodedAddress, config?: Readonly<{
getBalance(address: Address, config?: Readonly<{
commitment?: Commitment;

@@ -10,0 +12,0 @@ minContextSlot?: Slot;

@@ -1,4 +0,6 @@

import { U64UnsafeBeyond2Pow53Minus1, Commitment, Slot } from './common';
import type { IRpcApiMethods } from '@solana/rpc-transport';
import { Commitment } from '@solana/rpc-types';
import { Slot, U64UnsafeBeyond2Pow53Minus1 } from './common.js';
type GetBlockHeightApiResponse = U64UnsafeBeyond2Pow53Minus1;
export interface GetBlockHeightApi {
export interface GetBlockHeightApi extends IRpcApiMethods {
/**

@@ -5,0 +7,0 @@ * Returns the current block height of the node

@@ -1,4 +0,6 @@

import { Slot, Commitment } from './common';
import type { IRpcApiMethods } from '@solana/rpc-transport';
import { Commitment } from '@solana/rpc-types';
import { Slot } from './common.js';
type GetBlocksApiResponse = Slot[];
export interface GetBlocksApi {
export interface GetBlocksApi extends IRpcApiMethods {
/**

@@ -5,0 +7,0 @@ * Returns a list of confirmed blocks between two slots

@@ -1,15 +0,17 @@

import { Base58EncodedAddress } from '@solana/keys';
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common';
import { Address } from '@solana/addresses';
import type { IRpcApiMethods } from '@solana/rpc-transport';
import { Commitment, LamportsUnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types';
import { Slot, U64UnsafeBeyond2Pow53Minus1 } from './common.js';
type GetInflationRewardApiResponse = Readonly<{
amount: U64UnsafeBeyond2Pow53Minus1;
amount: LamportsUnsafeBeyond2Pow53Minus1;
commission: number;
effectiveSlot: U64UnsafeBeyond2Pow53Minus1;
effectiveSlot: Slot;
epoch: U64UnsafeBeyond2Pow53Minus1;
postBalance: U64UnsafeBeyond2Pow53Minus1;
postBalance: LamportsUnsafeBeyond2Pow53Minus1;
}>;
export interface GetInflationRewardApi {
export interface GetInflationRewardApi extends IRpcApiMethods {
/**
* Returns the current block height of the node
*/
getInflationReward(addresses: Base58EncodedAddress[], config?: Readonly<{
getInflationReward(addresses: Address[], config?: Readonly<{
commitment?: Commitment;

@@ -16,0 +18,0 @@ epoch?: U64UnsafeBeyond2Pow53Minus1;

{
"name": "@solana/rpc-core",
"version": "2.0.0-experimental.b219d97",
"version": "2.0.0-experimental.b315352",
"description": "A library for making calls to the Solana JSON RPC API",

@@ -48,32 +48,31 @@ "exports": {

],
"dependencies": {
"@solana/keys": "2.0.0-experimental.b219d97"
},
"devDependencies": {
"@solana/eslint-config-solana": "^1.0.0",
"@swc/core": "^1.3.18",
"@swc/jest": "^0.2.23",
"@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@solana/eslint-config-solana": "^1.0.2",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.3.0",
"agadoo": "^3.0.0",
"eslint": "^8.37.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.45.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock-fork": "^3.0.4",
"jest-runner-eslint": "^2.0.0",
"jest-runner-eslint": "^2.1.2",
"jest-runner-prettier": "^1.0.0",
"postcss": "^8.4.12",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"tsup": "6.7.0",
"typescript": "^5.0.3",
"prettier": "^3.1",
"tsup": "^8.0.1",
"typescript": "^5.2.2",
"version-from-git": "^1.1.1",
"@solana/rpc-transport": "2.0.0-experimental.b219d97",
"@solana/addresses": "2.0.0-experimental.b315352",
"@solana/keys": "2.0.0-experimental.b315352",
"@solana/rpc-transport": "2.0.0-experimental.b315352",
"@solana/codecs-core": "2.0.0-experimental.b315352",
"@solana/codecs-strings": "2.0.0-experimental.b315352",
"@solana/rpc-types": "2.0.0-experimental.b315352",
"build-scripts": "0.0.0",
"test-config": "0.0.0",
"tsconfig": "0.0.0"
"@solana/transactions": "2.0.0-experimental.b315352",
"tsconfig": "0.0.0",
"test-config": "0.0.0"
},

@@ -90,10 +89,11 @@ "bundlewatch": {

"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
"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",
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
"test:treeshakability:browser": "agadoo dist/index.browser.js",
"test:treeshakability:native": "agadoo dist/index.node.js",
"test:treeshakability:node": "agadoo dist/index.native.js",
"test:treeshakability:native": "agadoo dist/index.native.js",
"test:treeshakability:node": "agadoo dist/index.node.js",
"test:typecheck": "tsc --noEmit",

@@ -100,0 +100,0 @@ "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",

@@ -0,9 +1,17 @@

[![npm][npm-image]][npm-url]
[![npm-downloads][npm-downloads-image]][npm-url]
[![semantic-release][semantic-release-image]][semantic-release-url]
<br />
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
[code-style-prettier-url]: https://github.com/prettier/prettier
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/rpc-core/experimental.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/@solana/rpc-core/experimental.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@solana/rpc-core/v/experimental
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]: https://github.com/semantic-release/semantic-release
# @solana/rpc-core
This package defines a specification of the [Solana JSON-RPC](https://docs.solana.com/api/http). The inputs and outputs of each RPC method are described in terms of Typescript interfaces. You generally will not need to depend on this package directly, but rather use it as part of the RPC creation functions of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
## Contributing
As of this moment, this package does not represent a specification of the full set of Solana JSON-RPC methods. If you find that you have need of a method that has not yet been specified, we would be grateful if you submitted a specification for it.
Read the RPC method specification [contribution guide](https://github.com/solana-labs/solana-web3.js/issues/1278) to get started.

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

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