@solana/rpc-core
Advanced tools
Comparing version 2.0.0-experimental.093f058 to 2.0.0-experimental.098806e
@@ -0,3 +1,643 @@ | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/rpc-methods/index.ts | ||
// src/default-commitment.ts | ||
function applyDefaultCommitment({ | ||
commitmentPropertyName, | ||
params, | ||
optionsObjectPositionInParams, | ||
overrideCommitment | ||
}) { | ||
const paramInTargetPosition = params[optionsObjectPositionInParams]; | ||
if ( | ||
// There's no config. | ||
paramInTargetPosition === void 0 || // There is a config object. | ||
paramInTargetPosition && typeof paramInTargetPosition === "object" && !Array.isArray(paramInTargetPosition) | ||
) { | ||
if ( | ||
// The config object already has a commitment set. | ||
paramInTargetPosition && commitmentPropertyName in paramInTargetPosition | ||
) { | ||
if (!paramInTargetPosition[commitmentPropertyName] || paramInTargetPosition[commitmentPropertyName] === "finalized") { | ||
const nextParams = [...params]; | ||
const { | ||
[commitmentPropertyName]: _, | ||
// eslint-disable-line @typescript-eslint/no-unused-vars | ||
...rest | ||
} = paramInTargetPosition; | ||
if (Object.keys(rest).length > 0) { | ||
nextParams[optionsObjectPositionInParams] = rest; | ||
} else { | ||
if (optionsObjectPositionInParams === nextParams.length - 1) { | ||
nextParams.length--; | ||
} else { | ||
nextParams[optionsObjectPositionInParams] = void 0; | ||
} | ||
} | ||
return nextParams; | ||
} | ||
} else if (overrideCommitment !== "finalized") { | ||
const nextParams = [...params]; | ||
nextParams[optionsObjectPositionInParams] = { | ||
...paramInTargetPosition, | ||
[commitmentPropertyName]: overrideCommitment | ||
}; | ||
return nextParams; | ||
} | ||
} | ||
return params; | ||
} | ||
// 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/params-patcher-options-object-position-config.ts | ||
var OPTIONS_OBJECT_POSITION_BY_METHOD = { | ||
accountNotifications: 1, | ||
blockNotifications: 1, | ||
getAccountInfo: 1, | ||
getBalance: 1, | ||
getBlock: 1, | ||
getBlockHeight: 0, | ||
getBlockProduction: 0, | ||
getBlocks: 2, | ||
getBlocksWithLimit: 2, | ||
getConfirmedBlock: 1, | ||
getConfirmedBlocks: 1, | ||
getConfirmedBlocksWithLimit: 2, | ||
getConfirmedSignaturesForAddress2: 1, | ||
getConfirmedTransaction: 1, | ||
getEpochInfo: 0, | ||
getFeeCalculatorForBlockhash: 1, | ||
getFeeForMessage: 1, | ||
getFees: 1, | ||
getInflationGovernor: 0, | ||
getInflationReward: 1, | ||
getLargestAccounts: 0, | ||
getLatestBlockhash: 0, | ||
getLeaderSchedule: 1, | ||
getMinimumBalanceForRentExemption: 1, | ||
getMultipleAccounts: 1, | ||
getProgramAccounts: 1, | ||
getRecentBlockhash: 1, | ||
getSignaturesForAddress: 1, | ||
getSlot: 0, | ||
getSlotLeader: 0, | ||
getStakeActivation: 1, | ||
getStakeMinimumDelegation: 0, | ||
getSupply: 0, | ||
getTokenAccountBalance: 1, | ||
getTokenAccountsByDelegate: 2, | ||
getTokenAccountsByOwner: 2, | ||
getTokenLargestAccounts: 1, | ||
getTokenSupply: 1, | ||
getTransaction: 1, | ||
getTransactionCount: 0, | ||
getVoteAccounts: 0, | ||
isBlockhashValid: 1, | ||
logsNotifications: 1, | ||
programNotifications: 1, | ||
requestAirdrop: 2, | ||
sendTransaction: 1, | ||
signatureNotifications: 1, | ||
simulateTransaction: 1 | ||
}; | ||
// 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 defaultCommitment = config?.defaultCommitment; | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
return (rawParams, methodName) => { | ||
const traverse = getTreeWalker([ | ||
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [], | ||
downcastNodeToNumberIfBigint | ||
]); | ||
const initialState = { | ||
keyPath: [] | ||
}; | ||
const patchedParams = traverse(rawParams, initialState); | ||
if (!Array.isArray(patchedParams)) { | ||
return patchedParams; | ||
} | ||
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName]; | ||
if (optionsObjectPositionInParams == null) { | ||
return patchedParams; | ||
} | ||
return applyDefaultCommitment({ | ||
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment", | ||
optionsObjectPositionInParams, | ||
overrideCommitment: defaultCommitment, | ||
params: patchedParams | ||
}); | ||
}; | ||
} | ||
// 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 | ||
}); | ||
} | ||
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 |
@@ -0,3 +1,643 @@ | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/rpc-methods/index.ts | ||
// src/default-commitment.ts | ||
function applyDefaultCommitment({ | ||
commitmentPropertyName, | ||
params, | ||
optionsObjectPositionInParams, | ||
overrideCommitment | ||
}) { | ||
const paramInTargetPosition = params[optionsObjectPositionInParams]; | ||
if ( | ||
// There's no config. | ||
paramInTargetPosition === void 0 || // There is a config object. | ||
paramInTargetPosition && typeof paramInTargetPosition === "object" && !Array.isArray(paramInTargetPosition) | ||
) { | ||
if ( | ||
// The config object already has a commitment set. | ||
paramInTargetPosition && commitmentPropertyName in paramInTargetPosition | ||
) { | ||
if (!paramInTargetPosition[commitmentPropertyName] || paramInTargetPosition[commitmentPropertyName] === "finalized") { | ||
const nextParams = [...params]; | ||
const { | ||
[commitmentPropertyName]: _, | ||
// eslint-disable-line @typescript-eslint/no-unused-vars | ||
...rest | ||
} = paramInTargetPosition; | ||
if (Object.keys(rest).length > 0) { | ||
nextParams[optionsObjectPositionInParams] = rest; | ||
} else { | ||
if (optionsObjectPositionInParams === nextParams.length - 1) { | ||
nextParams.length--; | ||
} else { | ||
nextParams[optionsObjectPositionInParams] = void 0; | ||
} | ||
} | ||
return nextParams; | ||
} | ||
} else if (overrideCommitment !== "finalized") { | ||
const nextParams = [...params]; | ||
nextParams[optionsObjectPositionInParams] = { | ||
...paramInTargetPosition, | ||
[commitmentPropertyName]: overrideCommitment | ||
}; | ||
return nextParams; | ||
} | ||
} | ||
return params; | ||
} | ||
// 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/params-patcher-options-object-position-config.ts | ||
var OPTIONS_OBJECT_POSITION_BY_METHOD = { | ||
accountNotifications: 1, | ||
blockNotifications: 1, | ||
getAccountInfo: 1, | ||
getBalance: 1, | ||
getBlock: 1, | ||
getBlockHeight: 0, | ||
getBlockProduction: 0, | ||
getBlocks: 2, | ||
getBlocksWithLimit: 2, | ||
getConfirmedBlock: 1, | ||
getConfirmedBlocks: 1, | ||
getConfirmedBlocksWithLimit: 2, | ||
getConfirmedSignaturesForAddress2: 1, | ||
getConfirmedTransaction: 1, | ||
getEpochInfo: 0, | ||
getFeeCalculatorForBlockhash: 1, | ||
getFeeForMessage: 1, | ||
getFees: 1, | ||
getInflationGovernor: 0, | ||
getInflationReward: 1, | ||
getLargestAccounts: 0, | ||
getLatestBlockhash: 0, | ||
getLeaderSchedule: 1, | ||
getMinimumBalanceForRentExemption: 1, | ||
getMultipleAccounts: 1, | ||
getProgramAccounts: 1, | ||
getRecentBlockhash: 1, | ||
getSignaturesForAddress: 1, | ||
getSlot: 0, | ||
getSlotLeader: 0, | ||
getStakeActivation: 1, | ||
getStakeMinimumDelegation: 0, | ||
getSupply: 0, | ||
getTokenAccountBalance: 1, | ||
getTokenAccountsByDelegate: 2, | ||
getTokenAccountsByOwner: 2, | ||
getTokenLargestAccounts: 1, | ||
getTokenSupply: 1, | ||
getTransaction: 1, | ||
getTransactionCount: 0, | ||
getVoteAccounts: 0, | ||
isBlockhashValid: 1, | ||
logsNotifications: 1, | ||
programNotifications: 1, | ||
requestAirdrop: 2, | ||
sendTransaction: 1, | ||
signatureNotifications: 1, | ||
simulateTransaction: 1 | ||
}; | ||
// 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 defaultCommitment = config?.defaultCommitment; | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
return (rawParams, methodName) => { | ||
const traverse = getTreeWalker([ | ||
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [], | ||
downcastNodeToNumberIfBigint | ||
]); | ||
const initialState = { | ||
keyPath: [] | ||
}; | ||
const patchedParams = traverse(rawParams, initialState); | ||
if (!Array.isArray(patchedParams)) { | ||
return patchedParams; | ||
} | ||
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName]; | ||
if (optionsObjectPositionInParams == null) { | ||
return patchedParams; | ||
} | ||
return applyDefaultCommitment({ | ||
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment", | ||
optionsObjectPositionInParams, | ||
overrideCommitment: defaultCommitment, | ||
params: patchedParams | ||
}); | ||
}; | ||
} | ||
// 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 | ||
}); | ||
} | ||
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 |
@@ -0,3 +1,643 @@ | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/rpc-methods/index.ts | ||
// src/default-commitment.ts | ||
function applyDefaultCommitment({ | ||
commitmentPropertyName, | ||
params, | ||
optionsObjectPositionInParams, | ||
overrideCommitment | ||
}) { | ||
const paramInTargetPosition = params[optionsObjectPositionInParams]; | ||
if ( | ||
// There's no config. | ||
paramInTargetPosition === void 0 || // There is a config object. | ||
paramInTargetPosition && typeof paramInTargetPosition === "object" && !Array.isArray(paramInTargetPosition) | ||
) { | ||
if ( | ||
// The config object already has a commitment set. | ||
paramInTargetPosition && commitmentPropertyName in paramInTargetPosition | ||
) { | ||
if (!paramInTargetPosition[commitmentPropertyName] || paramInTargetPosition[commitmentPropertyName] === "finalized") { | ||
const nextParams = [...params]; | ||
const { | ||
[commitmentPropertyName]: _, | ||
// eslint-disable-line @typescript-eslint/no-unused-vars | ||
...rest | ||
} = paramInTargetPosition; | ||
if (Object.keys(rest).length > 0) { | ||
nextParams[optionsObjectPositionInParams] = rest; | ||
} else { | ||
if (optionsObjectPositionInParams === nextParams.length - 1) { | ||
nextParams.length--; | ||
} else { | ||
nextParams[optionsObjectPositionInParams] = void 0; | ||
} | ||
} | ||
return nextParams; | ||
} | ||
} else if (overrideCommitment !== "finalized") { | ||
const nextParams = [...params]; | ||
nextParams[optionsObjectPositionInParams] = { | ||
...paramInTargetPosition, | ||
[commitmentPropertyName]: overrideCommitment | ||
}; | ||
return nextParams; | ||
} | ||
} | ||
return params; | ||
} | ||
// 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/params-patcher-options-object-position-config.ts | ||
var OPTIONS_OBJECT_POSITION_BY_METHOD = { | ||
accountNotifications: 1, | ||
blockNotifications: 1, | ||
getAccountInfo: 1, | ||
getBalance: 1, | ||
getBlock: 1, | ||
getBlockHeight: 0, | ||
getBlockProduction: 0, | ||
getBlocks: 2, | ||
getBlocksWithLimit: 2, | ||
getConfirmedBlock: 1, | ||
getConfirmedBlocks: 1, | ||
getConfirmedBlocksWithLimit: 2, | ||
getConfirmedSignaturesForAddress2: 1, | ||
getConfirmedTransaction: 1, | ||
getEpochInfo: 0, | ||
getFeeCalculatorForBlockhash: 1, | ||
getFeeForMessage: 1, | ||
getFees: 1, | ||
getInflationGovernor: 0, | ||
getInflationReward: 1, | ||
getLargestAccounts: 0, | ||
getLatestBlockhash: 0, | ||
getLeaderSchedule: 1, | ||
getMinimumBalanceForRentExemption: 1, | ||
getMultipleAccounts: 1, | ||
getProgramAccounts: 1, | ||
getRecentBlockhash: 1, | ||
getSignaturesForAddress: 1, | ||
getSlot: 0, | ||
getSlotLeader: 0, | ||
getStakeActivation: 1, | ||
getStakeMinimumDelegation: 0, | ||
getSupply: 0, | ||
getTokenAccountBalance: 1, | ||
getTokenAccountsByDelegate: 2, | ||
getTokenAccountsByOwner: 2, | ||
getTokenLargestAccounts: 1, | ||
getTokenSupply: 1, | ||
getTransaction: 1, | ||
getTransactionCount: 0, | ||
getVoteAccounts: 0, | ||
isBlockhashValid: 1, | ||
logsNotifications: 1, | ||
programNotifications: 1, | ||
requestAirdrop: 2, | ||
sendTransaction: 1, | ||
signatureNotifications: 1, | ||
simulateTransaction: 1 | ||
}; | ||
// 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 defaultCommitment = config?.defaultCommitment; | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
return (rawParams, methodName) => { | ||
const traverse = getTreeWalker([ | ||
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [], | ||
downcastNodeToNumberIfBigint | ||
]); | ||
const initialState = { | ||
keyPath: [] | ||
}; | ||
const patchedParams = traverse(rawParams, initialState); | ||
if (!Array.isArray(patchedParams)) { | ||
return patchedParams; | ||
} | ||
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName]; | ||
if (optionsObjectPositionInParams == null) { | ||
return patchedParams; | ||
} | ||
return applyDefaultCommitment({ | ||
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment", | ||
optionsObjectPositionInParams, | ||
overrideCommitment: defaultCommitment, | ||
params: patchedParams | ||
}); | ||
}; | ||
} | ||
// 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 | ||
}); | ||
} | ||
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 |
@@ -1,2 +0,4 @@ | ||
export * from './types/jsonRpcApi'; | ||
export * from './rpc-methods/index.js'; | ||
export * from './rpc-subscriptions/index.js'; | ||
export * from './transaction-error.js'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@solana/rpc-core", | ||
"version": "2.0.0-experimental.093f058", | ||
"version": "2.0.0-experimental.098806e", | ||
"description": "A library for making calls to the Solana JSON RPC API", | ||
@@ -49,26 +49,29 @@ "exports": { | ||
"dependencies": { | ||
"@solana/keys": "2.0.0-experimental.093f058" | ||
"@solana/addresses": "2.0.0-experimental.098806e", | ||
"@solana/codecs-core": "2.0.0-experimental.098806e", | ||
"@solana/codecs-strings": "2.0.0-experimental.098806e", | ||
"@solana/keys": "2.0.0-experimental.098806e", | ||
"@solana/rpc-parsed-types": "2.0.0-experimental.098806e", | ||
"@solana/rpc-transport": "2.0.0-experimental.098806e", | ||
"@solana/rpc-types": "2.0.0-experimental.098806e", | ||
"@solana/transactions": "2.0.0-experimental.098806e" | ||
}, | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^0.0.4", | ||
"@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", | ||
"eslint-plugin-jest": "^27.1.5", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"@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.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-runner-eslint": "^2.0.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-fetch-mock-fork": "^3.0.4", | ||
"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", | ||
"turbo": "^1.6.3", | ||
"typescript": "^4.9", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
"version-from-git": "^1.1.1", | ||
@@ -89,12 +92,15 @@ "build-scripts": "0.0.0", | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json", | ||
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"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:typecheck": "tsc --noEmit" | ||
"test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:treeshakability:node": "agadoo dist/index.node.js", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
601311
21
168
6278
1
18
8
1
+ Added@solana/addresses@2.0.0-experimental.098806e(transitive)
+ Added@solana/assertions@2.0.0-experimental.098806e(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.098806e(transitive)
+ Added@solana/codecs-data-structures@2.0.0-experimental.098806e(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.098806e(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.098806e(transitive)
+ Added@solana/functional@2.0.0-experimental.098806e(transitive)
+ Added@solana/keys@2.0.0-experimental.098806e(transitive)
+ Added@solana/rpc-parsed-types@2.0.0-experimental.098806e(transitive)
+ Added@solana/rpc-transport@2.0.0-experimental.098806e(transitive)
+ Added@solana/rpc-types@2.0.0-experimental.098806e(transitive)
+ Added@solana/transactions@2.0.0-experimental.098806e(transitive)
+ Addedfastestsmallesttextencoderdecoder@1.0.22(transitive)
+ Addedws@8.18.0(transitive)
- Removed@solana/keys@2.0.0-experimental.093f058(transitive)
- Removedbase-x@4.0.0(transitive)
- Removedbs58@5.0.0(transitive)