@solana/rpc-core
Advanced tools
Comparing version 2.0.0-experimental.3536b48 to 2.0.0-experimental.35de86b
@@ -1,101 +0,397 @@ | ||
import { base58 } from '@metaplex-foundation/umi-serializers'; | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/lamports.ts | ||
var maxU64Value = 18446744073709551615n; | ||
function assertIsLamports(putativeLamports) { | ||
if (putativeLamports < 0) { | ||
throw new Error("Input for 64-bit unsigned integer cannot be negative"); | ||
// 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; | ||
} | ||
} | ||
if (putativeLamports > maxU64Value) { | ||
throw new Error("Input number is too large to be represented as a 64-bit unsigned integer"); | ||
} | ||
return params; | ||
} | ||
// 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); | ||
// 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 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 | ||
// 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 memoizedKeypaths; | ||
function getAllowedNumericKeypaths() { | ||
if (!memoizedKeypaths) { | ||
const 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" | ||
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"] | ||
], | ||
[ | ||
"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"] | ||
]; | ||
const 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"] | ||
]; | ||
memoizedKeypaths = { | ||
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]), | ||
@@ -276,110 +572,73 @@ getBlock: [ | ||
} | ||
return memoizedKeypaths; | ||
return memoizedResponseKeypaths; | ||
} | ||
// 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)); | ||
// 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 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); | ||
function getBigIntUpcastVisitor(allowedNumericKeyPaths) { | ||
return function upcastNodeToBigIntIfNumber(value, { keyPath }) { | ||
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
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 && // Only try to upcast an Integer to `bigint` | ||
Number.isInteger(value)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
}; | ||
} | ||
// src/response-patcher.ts | ||
function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
const allowedKeypaths = methodName ? getAllowedNumericKeypaths()[methodName] : void 0; | ||
return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
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 new Proxy({}, { | ||
defineProperty() { | ||
return false; | ||
}, | ||
deleteProperty() { | ||
return false; | ||
}, | ||
get(...args) { | ||
const [_, p] = args; | ||
const methodName = p.toString(); | ||
return function(...rawParams) { | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
const params = patchParamsForSolanaLabsRpc( | ||
rawParams, | ||
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
); | ||
return { | ||
methodName, | ||
params, | ||
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
}; | ||
}; | ||
} | ||
return createJsonRpcApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpc | ||
}); | ||
} | ||
// src/stringified-bigint.ts | ||
function assertIsStringifiedBigInt(putativeBigInt) { | ||
try { | ||
BigInt(putativeBigInt); | ||
} catch (e) { | ||
throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_INTERNAL(config) { | ||
return createJsonRpcSubscriptionsApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions, | ||
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"), | ||
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe") | ||
}); | ||
} | ||
function assertIsTransactionSignature(putativeTransactionSignature) { | ||
try { | ||
if ( | ||
// Lowest value (64 bytes of zeroes) | ||
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255) | ||
putativeTransactionSignature.length > 88 | ||
) { | ||
throw new Error("Expected input string to decode to a byte array of length 64."); | ||
} | ||
const bytes = base58.serialize(putativeTransactionSignature); | ||
const numBytes = bytes.byteLength; | ||
if (numBytes !== 64) { | ||
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
// src/unix-timestamp.ts | ||
function assertIsUnixTimestamp(putativeTimestamp) { | ||
try { | ||
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) { | ||
throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]"); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
export { assertIsLamports, assertIsStringifiedBigInt, assertIsTransactionSignature, assertIsUnixTimestamp, createSolanaRpcApi }; | ||
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -1,101 +0,397 @@ | ||
import { base58 } from '@metaplex-foundation/umi-serializers'; | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/lamports.ts | ||
var maxU64Value = 18446744073709551615n; | ||
function assertIsLamports(putativeLamports) { | ||
if (putativeLamports < 0) { | ||
throw new Error("Input for 64-bit unsigned integer cannot be negative"); | ||
// 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; | ||
} | ||
} | ||
if (putativeLamports > maxU64Value) { | ||
throw new Error("Input number is too large to be represented as a 64-bit unsigned integer"); | ||
} | ||
return params; | ||
} | ||
// 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); | ||
// 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 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 | ||
// 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 memoizedKeypaths; | ||
function getAllowedNumericKeypaths() { | ||
if (!memoizedKeypaths) { | ||
const 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" | ||
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"] | ||
], | ||
[ | ||
"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"] | ||
]; | ||
const 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"] | ||
]; | ||
memoizedKeypaths = { | ||
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]), | ||
@@ -276,110 +572,73 @@ getBlock: [ | ||
} | ||
return memoizedKeypaths; | ||
return memoizedResponseKeypaths; | ||
} | ||
// 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)); | ||
// 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 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); | ||
function getBigIntUpcastVisitor(allowedNumericKeyPaths) { | ||
return function upcastNodeToBigIntIfNumber(value, { keyPath }) { | ||
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
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 && // Only try to upcast an Integer to `bigint` | ||
Number.isInteger(value)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
}; | ||
} | ||
// src/response-patcher.ts | ||
function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
const allowedKeypaths = methodName ? getAllowedNumericKeypaths()[methodName] : void 0; | ||
return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
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 new Proxy({}, { | ||
defineProperty() { | ||
return false; | ||
}, | ||
deleteProperty() { | ||
return false; | ||
}, | ||
get(...args) { | ||
const [_, p] = args; | ||
const methodName = p.toString(); | ||
return function(...rawParams) { | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
const params = patchParamsForSolanaLabsRpc( | ||
rawParams, | ||
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
); | ||
return { | ||
methodName, | ||
params, | ||
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
}; | ||
}; | ||
} | ||
return createJsonRpcApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpc | ||
}); | ||
} | ||
// src/stringified-bigint.ts | ||
function assertIsStringifiedBigInt(putativeBigInt) { | ||
try { | ||
BigInt(putativeBigInt); | ||
} catch (e) { | ||
throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_INTERNAL(config) { | ||
return createJsonRpcSubscriptionsApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions, | ||
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"), | ||
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe") | ||
}); | ||
} | ||
function assertIsTransactionSignature(putativeTransactionSignature) { | ||
try { | ||
if ( | ||
// Lowest value (64 bytes of zeroes) | ||
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255) | ||
putativeTransactionSignature.length > 88 | ||
) { | ||
throw new Error("Expected input string to decode to a byte array of length 64."); | ||
} | ||
const bytes = base58.serialize(putativeTransactionSignature); | ||
const numBytes = bytes.byteLength; | ||
if (numBytes !== 64) { | ||
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
// src/unix-timestamp.ts | ||
function assertIsUnixTimestamp(putativeTimestamp) { | ||
try { | ||
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) { | ||
throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]"); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
export { assertIsLamports, assertIsStringifiedBigInt, assertIsTransactionSignature, assertIsUnixTimestamp, createSolanaRpcApi }; | ||
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -1,101 +0,397 @@ | ||
import { base58 } from '@metaplex-foundation/umi-serializers'; | ||
import { createJsonRpcApi, createJsonRpcSubscriptionsApi } from '@solana/rpc-transport'; | ||
// src/lamports.ts | ||
var maxU64Value = 18446744073709551615n; | ||
function assertIsLamports(putativeLamports) { | ||
if (putativeLamports < 0) { | ||
throw new Error("Input for 64-bit unsigned integer cannot be negative"); | ||
// 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; | ||
} | ||
} | ||
if (putativeLamports > maxU64Value) { | ||
throw new Error("Input number is too large to be represented as a 64-bit unsigned integer"); | ||
} | ||
return params; | ||
} | ||
// 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); | ||
// 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 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 | ||
// 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 memoizedKeypaths; | ||
function getAllowedNumericKeypaths() { | ||
if (!memoizedKeypaths) { | ||
const 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" | ||
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"] | ||
], | ||
[ | ||
"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"] | ||
]; | ||
const 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"] | ||
]; | ||
memoizedKeypaths = { | ||
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]), | ||
@@ -276,110 +572,73 @@ getBlock: [ | ||
} | ||
return memoizedKeypaths; | ||
return memoizedResponseKeypaths; | ||
} | ||
// 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)); | ||
// 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 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); | ||
function getBigIntUpcastVisitor(allowedNumericKeyPaths) { | ||
return function upcastNodeToBigIntIfNumber(value, { keyPath }) { | ||
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
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 && // Only try to upcast an Integer to `bigint` | ||
Number.isInteger(value)) { | ||
return BigInt(value); | ||
} else { | ||
return value; | ||
} | ||
}; | ||
} | ||
// src/response-patcher.ts | ||
function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
const allowedKeypaths = methodName ? getAllowedNumericKeypaths()[methodName] : void 0; | ||
return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
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 new Proxy({}, { | ||
defineProperty() { | ||
return false; | ||
}, | ||
deleteProperty() { | ||
return false; | ||
}, | ||
get(...args) { | ||
const [_, p] = args; | ||
const methodName = p.toString(); | ||
return function(...rawParams) { | ||
const handleIntegerOverflow = config?.onIntegerOverflow; | ||
const params = patchParamsForSolanaLabsRpc( | ||
rawParams, | ||
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
); | ||
return { | ||
methodName, | ||
params, | ||
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
}; | ||
}; | ||
} | ||
return createJsonRpcApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpc | ||
}); | ||
} | ||
// src/stringified-bigint.ts | ||
function assertIsStringifiedBigInt(putativeBigInt) { | ||
try { | ||
BigInt(putativeBigInt); | ||
} catch (e) { | ||
throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_INTERNAL(config) { | ||
return createJsonRpcSubscriptionsApi({ | ||
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config), | ||
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions, | ||
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"), | ||
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe") | ||
}); | ||
} | ||
function assertIsTransactionSignature(putativeTransactionSignature) { | ||
try { | ||
if ( | ||
// Lowest value (64 bytes of zeroes) | ||
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255) | ||
putativeTransactionSignature.length > 88 | ||
) { | ||
throw new Error("Expected input string to decode to a byte array of length 64."); | ||
} | ||
const bytes = base58.serialize(putativeTransactionSignature); | ||
const numBytes = bytes.byteLength; | ||
if (numBytes !== 64) { | ||
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
// src/unix-timestamp.ts | ||
function assertIsUnixTimestamp(putativeTimestamp) { | ||
try { | ||
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) { | ||
throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]"); | ||
} | ||
} catch (e) { | ||
throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, { | ||
cause: e | ||
}); | ||
} | ||
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) { | ||
return createSolanaRpcSubscriptionsApi_INTERNAL(config); | ||
} | ||
export { assertIsLamports, assertIsStringifiedBigInt, assertIsTransactionSignature, assertIsUnixTimestamp, createSolanaRpcApi }; | ||
export { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_INTERNAL, createSolanaRpcSubscriptionsApi_UNSTABLE }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -1,6 +0,4 @@ | ||
export * from './lamports'; | ||
export * from './rpc-methods'; | ||
export * from './stringified-bigint'; | ||
export * from './transaction-signature'; | ||
export * from './unix-timestamp'; | ||
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,8 @@ | ||
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 { Commitment } from '@solana/rpc-types'; | ||
import { KeyPath } from './tree-traversal.js'; | ||
export type ParamsPatcherConfig = Readonly<{ | ||
defaultCommitment?: Commitment; | ||
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,4 +0,6 @@ | ||
import { KeyPath } from './response-patcher'; | ||
import { createSolanaRpcApi } from './rpc-methods'; | ||
type AllowedNumericKeypaths = Partial<Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>>; | ||
import type { IRpcSubscriptionsApi } from '@solana/rpc-types'; | ||
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[]>>; | ||
/** | ||
@@ -8,4 +10,9 @@ * These are keypaths at the end of which you will find a numeric value that should *not* be upcast | ||
*/ | ||
export declare function getAllowedNumericKeypaths(): AllowedNumericKeypaths; | ||
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 { KeyPathWildcard } from './response-patcher-types'; | ||
import { createSolanaRpcApi } from './rpc-methods'; | ||
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,7 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { StringifiedBigInt } from '../stringified-bigint'; | ||
import { StringifiedNumber } from '../stringified-number'; | ||
import { TransactionError } from '../transaction-error'; | ||
export type Commitment = 'confirmed' | 'finalized' | 'processed'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Base58EncodedBytes, Base58EncodedDataResponse, Base64EncodedDataResponse, Base64EncodedZStdCompressedDataResponse, LamportsUnsafeBeyond2Pow53Minus1, TokenAmount, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
export type DataSlice = Readonly<{ | ||
@@ -14,27 +10,4 @@ offset: number; | ||
}; | ||
export type Slot = U64UnsafeBeyond2Pow53Minus1; | ||
export type U64UnsafeBeyond2Pow53Minus1 = bigint; | ||
export type SignedLamportsAsI64Unsafe = bigint; | ||
export type F64UnsafeSeeDocumentation = number; | ||
export type RpcResponse<TValue> = Readonly<{ | ||
context: Readonly<{ | ||
slot: Slot; | ||
}>; | ||
value: TValue; | ||
}>; | ||
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 Base58EncodedTransactionSignature = string & { | ||
readonly __brand: unique symbol; | ||
}; | ||
export type AccountInfoBase = Readonly<{ | ||
@@ -46,3 +19,3 @@ /** indicates if the account contains a program (and is strictly read-only) */ | ||
/** pubkey of the program this account has been assigned to */ | ||
owner: Base58EncodedAddress; | ||
owner: Address; | ||
/** the epoch at which this account will next owe rent */ | ||
@@ -68,3 +41,6 @@ rentEpoch: U64UnsafeBeyond2Pow53Minus1; | ||
program: string; | ||
parsed: unknown; | ||
parsed: { | ||
info?: object; | ||
type: string; | ||
}; | ||
space: U64UnsafeBeyond2Pow53Minus1; | ||
@@ -75,10 +51,4 @@ }> | Base64EncodedDataResponse; | ||
account: TAccount; | ||
pubkey: Base58EncodedAddress; | ||
pubkey: Address; | ||
}>; | ||
export type TokenAmount = Readonly<{ | ||
amount: StringifiedBigInt; | ||
decimals: number; | ||
uiAmount: number | null; | ||
uiAmountString: StringifiedNumber; | ||
}>; | ||
export type TokenBalance = Readonly<{ | ||
@@ -88,48 +58,17 @@ /** Index of the account in which the token balance is provided for. */ | ||
/** Pubkey of the token's mint. */ | ||
mint: Base58EncodedAddress; | ||
mint: Address; | ||
/** Pubkey of token balance's owner. */ | ||
owner?: Base58EncodedAddress; | ||
owner?: Address; | ||
/** Pubkey of the Token program that owns the account. */ | ||
programId?: Base58EncodedAddress; | ||
programId?: Address; | ||
uiTokenAmount: TokenAmount; | ||
}>; | ||
type TokenAccountState = 'initialized' | 'uninitialized' | 'frozen'; | ||
export type TokenAccount = Readonly<{ | ||
mint: Base58EncodedAddress; | ||
owner: Base58EncodedAddress; | ||
tokenAmount: TokenAmount; | ||
delegate?: Base58EncodedAddress; | ||
state: TokenAccountState; | ||
isNative: boolean; | ||
rentExemptReserve?: TokenAmount; | ||
delegatedAmount?: TokenAmount; | ||
closeAuthority?: Base58EncodedAddress; | ||
extensions?: unknown[]; | ||
export type GetProgramAccountsMemcmpFilter = Readonly<{ | ||
offset: U64UnsafeBeyond2Pow53Minus1; | ||
bytes: string; | ||
encoding: 'base58' | 'base64'; | ||
}>; | ||
type RewardBase = Readonly<{ | ||
/** The public key of the account that received the reward */ | ||
pubkey: Base58EncodedAddress; | ||
/** number of reward lamports credited or debited by the account */ | ||
lamports: SignedLamportsAsI64Unsafe; | ||
/** account balance in lamports after the reward was applied */ | ||
postBalance: LamportsUnsafeBeyond2Pow53Minus1; | ||
export type GetProgramAccountsDatasizeFilter = Readonly<{ | ||
dataSize: U64UnsafeBeyond2Pow53Minus1; | ||
}>; | ||
export type Reward = (RewardBase & Readonly<{ | ||
/** type of reward */ | ||
rewardType: 'fee' | 'rent'; | ||
}>) | ||
/** Commission is present only for voting and staking rewards */ | ||
| (RewardBase & Readonly<{ | ||
/** type of reward */ | ||
rewardType: 'voting' | 'staking'; | ||
/** vote account commission when the reward was credited */ | ||
commission: number; | ||
}>); | ||
/** @deprecated */ | ||
export type TransactionStatus = { | ||
Ok: null; | ||
} | { | ||
Err: TransactionError; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=common.d.ts.map |
@@ -1,3 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, Commitment, DataSlice, RpcResponse, Slot } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, DataSlice } from './common.js'; | ||
type GetAccountInfoApiResponseBase = RpcResponse<AccountInfoBase | null>; | ||
@@ -14,21 +15,21 @@ type NestInRpcResponseOrNull<T> = Readonly<{ | ||
}>; | ||
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 & NestInRpcResponseOrNull<AccountInfoWithBase64EncodedData>; | ||
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase64EncodedZStdCompressedData>; | ||
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & Readonly<{ | ||
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithJsonData>; | ||
getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
getAccountInfo(address: Address, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
}>): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase58EncodedData>; | ||
getAccountInfo(address: Base58EncodedAddress, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase58Bytes>; | ||
getAccountInfo(address: Address, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & NestInRpcResponseOrNull<AccountInfoWithBase58Bytes>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getAccountInfo.d.ts.map |
@@ -1,10 +0,9 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, RpcResponse, Slot } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, RpcResponse, Slot } from '@solana/rpc-types'; | ||
type GetBalanceApiResponse = RpcResponse<LamportsUnsafeBeyond2Pow53Minus1>; | ||
export interface GetBalanceApi { | ||
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; | ||
@@ -11,0 +10,0 @@ minContextSlot?: Slot; |
@@ -1,223 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Blockhash, TransactionVersion } from '@solana/transactions'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { TransactionError } from '../transaction-error'; | ||
import { UnixTimestamp } from '../unix-timestamp'; | ||
import { Base58EncodedBytes, Base58EncodedDataResponse, Base64EncodedDataResponse, Commitment, Reward, Slot, TokenBalance, TransactionStatus, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
type AddressTableLookup = Readonly<{ | ||
/** public key for an address lookup table account. */ | ||
accountKey: Base58EncodedAddress; | ||
/** List of indices used to load addresses of writable accounts from a lookup table. */ | ||
writableIndexes: readonly number[]; | ||
/** List of indices used to load addresses of readonly accounts from a lookup table. */ | ||
readableIndexes: readonly number[]; | ||
}>; | ||
type ParsedTransactionInstruction = Readonly<{ | ||
parsed: { | ||
type: string; | ||
info?: object; | ||
}; | ||
program: string; | ||
programId: Base58EncodedAddress; | ||
}>; | ||
type PartiallyDecodedTransactionInstruction = Readonly<{ | ||
accounts: readonly Base58EncodedAddress[]; | ||
data: Base58EncodedBytes; | ||
programId: Base58EncodedAddress; | ||
}>; | ||
type ReturnData = { | ||
/** the program that generated the return data */ | ||
programId: Base58EncodedAddress; | ||
/** the return data itself */ | ||
data: Base64EncodedDataResponse; | ||
}; | ||
type TransactionInstruction = Readonly<{ | ||
accounts: readonly number[]; | ||
data: Base58EncodedBytes; | ||
programIdIndex: number; | ||
}>; | ||
type TransactionParsedAccountLegacy = Readonly<{ | ||
pubkey: Base58EncodedAddress; | ||
signer: boolean; | ||
source: 'transaction'; | ||
writable: boolean; | ||
}>; | ||
type TransactionParsedAccountVersioned = Readonly<{ | ||
pubkey: Base58EncodedAddress; | ||
signer: boolean; | ||
source: 'lookupTable' | 'transaction'; | ||
writable: boolean; | ||
}>; | ||
type TransactionForAccountsMetaBase = Readonly<{ | ||
/** Error if transaction failed, null if transaction succeeded. */ | ||
err: TransactionError | null; | ||
/** fee this transaction was charged */ | ||
fee: LamportsUnsafeBeyond2Pow53Minus1; | ||
/** array of account balances from before the transaction was processed */ | ||
preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; | ||
/** array of account balances after the transaction was processed */ | ||
postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; | ||
/** List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */ | ||
preTokenBalances?: readonly TokenBalance[]; | ||
/** List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */ | ||
postTokenBalances?: readonly TokenBalance[]; | ||
/** | ||
* Transaction status | ||
* @deprecated | ||
*/ | ||
status: TransactionStatus; | ||
}>; | ||
type TransactionForAccounts<TMaxSupportedTransactionVersion extends TransactionVersion | void> = TMaxSupportedTransactionVersion extends void ? Readonly<{ | ||
/** Transaction partial meta */ | ||
meta: TransactionForAccountsMetaBase | null; | ||
/** Partial transactions */ | ||
transaction: Readonly<{ | ||
/** Parsed accounts */ | ||
accountKeys: readonly TransactionParsedAccountLegacy[]; | ||
/** Account signatures */ | ||
signatures: readonly Base58EncodedBytes[]; | ||
}>; | ||
}> : Readonly<{ | ||
/** Transaction partial meta */ | ||
meta: TransactionForAccountsMetaBase | null; | ||
/** Partial transactions */ | ||
transaction: Readonly<{ | ||
/** Parsed accounts */ | ||
accountKeys: readonly TransactionParsedAccountVersioned[]; | ||
/** Account signatures */ | ||
signatures: readonly Base58EncodedBytes[]; | ||
}>; | ||
/** The transaction version */ | ||
version: TransactionVersion; | ||
}>; | ||
type TransactionForFullMetaBase = Readonly<{ | ||
/** number of compute units consumed by the transaction */ | ||
computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; | ||
/** Error if transaction failed, null if transaction succeeded. */ | ||
err: TransactionError | null; | ||
/** fee this transaction was charged */ | ||
fee: LamportsUnsafeBeyond2Pow53Minus1; | ||
/** array of string log messages or null if log message recording was not enabled during this transaction */ | ||
logMessages: readonly string[] | null; | ||
/** array of account balances from before the transaction was processed */ | ||
preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; | ||
/** array of account balances after the transaction was processed */ | ||
postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; | ||
/** List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */ | ||
preTokenBalances?: readonly TokenBalance[]; | ||
/** List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */ | ||
postTokenBalances?: readonly TokenBalance[]; | ||
/** the most-recent return data generated by an instruction in the transaction */ | ||
returnData?: ReturnData; | ||
/** transaction-level rewards */ | ||
rewards: readonly Reward[] | null; | ||
/** | ||
* Transaction status | ||
* @deprecated | ||
*/ | ||
status: TransactionStatus; | ||
}>; | ||
type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{ | ||
innerInstructions: readonly Readonly<{ | ||
/** The index of the instruction in the transaction */ | ||
index: number; | ||
/** The instruction */ | ||
instructions: readonly TransactionInstruction[]; | ||
}>[]; | ||
}>; | ||
type TransactionForFullMetaInnerInstructionsParsed = Readonly<{ | ||
innerInstructions: readonly Readonly<{ | ||
/** The index of the instruction in the transaction */ | ||
index: number; | ||
/** The instruction */ | ||
instructions: readonly (ParsedTransactionInstruction | PartiallyDecodedTransactionInstruction)[]; | ||
}>[]; | ||
}>; | ||
type TransactionForFullMetaLoadedAddresses = Readonly<{ | ||
/** Addresses loaded from lookup tables */ | ||
loadedAddresses: { | ||
writable: readonly Base58EncodedAddress[]; | ||
readonly: readonly Base58EncodedAddress[]; | ||
}; | ||
}>; | ||
type TransactionForFullTransactionAddressTableLookups = Readonly<{ | ||
message: { | ||
addressTableLookups?: readonly AddressTableLookup[] | null; | ||
}; | ||
}>; | ||
type TransactionForFullBase58<TMaxSupportedTransactionVersion extends TransactionVersion | void> = TMaxSupportedTransactionVersion extends void ? Readonly<{ | ||
/** Transaction meta */ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed) | null; | ||
/** Partial transactions */ | ||
transaction: Base58EncodedDataResponse; | ||
}> : Readonly<{ | ||
/** Transaction meta */ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed & TransactionForFullMetaLoadedAddresses) | null; | ||
/** Partial transactions */ | ||
transaction: Base58EncodedDataResponse; | ||
/** The transaction version */ | ||
version: TransactionVersion; | ||
}>; | ||
type TransactionForFullBase64<TMaxSupportedTransactionVersion extends TransactionVersion | void> = TMaxSupportedTransactionVersion extends void ? Readonly<{ | ||
/** Transaction meta */ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed) | null; | ||
/** Partial transactions */ | ||
transaction: Base64EncodedDataResponse; | ||
}> : Readonly<{ | ||
/** Transaction meta */ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed & TransactionForFullMetaLoadedAddresses) | null; | ||
/** Partial transactions */ | ||
transaction: Base64EncodedDataResponse; | ||
/** The transaction version */ | ||
version: TransactionVersion; | ||
}>; | ||
type TransactionForFullTransactionJsonParsedBase = Readonly<{ | ||
message: { | ||
header: { | ||
numReadonlySignedAccounts: number; | ||
numReadonlyUnsignedAccounts: number; | ||
numRequiredSignatures: number; | ||
}; | ||
instructions: readonly (ParsedTransactionInstruction | PartiallyDecodedTransactionInstruction)[]; | ||
recentBlockhash: Blockhash; | ||
}; | ||
signatures: readonly Base58EncodedBytes[]; | ||
}>; | ||
type TransactionForFullJsonParsed<TMaxSupportedTransactionVersion extends TransactionVersion | void> = TMaxSupportedTransactionVersion extends void ? Readonly<{ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsParsed) | null; | ||
transaction: TransactionForFullTransactionJsonParsedBase & { | ||
message: Readonly<{ | ||
accountKeys: readonly TransactionParsedAccountLegacy[]; | ||
}>; | ||
}; | ||
}> : Readonly<{ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsParsed & TransactionForFullMetaLoadedAddresses) | null; | ||
transaction: TransactionForFullTransactionJsonParsedBase & { | ||
message: Readonly<{ | ||
accountKeys: readonly TransactionParsedAccountLegacy[]; | ||
}>; | ||
}; | ||
version: TransactionVersion; | ||
}>; | ||
type TransactionForFullTransactionJsonBase = Readonly<{ | ||
message: { | ||
accountKeys: readonly Base58EncodedAddress[]; | ||
header: { | ||
numReadonlySignedAccounts: number; | ||
numReadonlyUnsignedAccounts: number; | ||
numRequiredSignatures: number; | ||
}; | ||
instructions: readonly TransactionInstruction[]; | ||
recentBlockhash: Blockhash; | ||
}; | ||
signatures: readonly Base58EncodedBytes[]; | ||
}>; | ||
type TransactionForFullJson<TMaxSupportedTransactionVersion extends TransactionVersion | void> = TMaxSupportedTransactionVersion extends void ? Readonly<{ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed) | null; | ||
transaction: TransactionForFullTransactionJsonBase; | ||
}> : Readonly<{ | ||
meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed & TransactionForFullMetaLoadedAddresses) | null; | ||
transaction: TransactionForFullTransactionJsonBase & TransactionForFullTransactionAddressTableLookups; | ||
version: TransactionVersion; | ||
}>; | ||
import type { Base58EncodedBytes, Blockhash, Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1, UnixTimestamp } from '@solana/rpc-types'; | ||
import { TransactionVersion } from '@solana/transactions'; | ||
import { Reward, TransactionForAccounts, TransactionForFullBase58, TransactionForFullBase64, TransactionForFullJson, TransactionForFullJsonParsed } from './common-transactions.js'; | ||
type GetBlockApiResponseBase = Readonly<{ | ||
@@ -252,3 +33,3 @@ /** the blockhash of this block */ | ||
type GetBlockMaxSupportedTransactionVersion = Exclude<TransactionVersion, 'legacy'>; | ||
export interface GetBlockApi { | ||
export interface GetBlockApi extends IRpcApiMethods { | ||
/** | ||
@@ -255,0 +36,0 @@ * Returns identity and transaction information about a confirmed block in the ledger |
@@ -1,3 +0,2 @@ | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, Slot } from '@solana/rpc-types'; | ||
type GetBlockCommitmentApiResponse = Readonly<{ | ||
@@ -7,3 +6,3 @@ commitment: LamportsUnsafeBeyond2Pow53Minus1[] | null; | ||
}>; | ||
export interface GetBlockCommitmentApi { | ||
export interface GetBlockCommitmentApi extends IRpcApiMethods { | ||
/** | ||
@@ -10,0 +9,0 @@ * Returns the amount of cluster stake in lamports that has voted on |
@@ -1,4 +0,4 @@ | ||
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetBlockHeightApiResponse = U64UnsafeBeyond2Pow53Minus1; | ||
export interface GetBlockHeightApi { | ||
export interface GetBlockHeightApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the current block height of the node |
@@ -1,8 +0,8 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, RpcResponse, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type NumberOfLeaderSlots = U64UnsafeBeyond2Pow53Minus1; | ||
type NumberOfBlocksProduced = U64UnsafeBeyond2Pow53Minus1; | ||
type SlotRange = Readonly<{ | ||
firstSlot: U64UnsafeBeyond2Pow53Minus1; | ||
lastSlot: U64UnsafeBeyond2Pow53Minus1; | ||
firstSlot: Slot; | ||
lastSlot: Slot; | ||
}>; | ||
@@ -18,3 +18,3 @@ type GetBlockProductionApiConfigBase = Readonly<{ | ||
value: Readonly<{ | ||
byIdentity: Record<Base58EncodedAddress, [NumberOfLeaderSlots, NumberOfBlocksProduced]>; | ||
byIdentity: Record<Address, [NumberOfLeaderSlots, NumberOfBlocksProduced]>; | ||
}>; | ||
@@ -29,7 +29,7 @@ }>; | ||
}>; | ||
export interface GetBlockProductionApi { | ||
export interface GetBlockProductionApi extends IRpcApiMethods { | ||
/** | ||
* Returns recent block production information from the current or previous epoch. | ||
*/ | ||
getBlockProduction<TIdentity extends Base58EncodedAddress>(config: GetBlockProductionApiConfigBase & Readonly<{ | ||
getBlockProduction<TIdentity extends Address>(config: GetBlockProductionApiConfigBase & Readonly<{ | ||
identity: TIdentity; | ||
@@ -36,0 +36,0 @@ }>): GetBlockProductionApiResponseBase & GetBlockProductionApiResponseWithSingleIdentity<TIdentity>; |
@@ -1,4 +0,4 @@ | ||
import { Commitment, Slot } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetBlocksApiResponse = Slot[]; | ||
export interface GetBlocksApi { | ||
export interface GetBlocksApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns a list of confirmed blocks between two slots |
@@ -1,4 +0,4 @@ | ||
import { Commitment, Slot } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetBlocksWithLimitApiResponse = Slot[]; | ||
export interface GetBlocksWithLimitApi { | ||
export interface GetBlocksWithLimitApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns a list of confirmed blocks starting at the given slot |
@@ -1,6 +0,5 @@ | ||
import { UnixTimestamp } from '../unix-timestamp'; | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot, UnixTimestamp } from '@solana/rpc-types'; | ||
/** Estimated production time, as Unix timestamp (seconds since the Unix epoch) */ | ||
type GetBlockTimeApiResponse = UnixTimestamp; | ||
export interface GetBlockTimeApi { | ||
export interface GetBlockTimeApi extends IRpcApiMethods { | ||
/** | ||
@@ -7,0 +6,0 @@ * Returns the estimated production time of a block. |
@@ -1,2 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Address } from '@solana/addresses'; | ||
import type { IRpcApiMethods } from '@solana/rpc-types'; | ||
type GetClusterNodesNode = Readonly<{ | ||
@@ -8,3 +9,3 @@ /** The unique identifier of the node's feature set */ | ||
/** Node public key, as base-58 encoded string */ | ||
pubkey: Base58EncodedAddress; | ||
pubkey: Address; | ||
/** | ||
@@ -26,3 +27,3 @@ * JSON RPC network address for the node, | ||
type GetClusterNodesApiResponse = readonly GetClusterNodesNode[]; | ||
export interface GetClusterNodesApi { | ||
export interface GetClusterNodesApi extends IRpcApiMethods { | ||
/** | ||
@@ -29,0 +30,0 @@ * Returns information about all the nodes participating in the cluster |
@@ -1,2 +0,2 @@ | ||
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetEpochInfoApiResponse = Readonly<{ | ||
@@ -16,3 +16,3 @@ /** the current slot */ | ||
}>; | ||
export interface GetEpochInfoApi { | ||
export interface GetEpochInfoApi extends IRpcApiMethods { | ||
/** | ||
@@ -19,0 +19,0 @@ * Returns the balance of the account of provided Pubkey |
@@ -1,2 +0,2 @@ | ||
import { U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { IRpcApiMethods, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetEpochScheduleApiResponse = Readonly<{ | ||
@@ -14,3 +14,3 @@ /** the maximum number of slots in each epoch */ | ||
}>; | ||
export interface GetEpochScheduleApi { | ||
export interface GetEpochScheduleApi extends IRpcApiMethods { | ||
/** | ||
@@ -17,0 +17,0 @@ * Returns the epoch schedule information from this cluster's genesis config |
@@ -0,6 +1,6 @@ | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import { SerializedMessageBytesBase64 } from '@solana/transactions'; | ||
import { Commitment, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
/** Fee corresponding to the message at the specified blockhash */ | ||
type GetFeeForMessageApiResponse = RpcResponse<U64UnsafeBeyond2Pow53Minus1 | null>; | ||
export interface GetFeeForMessageApi { | ||
export interface GetFeeForMessageApi extends IRpcApiMethods { | ||
/** | ||
@@ -7,0 +7,0 @@ * Returns the fee the network will charge for a particular Message |
@@ -1,4 +0,4 @@ | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetFirstAvailableBlockApiResponse = Slot; | ||
export interface GetFirstAvailableBlockApi { | ||
export interface GetFirstAvailableBlockApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the slot of the lowest confirmed block that has not been purged from the ledger |
@@ -1,4 +0,4 @@ | ||
import { Blockhash } from '@solana/transactions'; | ||
import type { Blockhash, IRpcApiMethods } from '@solana/rpc-types'; | ||
type GetGenesisHashApiResponse = Blockhash; | ||
export interface GetGenesisHashApi { | ||
export interface GetGenesisHashApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the genesis hash |
@@ -0,3 +1,4 @@ | ||
import type { IRpcApiMethods } from '@solana/rpc-types'; | ||
type GetHealthApiResponse = 'ok'; | ||
export interface GetHealthApi { | ||
export interface GetHealthApi extends IRpcApiMethods { | ||
/** | ||
@@ -4,0 +5,0 @@ * Returns the health status of the node ("ok" if healthy). |
@@ -1,2 +0,2 @@ | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetHighestSnapshotSlotApiResponse = Readonly<{ | ||
@@ -6,3 +6,3 @@ full: Slot; | ||
}>; | ||
export interface GetHighestSnapshotSlotApi { | ||
export interface GetHighestSnapshotSlotApi extends IRpcApiMethods { | ||
/** | ||
@@ -9,0 +9,0 @@ * Returns the highest slot information that the node has snapshots for. |
@@ -1,6 +0,7 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { IRpcApiMethods } from '@solana/rpc-types'; | ||
type GetIdentityApiResponse = Readonly<{ | ||
identity: Base58EncodedAddress; | ||
identity: Address; | ||
}>; | ||
export interface GetIdentityApi { | ||
export interface GetIdentityApi extends IRpcApiMethods { | ||
/** | ||
@@ -7,0 +8,0 @@ * Returns the identity pubkey for the current node |
@@ -1,2 +0,3 @@ | ||
import { Commitment, F64UnsafeSeeDocumentation } from './common'; | ||
import type { Commitment, IRpcApiMethods } from '@solana/rpc-types'; | ||
import { F64UnsafeSeeDocumentation } from './common.js'; | ||
type GetInflationGovernorApiResponse = Readonly<{ | ||
@@ -18,3 +19,3 @@ /** The initial inflation percentage from time 0 */ | ||
}>; | ||
export interface GetInflationGovernorApi { | ||
export interface GetInflationGovernorApi extends IRpcApiMethods { | ||
/** | ||
@@ -21,0 +22,0 @@ * Returns the current inflation governor |
@@ -1,2 +0,3 @@ | ||
import { F64UnsafeSeeDocumentation, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { IRpcApiMethods, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import { F64UnsafeSeeDocumentation } from './common.js'; | ||
type GetInflationRateApiResponse = Readonly<{ | ||
@@ -12,3 +13,3 @@ /** Epoch for which these values are valid */ | ||
}>; | ||
export interface GetInflationRateApi { | ||
export interface GetInflationRateApi extends IRpcApiMethods { | ||
/** | ||
@@ -15,0 +16,0 @@ * Returns the current block height of the node |
@@ -1,4 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetInflationRewardApiResponse = Readonly<{ | ||
@@ -11,7 +10,7 @@ amount: 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; | ||
@@ -18,0 +17,0 @@ epoch?: U64UnsafeBeyond2Pow53Minus1; |
@@ -1,7 +0,6 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, RpcResponse } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, RpcResponse } from '@solana/rpc-types'; | ||
type GetLargestAccountsResponseItem = Readonly<{ | ||
/** Base-58 encoded address of the account */ | ||
address: Base58EncodedAddress; | ||
address: Address; | ||
/** Number of lamports in the account */ | ||
@@ -11,3 +10,3 @@ lamports: LamportsUnsafeBeyond2Pow53Minus1; | ||
type GetLargestAccountsApiResponse = RpcResponse<GetLargestAccountsResponseItem[]>; | ||
export interface GetLargestAccountsApi { | ||
export interface GetLargestAccountsApi extends IRpcApiMethods { | ||
/** | ||
@@ -14,0 +13,0 @@ * Returns the 20 largest accounts, by lamport balance |
@@ -1,3 +0,2 @@ | ||
import { Blockhash } from '@solana/transactions'; | ||
import { Commitment, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Blockhash, Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetLatestBlockhashApiResponse = RpcResponse<{ | ||
@@ -9,3 +8,3 @@ /** a Hash as base-58 encoded string */ | ||
}>; | ||
export interface GetLatestBlockhashApi { | ||
export interface GetLatestBlockhashApi extends IRpcApiMethods { | ||
/** | ||
@@ -12,0 +11,0 @@ * Returns the latest blockhash |
@@ -1,3 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, Slot } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
/** | ||
@@ -20,5 +20,5 @@ * This return type is a dictionary of validator identities, as base-58 encoded | ||
type GetLeaderScheduleApiResponseBase = Readonly<{ | ||
[key: Base58EncodedAddress]: Slot[]; | ||
[key: Address]: Slot[]; | ||
}>; | ||
export interface GetLeaderScheduleApi { | ||
export interface GetLeaderScheduleApi extends IRpcApiMethods { | ||
/** | ||
@@ -35,3 +35,3 @@ * Fetch the leader schedule for the epoch that corresponds to the provided slot. | ||
/** Only return results for this validator identity (base58 encoded address) */ | ||
identity?: Base58EncodedAddress; | ||
identity?: Address; | ||
}>): GetLeaderScheduleApiResponseBase | null; | ||
@@ -41,3 +41,3 @@ getLeaderSchedule(config?: Readonly<{ | ||
/** Only return results for this validator identity (base58 encoded address) */ | ||
identity?: Base58EncodedAddress; | ||
identity?: Address; | ||
}>): GetLeaderScheduleApiResponseBase; | ||
@@ -44,0 +44,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetMaxRetransmitSlotApiResponse = Slot; | ||
export interface GetMaxRetransmitSlotApi { | ||
export interface GetMaxRetransmitSlotApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Get the max slot seen from retransmit stage. |
@@ -1,4 +0,4 @@ | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetMaxShredInsertSlotApiResponse = Slot; | ||
export interface GetMaxShredInsertSlotApi { | ||
export interface GetMaxShredInsertSlotApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Get the max slot seen from after shred insert. |
@@ -1,5 +0,4 @@ | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetMinimumBalanceForRentExemptionApiResponse = LamportsUnsafeBeyond2Pow53Minus1; | ||
export interface GetMinimumBalanceForRentExemptionApi { | ||
export interface GetMinimumBalanceForRentExemptionApi extends IRpcApiMethods { | ||
/** | ||
@@ -6,0 +5,0 @@ * Returns the minimum balance to exempt an account of a certain size from rent |
@@ -1,3 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, Commitment, DataSlice, RpcResponse, Slot } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, DataSlice } from './common.js'; | ||
type GetMultipleAccountsApiResponseBase = AccountInfoBase | null; | ||
@@ -14,3 +15,3 @@ type GetMultipleAccountsApiCommonConfig = Readonly<{ | ||
}>; | ||
export interface GetMultipleAccountsApi { | ||
export interface GetMultipleAccountsApi extends IRpcApiMethods { | ||
/** | ||
@@ -21,3 +22,3 @@ * Returns the account information for a list of Pubkeys. | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Base58EncodedAddress[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
addresses: Address[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64'; | ||
@@ -27,3 +28,3 @@ }>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Base58EncodedAddress[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
addresses: Address[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
@@ -33,3 +34,3 @@ }>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedZStdCompressedData | null))[]>; | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Base58EncodedAddress[], config: GetMultipleAccountsApiCommonConfig & Readonly<{ | ||
addresses: Address[], config: GetMultipleAccountsApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
@@ -39,3 +40,3 @@ }>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithJsonData | null))[]>; | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Base58EncodedAddress[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
addresses: Address[], config: GetMultipleAccountsApiCommonConfig & GetMultipleAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
@@ -45,5 +46,5 @@ }>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase58EncodedData | null))[]>; | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Base58EncodedAddress[], config?: GetMultipleAccountsApiCommonConfig): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
addresses: Address[], config?: GetMultipleAccountsApiCommonConfig): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getMultipleAccounts.d.ts.map |
@@ -1,11 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, AccountInfoWithPubkey, Commitment, DataSlice, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
type GetProgramAccountsMemcmpFilter = Readonly<{ | ||
offset: U64UnsafeBeyond2Pow53Minus1; | ||
bytes: string; | ||
encoding: 'base58' | 'base64'; | ||
}>; | ||
type GetProgramAccountsDatasizeFilter = Readonly<{ | ||
dataSize: U64UnsafeBeyond2Pow53Minus1; | ||
}>; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, AccountInfoWithPubkey, DataSlice, GetProgramAccountsDatasizeFilter, GetProgramAccountsMemcmpFilter } from './common.js'; | ||
type GetProgramAccountsApiCommonConfig = Readonly<{ | ||
@@ -23,42 +16,42 @@ /** @defaultValue "finalized" */ | ||
}>; | ||
export interface GetProgramAccountsApi { | ||
export interface GetProgramAccountsApi extends IRpcApiMethods { | ||
/** | ||
* Returns the account information for a list of Pubkeys. | ||
*/ | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64'; | ||
withContext: true; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedData>[]>; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64'; | ||
withContext?: boolean; | ||
}>): AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedData>[]; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
withContext: true; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>[]>; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
withContext?: boolean; | ||
}>): AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>[]; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
withContext: true; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithJsonData>[]>; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
withContext?: boolean; | ||
}>): AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithJsonData>[]; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
withContext: true; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58EncodedData>[]>; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
withContext?: boolean; | ||
}>): AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58EncodedData>[]; | ||
getProgramAccounts(program: Base58EncodedAddress, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
withContext: true; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]>; | ||
getProgramAccounts(program: Base58EncodedAddress, config?: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
getProgramAccounts(program: Address, config?: GetProgramAccountsApiCommonConfig & GetProgramAccountsApiSliceableCommonConfig & Readonly<{ | ||
withContext?: boolean; | ||
@@ -65,0 +58,0 @@ }>): AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]; |
@@ -1,2 +0,2 @@ | ||
import { Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type PerformanceSample = Readonly<{ | ||
@@ -15,3 +15,3 @@ /** Slot in which sample was taken at */ | ||
type GetRecentPerformanceSamplesApiResponse = readonly PerformanceSample[]; | ||
export interface GetRecentPerformanceSamplesApi { | ||
export interface GetRecentPerformanceSamplesApi extends IRpcApiMethods { | ||
/** | ||
@@ -18,0 +18,0 @@ * Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window. |
@@ -1,3 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { MicroLamportsUnsafeBeyond2Pow53Minus1, Slot } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
import { MicroLamportsUnsafeBeyond2Pow53Minus1 } from './common.js'; | ||
type GetRecentPrioritizationFeesApiResponse = Readonly<{ | ||
@@ -13,3 +14,3 @@ /** | ||
}>[]; | ||
export interface GetRecentPrioritizationFeesApi { | ||
export interface GetRecentPrioritizationFeesApi extends IRpcApiMethods { | ||
/** | ||
@@ -27,5 +28,5 @@ * Returns the balance of the account of provided Pubkey | ||
*/ | ||
addresses?: Base58EncodedAddress[]): GetRecentPrioritizationFeesApiResponse; | ||
addresses?: Address[]): GetRecentPrioritizationFeesApiResponse; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getRecentPrioritizationFees.d.ts.map |
@@ -1,9 +0,8 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { TransactionError } from '../transaction-error'; | ||
import { TransactionSignature } from '../transaction-signature'; | ||
import { UnixTimestamp } from '../unix-timestamp'; | ||
import { Commitment, RpcResponse, Slot } from './common'; | ||
type GetSignaturesForAddressTransaction = RpcResponse<{ | ||
import type { Address } from '@solana/addresses'; | ||
import type { Signature } from '@solana/keys'; | ||
import type { Commitment, IRpcApiMethods, Slot, UnixTimestamp } from '@solana/rpc-types'; | ||
import { TransactionError } from '../transaction-error.js'; | ||
type GetSignaturesForAddressTransaction = Readonly<{ | ||
/** transaction signature as base-58 encoded string */ | ||
signature: TransactionSignature; | ||
signature: Signature; | ||
/** The slot that contains the block with the transaction */ | ||
@@ -29,7 +28,7 @@ slot: Slot; | ||
/** start searching backwards from this transaction signature. If not provided the search starts from the top of the highest max confirmed block. */ | ||
before?: TransactionSignature; | ||
before?: Signature; | ||
/** search until this transaction signature, if found before limit reached */ | ||
until?: TransactionSignature; | ||
until?: Signature; | ||
}>; | ||
export interface GetSignaturesForAddressApi { | ||
export interface GetSignaturesForAddressApi extends IRpcApiMethods { | ||
/** | ||
@@ -39,5 +38,5 @@ * Returns signatures for confirmed transactions that include the given address in their accountKeys list. | ||
*/ | ||
getSignaturesForAddress(address: Base58EncodedAddress, config?: GetSignaturesForAddressConfig): GetSignaturesForAddressApiResponse; | ||
getSignaturesForAddress(address: Address, config?: GetSignaturesForAddressConfig): GetSignaturesForAddressApiResponse; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getSignaturesForAddress.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { TransactionError } from '../transaction-error'; | ||
import { TransactionSignature } from '../transaction-signature'; | ||
import { Commitment, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Signature } from '@solana/keys'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import { TransactionError } from '../transaction-error.js'; | ||
/** @deprecated */ | ||
@@ -12,3 +12,3 @@ type TransactionStatusOk = Readonly<{ | ||
}>; | ||
type GetSignatureStatusesBase = Readonly<{ | ||
type SignatureStatusResult = Readonly<{ | ||
/** | ||
@@ -32,5 +32,6 @@ * Number of blocks since signature confirmation, null if rooted, | ||
status: TransactionStatusOk | TransactionStatusErr; | ||
}> | null; | ||
}>; | ||
type GetSignatureStatusesBase = ReadonlyArray<SignatureStatusResult | null>; | ||
type GetSignatureStatusesApiResponse = RpcResponse<GetSignatureStatusesBase>; | ||
export interface GetSignatureStatusesApi { | ||
export interface GetSignatureStatusesApi extends IRpcApiMethods { | ||
/** | ||
@@ -50,3 +51,3 @@ * Returns the statuses of a list of signatures. | ||
*/ | ||
signatures: TransactionSignature[], config?: Readonly<{ | ||
signatures: Signature[], config?: Readonly<{ | ||
/** | ||
@@ -53,0 +54,0 @@ * if `true` - a Solana node will search its ledger cache for any |
@@ -1,4 +0,4 @@ | ||
import { Commitment, Slot } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type GetSlotApiResponse = Slot; | ||
export interface GetSlotApi { | ||
export interface GetSlotApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the slot that has reached the given or default commitment level |
@@ -1,4 +0,4 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, Slot } from './common'; | ||
export interface GetSlotLeaderApi { | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
export interface GetSlotLeaderApi extends IRpcApiMethods { | ||
/** | ||
@@ -10,4 +10,4 @@ * Returns the current slot leader | ||
minContextSlot?: Slot; | ||
}>): Base58EncodedAddress; | ||
}>): Address; | ||
} | ||
//# sourceMappingURL=getSlotLeader.d.ts.map |
@@ -1,6 +0,6 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Slot } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
/** array of Node identity public keys as base-58 encoded strings */ | ||
type GetSlotLeadersApiResponse = Base58EncodedAddress[]; | ||
export interface GetSlotLeadersApi { | ||
type GetSlotLeadersApiResponse = Address[]; | ||
export interface GetSlotLeadersApi extends IRpcApiMethods { | ||
/** | ||
@@ -7,0 +7,0 @@ * Returns the slot leaders for a given slot range |
@@ -1,3 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetStakeActivationApiResponse = Readonly<{ | ||
@@ -11,7 +11,7 @@ /** Stake active during the epoch */ | ||
}>; | ||
export interface GetStakeActivationApi { | ||
export interface GetStakeActivationApi extends IRpcApiMethods { | ||
/** | ||
* Returns epoch activation information for a stake account | ||
*/ | ||
getStakeActivation(address: Base58EncodedAddress, config?: Readonly<{ | ||
getStakeActivation(address: Address, config?: Readonly<{ | ||
commitment?: Commitment; | ||
@@ -18,0 +18,0 @@ minContextSlot?: Slot; |
@@ -1,5 +0,4 @@ | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, RpcResponse } from './common'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, RpcResponse } from '@solana/rpc-types'; | ||
type GetStakeMinimumDelegationApiResponse = RpcResponse<LamportsUnsafeBeyond2Pow53Minus1>; | ||
export interface GetStakeMinimumDelegationApi { | ||
export interface GetStakeMinimumDelegationApi extends IRpcApiMethods { | ||
/** | ||
@@ -6,0 +5,0 @@ * Returns the stake minimum delegation, in lamports. |
@@ -1,4 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Commitment, RpcResponse } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1, RpcResponse } from '@solana/rpc-types'; | ||
type GetSupplyConfig = Readonly<{ | ||
@@ -19,3 +18,3 @@ commitment?: Commitment; | ||
/** an array of account addresses of non-circulating accounts */ | ||
nonCirculatingAccounts: [Base58EncodedAddress]; | ||
nonCirculatingAccounts: [Address]; | ||
}>; | ||
@@ -28,3 +27,3 @@ }>; | ||
}>; | ||
export interface GetSupplyApi { | ||
export interface GetSupplyApi extends IRpcApiMethods { | ||
/** | ||
@@ -31,0 +30,0 @@ * Returns information about the current supply. |
@@ -1,5 +0,5 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, RpcResponse, TokenAmount } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, TokenAmount } from '@solana/rpc-types'; | ||
type GetTokenAccountBalanceApiResponse = RpcResponse<TokenAmount>; | ||
export interface GetTokenAccountBalanceApi { | ||
export interface GetTokenAccountBalanceApi extends IRpcApiMethods { | ||
/** | ||
@@ -10,3 +10,3 @@ * Returns the token balance of an SPL Token account | ||
/** Pubkey of Token account to query, as base-58 encoded string */ | ||
address: Base58EncodedAddress, config?: Readonly<{ | ||
address: Address, config?: Readonly<{ | ||
commitment?: Commitment; | ||
@@ -13,0 +13,0 @@ }>): GetTokenAccountBalanceApiResponse; |
@@ -1,11 +0,13 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithPubkey, Commitment, DataSlice, RpcResponse, Slot, TokenAccount, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { JsonParsedTokenAccount } from '@solana/rpc-parsed-types'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithPubkey, DataSlice } from './common.js'; | ||
type TokenAccountInfoWithJsonData = Readonly<{ | ||
data: Readonly<{ | ||
/** Name of the program that owns this account. */ | ||
program: { | ||
info: TokenAccount; | ||
program: Address; | ||
parsed: { | ||
info: JsonParsedTokenAccount; | ||
type: 'account'; | ||
}; | ||
parsed: unknown; | ||
space: U64UnsafeBeyond2Pow53Minus1; | ||
@@ -16,7 +18,7 @@ }>; | ||
/** Pubkey of the specific token Mint to limit accounts to */ | ||
mint: Base58EncodedAddress; | ||
mint: Address; | ||
}>; | ||
type ProgramIdFilter = Readonly<{ | ||
/** Pubkey of the Token program that owns the accounts */ | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
}>; | ||
@@ -34,21 +36,21 @@ type AccountsFilter = MintFilter | ProgramIdFilter; | ||
}>; | ||
export interface GetTokenAccountsByDelegateApi { | ||
export interface GetTokenAccountsByDelegateApi extends IRpcApiMethods { | ||
/** | ||
* Returns all SPL Token accounts by approved Delegate. | ||
*/ | ||
getTokenAccountsByDelegate(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByDelegate(program: Address, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedData>[]>; | ||
getTokenAccountsByDelegate(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByDelegate(program: Address, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>[]>; | ||
getTokenAccountsByDelegate(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & Readonly<{ | ||
getTokenAccountsByDelegate(program: Address, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & TokenAccountInfoWithJsonData>[]>; | ||
getTokenAccountsByDelegate(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByDelegate(program: Address, filter: AccountsFilter, config: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58EncodedData>[]>; | ||
getTokenAccountsByDelegate(program: Base58EncodedAddress, filter: AccountsFilter, config?: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]>; | ||
getTokenAccountsByDelegate(program: Address, filter: AccountsFilter, config?: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getTokenAccountsByDelegate.d.ts.map |
@@ -1,11 +0,13 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithPubkey, Commitment, DataSlice, RpcResponse, Slot, TokenAccount, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { JsonParsedTokenAccount } from '@solana/rpc-parsed-types'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithPubkey, DataSlice } from './common.js'; | ||
type TokenAccountInfoWithJsonData = Readonly<{ | ||
data: Readonly<{ | ||
/** Name of the program that owns this account. */ | ||
program: { | ||
info: TokenAccount; | ||
program: Address; | ||
parsed: { | ||
info: JsonParsedTokenAccount; | ||
type: 'account'; | ||
}; | ||
parsed: unknown; | ||
space: U64UnsafeBeyond2Pow53Minus1; | ||
@@ -16,7 +18,7 @@ }>; | ||
/** Pubkey of the specific token Mint to limit accounts to */ | ||
mint: Base58EncodedAddress; | ||
mint: Address; | ||
}>; | ||
type ProgramIdFilter = Readonly<{ | ||
/** Pubkey of the Token program that owns the accounts */ | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
}>; | ||
@@ -34,21 +36,21 @@ type AccountsFilter = MintFilter | ProgramIdFilter; | ||
}>; | ||
export interface GetTokenAccountsByOwnerApi { | ||
export interface GetTokenAccountsByOwnerApi extends IRpcApiMethods { | ||
/** | ||
* Returns all SPL Token accounts by token owner. | ||
*/ | ||
getTokenAccountsByOwner(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByOwner(owner: Address, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedData>[]>; | ||
getTokenAccountsByOwner(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByOwner(owner: Address, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base64+zstd'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>[]>; | ||
getTokenAccountsByOwner(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & Readonly<{ | ||
getTokenAccountsByOwner(owner: Address, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & TokenAccountInfoWithJsonData>[]>; | ||
getTokenAccountsByOwner(program: Base58EncodedAddress, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
getTokenAccountsByOwner(owner: Address, filter: AccountsFilter, config: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig & Readonly<{ | ||
encoding: 'base58'; | ||
}>): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58EncodedData>[]>; | ||
getTokenAccountsByOwner(program: Base58EncodedAddress, filter: AccountsFilter, config?: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]>; | ||
getTokenAccountsByOwner(owner: Address, filter: AccountsFilter, config?: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig): RpcResponse<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithBase58Bytes>[]>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getTokenAccountsByOwner.d.ts.map |
@@ -1,11 +0,11 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, RpcResponse, TokenAmount } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, TokenAmount } from '@solana/rpc-types'; | ||
type GetTokenLargestAccountsApiResponse = RpcResponse<TokenAmount & { | ||
address: Base58EncodedAddress; | ||
address: Address; | ||
}[]>; | ||
export interface GetTokenLargestAccountsApi { | ||
export interface GetTokenLargestAccountsApi extends IRpcApiMethods { | ||
/** | ||
* Returns the 20 largest accounts of a particular SPL Token type. | ||
*/ | ||
getTokenLargestAccounts(tokenMint: Base58EncodedAddress, config?: Readonly<{ | ||
getTokenLargestAccounts(tokenMint: Address, config?: Readonly<{ | ||
commitment?: Commitment; | ||
@@ -12,0 +12,0 @@ }>): GetTokenLargestAccountsApiResponse; |
@@ -1,5 +0,5 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, RpcResponse, TokenAmount } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, TokenAmount } from '@solana/rpc-types'; | ||
type GetTokenSupplyApiResponse = RpcResponse<TokenAmount>; | ||
export interface GetTokenSupplyApi { | ||
export interface GetTokenSupplyApi extends IRpcApiMethods { | ||
/** | ||
@@ -10,3 +10,3 @@ * Returns the total supply of an SPL Token mint | ||
/** Pubkey of the token Mint to query, as base-58 encoded string */ | ||
address: Base58EncodedAddress, config?: Readonly<{ | ||
address: Address, config?: Readonly<{ | ||
commitment?: Commitment; | ||
@@ -13,0 +13,0 @@ }>): GetTokenSupplyApiResponse; |
@@ -1,10 +0,12 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Blockhash, TransactionVersion } from '@solana/transactions'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { TransactionError } from '../transaction-error'; | ||
import { UnixTimestamp } from '../unix-timestamp'; | ||
import { Base58EncodedBytes, Base58EncodedDataResponse, Base64EncodedDataResponse, Commitment, Reward, Slot, TokenBalance, TransactionStatus, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import { Address } from '@solana/addresses'; | ||
import { Signature } from '@solana/keys'; | ||
import type { IRpcApiMethods } from '@solana/rpc-types'; | ||
import { Base58EncodedBytes, Base58EncodedDataResponse, Base64EncodedDataResponse, Blockhash, Commitment, LamportsUnsafeBeyond2Pow53Minus1, Slot, U64UnsafeBeyond2Pow53Minus1, UnixTimestamp } from '@solana/rpc-types'; | ||
import { TransactionVersion } from '@solana/transactions'; | ||
import { TransactionError } from '../transaction-error.js'; | ||
import { TokenBalance } from './common.js'; | ||
import { Reward, TransactionStatus } from './common-transactions.js'; | ||
type ReturnData = { | ||
/** the program that generated the return data */ | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
/** the return data itself */ | ||
@@ -42,3 +44,3 @@ data: Base64EncodedDataResponse; | ||
/** public key for an address lookup table account. */ | ||
accountKey: Base58EncodedAddress; | ||
accountKey: Address; | ||
/** List of indices used to load addresses of writable accounts from a lookup table. */ | ||
@@ -62,3 +64,3 @@ writableIndexes: readonly number[]; | ||
message: { | ||
accountKeys: readonly Base58EncodedAddress[]; | ||
accountKeys: readonly Address[]; | ||
header: { | ||
@@ -73,5 +75,5 @@ numReadonlySignedAccounts: number; | ||
type PartiallyDecodedTransactionInstruction = Readonly<{ | ||
accounts: readonly Base58EncodedAddress[]; | ||
accounts: readonly Address[]; | ||
data: Base58EncodedBytes; | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
}>; | ||
@@ -84,3 +86,3 @@ type ParsedTransactionInstruction = Readonly<{ | ||
program: string; | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
}>; | ||
@@ -91,3 +93,3 @@ type TransactionJsonParsed = TransactionBase & Readonly<{ | ||
{ | ||
pubkey: Base58EncodedAddress; | ||
pubkey: Address; | ||
signer: boolean; | ||
@@ -113,4 +115,4 @@ source: string; | ||
loadedAddresses: { | ||
writable: readonly Base58EncodedAddress[]; | ||
readonly: readonly Base58EncodedAddress[]; | ||
writable: readonly Address[]; | ||
readonly: readonly Address[]; | ||
}; | ||
@@ -133,7 +135,7 @@ }>; | ||
}>; | ||
export interface GetTransactionApi { | ||
export interface GetTransactionApi extends IRpcApiMethods { | ||
/** | ||
* Returns transaction details for a confirmed transaction | ||
*/ | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(address: Base58EncodedAddress, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(signature: Signature, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
encoding: 'jsonParsed'; | ||
@@ -146,3 +148,3 @@ }>): (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record<string, never> : { | ||
}) | null; | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(address: Base58EncodedAddress, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(signature: Signature, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
encoding: 'base64'; | ||
@@ -155,3 +157,3 @@ }>): (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record<string, never> : { | ||
}) | null; | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(address: Base58EncodedAddress, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(signature: Signature, config: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
encoding: 'base58'; | ||
@@ -164,3 +166,3 @@ }>): (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record<string, never> : { | ||
}) | null; | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(address: Base58EncodedAddress, config?: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
getTransaction<TMaxSupportedTransactionVersion extends TransactionVersion | void = void>(signature: Signature, config?: GetTransactionCommonConfig<TMaxSupportedTransactionVersion> & Readonly<{ | ||
encoding?: 'json'; | ||
@@ -167,0 +169,0 @@ }>): (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record<string, never> : { |
@@ -1,4 +0,4 @@ | ||
import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type GetTransactionCountApiResponse = U64UnsafeBeyond2Pow53Minus1; | ||
export interface GetTransactionCountApi { | ||
export interface GetTransactionCountApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the current Transaction count from the ledger |
@@ -0,1 +1,2 @@ | ||
import type { IRpcApiMethods } from '@solana/rpc-types'; | ||
type GetVersionApiResponse = Readonly<{ | ||
@@ -7,3 +8,3 @@ /** Unique identifier of the current software's feature set */ | ||
}>; | ||
export interface GetVersionApi { | ||
export interface GetVersionApi extends IRpcApiMethods { | ||
/** | ||
@@ -10,0 +11,0 @@ * Returns the current Solana version running on the node |
@@ -1,3 +0,3 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Commitment, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type Epoch = U64UnsafeBeyond2Pow53Minus1; | ||
@@ -7,7 +7,7 @@ type Credits = U64UnsafeBeyond2Pow53Minus1; | ||
type EpochCredit = [Epoch, Credits, PreviousCredits]; | ||
type VoteAccount<TVotePubkey extends Base58EncodedAddress> = Readonly<{ | ||
type VoteAccount<TVotePubkey extends Address> = Readonly<{ | ||
/** Vote account address */ | ||
votePubkey: TVotePubkey; | ||
/** Validator identity */ | ||
nodePubkey: Base58EncodedAddress; | ||
nodePubkey: Address; | ||
/** the stake, in lamports, delegated to this vote account and active in this epoch */ | ||
@@ -24,9 +24,9 @@ activatedStake: U64UnsafeBeyond2Pow53Minus1; | ||
/** Current root slot for this vote account */ | ||
rootSlot: U64UnsafeBeyond2Pow53Minus1; | ||
rootSlot: Slot; | ||
}>; | ||
type GetVoteAccountsApiResponse<TVotePubkey extends Base58EncodedAddress> = Readonly<{ | ||
type GetVoteAccountsApiResponse<TVotePubkey extends Address> = Readonly<{ | ||
current: readonly VoteAccount<TVotePubkey>[]; | ||
delinquent: readonly VoteAccount<TVotePubkey>[]; | ||
}>; | ||
type GetVoteAccountsConfig<TVotePubkey extends Base58EncodedAddress> = Readonly<{ | ||
type GetVoteAccountsConfig<TVotePubkey extends Address> = Readonly<{ | ||
commitment?: Commitment; | ||
@@ -40,7 +40,7 @@ /** Only return results for this validator vote address */ | ||
}>; | ||
export interface GetVoteAccountsApi { | ||
export interface GetVoteAccountsApi extends IRpcApiMethods { | ||
/** Returns the account info and associated stake for all the voting accounts in the current bank. */ | ||
getVoteAccounts<TVoteAccount extends Base58EncodedAddress>(config?: GetVoteAccountsConfig<TVoteAccount>): GetVoteAccountsApiResponse<TVoteAccount>; | ||
getVoteAccounts<TVoteAccount extends Address>(config?: GetVoteAccountsConfig<TVoteAccount>): GetVoteAccountsApiResponse<TVoteAccount>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getVoteAccounts.d.ts.map |
@@ -1,61 +0,61 @@ | ||
import { IRpcApi } from '@solana/rpc-transport/dist/types/json-rpc-types'; | ||
import { GetAccountInfoApi } from './getAccountInfo'; | ||
import { GetBalanceApi } from './getBalance'; | ||
import { GetBlockApi } from './getBlock'; | ||
import { GetBlockCommitmentApi } from './getBlockCommitment'; | ||
import { GetBlockHeightApi } from './getBlockHeight'; | ||
import { GetBlockProductionApi } from './getBlockProduction'; | ||
import { GetBlocksApi } from './getBlocks'; | ||
import { GetBlocksWithLimitApi } from './getBlocksWithLimit'; | ||
import { GetBlockTimeApi } from './getBlockTime'; | ||
import { GetClusterNodesApi } from './getClusterNodes'; | ||
import { GetEpochInfoApi } from './getEpochInfo'; | ||
import { GetEpochScheduleApi } from './getEpochSchedule'; | ||
import { GetFeeForMessageApi } from './getFeeForMessage'; | ||
import { GetFirstAvailableBlockApi } from './getFirstAvailableBlock'; | ||
import { GetGenesisHashApi } from './getGenesisHash'; | ||
import { GetHealthApi } from './getHealth'; | ||
import { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot'; | ||
import { GetIdentityApi } from './getIdentity'; | ||
import { GetInflationGovernorApi } from './getInflationGovernor'; | ||
import { GetInflationRateApi } from './getInflationRate'; | ||
import { GetInflationRewardApi } from './getInflationReward'; | ||
import { GetLargestAccountsApi } from './getLargestAccounts'; | ||
import { GetLatestBlockhashApi } from './getLatestBlockhash'; | ||
import { GetLeaderScheduleApi } from './getLeaderSchedule'; | ||
import { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot'; | ||
import { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot'; | ||
import { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption'; | ||
import { GetMultipleAccountsApi } from './getMultipleAccounts'; | ||
import { GetProgramAccountsApi } from './getProgramAccounts'; | ||
import { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples'; | ||
import { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees'; | ||
import { GetSignaturesForAddressApi } from './getSignaturesForAddress'; | ||
import { GetSignatureStatusesApi } from './getSignatureStatuses'; | ||
import { GetSlotApi } from './getSlot'; | ||
import { GetSlotLeaderApi } from './getSlotLeader'; | ||
import { GetSlotLeadersApi } from './getSlotLeaders'; | ||
import { GetStakeActivationApi } from './getStakeActivation'; | ||
import { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation'; | ||
import { GetSupplyApi } from './getSupply'; | ||
import { GetTokenAccountBalanceApi } from './getTokenAccountBalance'; | ||
import { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate'; | ||
import { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner'; | ||
import { GetTokenLargestAccountsApi } from './getTokenLargestAccounts'; | ||
import { GetTokenSupplyApi } from './getTokenSupply'; | ||
import { GetTransactionApi } from './getTransaction'; | ||
import { GetTransactionCountApi } from './getTransactionCount'; | ||
import { GetVersionApi } from './getVersion'; | ||
import { GetVoteAccountsApi } from './getVoteAccounts'; | ||
import { IsBlockhashValidApi } from './isBlockhashValid'; | ||
import { MinimumLedgerSlotApi } from './minimumLedgerSlot'; | ||
import { RequestAirdropApi } from './requestAirdrop'; | ||
import { SendTransactionApi } from './sendTransaction'; | ||
import { SimulateTransactionApi } from './simulateTransaction'; | ||
type Config = Readonly<{ | ||
onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void; | ||
}>; | ||
import { IRpcApi } from '@solana/rpc-types'; | ||
import { ParamsPatcherConfig } from '../params-patcher.js'; | ||
import { GetAccountInfoApi } from './getAccountInfo.js'; | ||
import { GetBalanceApi } from './getBalance.js'; | ||
import { GetBlockApi } from './getBlock.js'; | ||
import { GetBlockCommitmentApi } from './getBlockCommitment.js'; | ||
import { GetBlockHeightApi } from './getBlockHeight.js'; | ||
import { GetBlockProductionApi } from './getBlockProduction.js'; | ||
import { GetBlocksApi } from './getBlocks.js'; | ||
import { GetBlocksWithLimitApi } from './getBlocksWithLimit.js'; | ||
import { GetBlockTimeApi } from './getBlockTime.js'; | ||
import { GetClusterNodesApi } from './getClusterNodes.js'; | ||
import { GetEpochInfoApi } from './getEpochInfo.js'; | ||
import { GetEpochScheduleApi } from './getEpochSchedule.js'; | ||
import { GetFeeForMessageApi } from './getFeeForMessage.js'; | ||
import { GetFirstAvailableBlockApi } from './getFirstAvailableBlock.js'; | ||
import { GetGenesisHashApi } from './getGenesisHash.js'; | ||
import { GetHealthApi } from './getHealth.js'; | ||
import { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot.js'; | ||
import { GetIdentityApi } from './getIdentity.js'; | ||
import { GetInflationGovernorApi } from './getInflationGovernor.js'; | ||
import { GetInflationRateApi } from './getInflationRate.js'; | ||
import { GetInflationRewardApi } from './getInflationReward.js'; | ||
import { GetLargestAccountsApi } from './getLargestAccounts.js'; | ||
import { GetLatestBlockhashApi } from './getLatestBlockhash.js'; | ||
import { GetLeaderScheduleApi } from './getLeaderSchedule.js'; | ||
import { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot.js'; | ||
import { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot.js'; | ||
import { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption.js'; | ||
import { GetMultipleAccountsApi } from './getMultipleAccounts.js'; | ||
import { GetProgramAccountsApi } from './getProgramAccounts.js'; | ||
import { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples.js'; | ||
import { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees.js'; | ||
import { GetSignaturesForAddressApi } from './getSignaturesForAddress.js'; | ||
import { GetSignatureStatusesApi } from './getSignatureStatuses.js'; | ||
import { GetSlotApi } from './getSlot.js'; | ||
import { GetSlotLeaderApi } from './getSlotLeader.js'; | ||
import { GetSlotLeadersApi } from './getSlotLeaders.js'; | ||
import { GetStakeActivationApi } from './getStakeActivation.js'; | ||
import { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation.js'; | ||
import { GetSupplyApi } from './getSupply.js'; | ||
import { GetTokenAccountBalanceApi } from './getTokenAccountBalance.js'; | ||
import { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate.js'; | ||
import { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner.js'; | ||
import { GetTokenLargestAccountsApi } from './getTokenLargestAccounts.js'; | ||
import { GetTokenSupplyApi } from './getTokenSupply.js'; | ||
import { GetTransactionApi } from './getTransaction.js'; | ||
import { GetTransactionCountApi } from './getTransactionCount.js'; | ||
import { GetVersionApi } from './getVersion.js'; | ||
import { GetVoteAccountsApi } from './getVoteAccounts.js'; | ||
import { IsBlockhashValidApi } from './isBlockhashValid.js'; | ||
import { MinimumLedgerSlotApi } from './minimumLedgerSlot.js'; | ||
import { RequestAirdropApi } from './requestAirdrop.js'; | ||
import { SendTransactionApi } from './sendTransaction.js'; | ||
import { SimulateTransactionApi } from './simulateTransaction.js'; | ||
type Config = ParamsPatcherConfig; | ||
export type SolanaRpcMethods = GetAccountInfoApi & GetBalanceApi & GetBlockApi & GetBlockCommitmentApi & GetBlockHeightApi & GetBlockProductionApi & GetBlocksApi & GetBlocksWithLimitApi & GetBlockTimeApi & GetClusterNodesApi & GetEpochInfoApi & GetEpochScheduleApi & GetFeeForMessageApi & GetFirstAvailableBlockApi & GetGenesisHashApi & GetHealthApi & GetHighestSnapshotSlotApi & GetIdentityApi & GetInflationGovernorApi & GetInflationRateApi & GetInflationRewardApi & GetLargestAccountsApi & GetLatestBlockhashApi & GetLeaderScheduleApi & GetMaxRetransmitSlotApi & GetMaxShredInsertSlotApi & GetMinimumBalanceForRentExemptionApi & GetMultipleAccountsApi & GetProgramAccountsApi & GetRecentPerformanceSamplesApi & GetRecentPrioritizationFeesApi & GetSignaturesForAddressApi & GetSignatureStatusesApi & GetSlotApi & GetSlotLeaderApi & GetSlotLeadersApi & GetStakeActivationApi & GetStakeMinimumDelegationApi & GetSupplyApi & GetTokenAccountBalanceApi & GetTokenAccountsByDelegateApi & GetTokenAccountsByOwnerApi & GetTokenLargestAccountsApi & GetTokenSupplyApi & GetTransactionApi & GetTransactionCountApi & GetVersionApi & GetVoteAccountsApi & IsBlockhashValidApi & MinimumLedgerSlotApi & RequestAirdropApi & SendTransactionApi & SimulateTransactionApi; | ||
export type { Commitment } from './common'; | ||
export declare function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods>; | ||
export type { GetAccountInfoApi, GetBalanceApi, GetBlockApi, GetBlockCommitmentApi, GetBlockHeightApi, GetBlockProductionApi, GetBlocksApi, GetBlocksWithLimitApi, GetBlockTimeApi, GetClusterNodesApi, GetEpochInfoApi, GetEpochScheduleApi, GetFeeForMessageApi, GetFirstAvailableBlockApi, GetGenesisHashApi, GetHealthApi, GetHighestSnapshotSlotApi, GetIdentityApi, GetInflationGovernorApi, GetInflationRateApi, GetInflationRewardApi, GetLargestAccountsApi, GetLatestBlockhashApi, GetLeaderScheduleApi, GetMaxRetransmitSlotApi, GetMaxShredInsertSlotApi, GetMinimumBalanceForRentExemptionApi, GetMultipleAccountsApi, GetProgramAccountsApi, GetRecentPerformanceSamplesApi, GetRecentPrioritizationFeesApi, GetSignaturesForAddressApi, GetSignatureStatusesApi, GetSlotApi, GetSlotLeaderApi, GetSlotLeadersApi, GetStakeActivationApi, GetStakeMinimumDelegationApi, GetSupplyApi, GetTokenAccountBalanceApi, GetTokenAccountsByDelegateApi, GetTokenAccountsByOwnerApi, GetTokenLargestAccountsApi, GetTokenSupplyApi, GetTransactionApi, GetTransactionCountApi, GetVersionApi, GetVoteAccountsApi, IsBlockhashValidApi, MinimumLedgerSlotApi, RequestAirdropApi, SendTransactionApi, SimulateTransactionApi, }; | ||
export type { DataSlice, GetProgramAccountsDatasizeFilter, GetProgramAccountsMemcmpFilter } from './common.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,5 +0,4 @@ | ||
import { Blockhash } from '@solana/transactions'; | ||
import { Commitment, RpcResponse, Slot } from './common'; | ||
import type { Blockhash, Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
type IsBlockhashValidApiResponse = RpcResponse<boolean>; | ||
export interface IsBlockhashValidApi { | ||
export interface IsBlockhashValidApi extends IRpcApiMethods { | ||
/** | ||
@@ -6,0 +5,0 @@ * Returns whether a blockhash is still valid or not |
@@ -1,4 +0,4 @@ | ||
import { Slot } from './common'; | ||
import type { IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
type MinimumLedgerSlotApiResponse = Slot; | ||
export interface MinimumLedgerSlotApi { | ||
export interface MinimumLedgerSlotApi extends IRpcApiMethods { | ||
/** | ||
@@ -5,0 +5,0 @@ * Returns the lowest slot that the node has information about in its ledger. |
@@ -1,15 +0,15 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { LamportsUnsafeBeyond2Pow53Minus1 } from '../lamports'; | ||
import { Base58EncodedTransactionSignature, Commitment } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Signature } from '@solana/keys'; | ||
import type { Commitment, IRpcApiMethods, LamportsUnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
type RequestAirdropConfig = Readonly<{ | ||
commitment?: Commitment; | ||
}>; | ||
type RequestAirdropResponse = Base58EncodedTransactionSignature; | ||
export interface RequestAirdropApi { | ||
type RequestAirdropResponse = Signature; | ||
export interface RequestAirdropApi extends IRpcApiMethods { | ||
/** | ||
* Requests an airdrop of lamports to a Pubkey | ||
*/ | ||
requestAirdrop(recipientAccount: Base58EncodedAddress, lamports: LamportsUnsafeBeyond2Pow53Minus1, config?: RequestAirdropConfig): RequestAirdropResponse; | ||
requestAirdrop(recipientAccount: Address, lamports: LamportsUnsafeBeyond2Pow53Minus1, config?: RequestAirdropConfig): RequestAirdropResponse; | ||
} | ||
export {}; | ||
//# sourceMappingURL=requestAirdrop.d.ts.map |
@@ -1,3 +0,4 @@ | ||
import { Base64EncodedWireTransaction } from '@solana/transactions'; | ||
import { Base58EncodedTransactionSignature, Commitment, Slot } from './common'; | ||
import type { Signature } from '@solana/keys'; | ||
import type { Commitment, IRpcApiMethods, Slot } from '@solana/rpc-types'; | ||
import type { Base64EncodedWireTransaction } from '@solana/transactions'; | ||
type SendTransactionConfig = Readonly<{ | ||
@@ -9,4 +10,4 @@ skipPreflight?: boolean; | ||
}>; | ||
type SendTransactionResponse = Base58EncodedTransactionSignature; | ||
export interface SendTransactionApi { | ||
type SendTransactionResponse = Signature; | ||
export interface SendTransactionApi extends IRpcApiMethods { | ||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
@@ -13,0 +14,0 @@ sendTransaction(base64EncodedWireTransaction: Base64EncodedWireTransaction, config?: SendTransactionConfig & { |
@@ -1,5 +0,6 @@ | ||
import { Base58EncodedAddress } from '@solana/addresses'; | ||
import { Base64EncodedWireTransaction } from '@solana/transactions'; | ||
import { TransactionError } from '../transaction-error'; | ||
import { AccountInfoBase, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, Base58EncodedBytes, Base64EncodedDataResponse, Commitment, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
import type { Address } from '@solana/addresses'; | ||
import type { Base58EncodedBytes, Base64EncodedDataResponse, Commitment, IRpcApiMethods, RpcResponse, Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
import type { Base64EncodedWireTransaction } from '@solana/transactions'; | ||
import { TransactionError } from '../transaction-error.js'; | ||
import { AccountInfoBase, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData } from './common.js'; | ||
type SimulateTransactionConfigBase = Readonly<{ | ||
@@ -33,3 +34,3 @@ /** | ||
/** An `array` of accounts to return */ | ||
addresses: Base58EncodedAddress[]; | ||
addresses: Address[]; | ||
/** Encoding for returned Account data */ | ||
@@ -42,3 +43,3 @@ encoding: 'base64+zstd'; | ||
/** An `array` of accounts to return */ | ||
addresses: Base58EncodedAddress[]; | ||
addresses: Address[]; | ||
/** Encoding for returned Account data */ | ||
@@ -51,3 +52,3 @@ encoding: 'jsonParsed'; | ||
/** An `array` of accounts to return */ | ||
addresses: Base58EncodedAddress[]; | ||
addresses: Address[]; | ||
/** Encoding for returned Account data */ | ||
@@ -67,3 +68,3 @@ encoding?: 'base64'; | ||
/** The program that generated the return data */ | ||
programId: Base58EncodedAddress; | ||
programId: Address; | ||
/** The return data itself, as base-64 encoded binary data */ | ||
@@ -77,3 +78,3 @@ data: Base64EncodedDataResponse; | ||
}>; | ||
export interface SimulateTransactionApi { | ||
export interface SimulateTransactionApi extends IRpcApiMethods { | ||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
@@ -80,0 +81,0 @@ simulateTransaction(base58EncodedWireTransaction: Base58EncodedBytes, config: SimulateTransactionConfigBase & SigVerifyAndReplaceRecentBlockhashConfig & AccountsConfigWithBase64Encoding): SimulateTransactionApiResponseBase & SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData>; |
{ | ||
"name": "@solana/rpc-core", | ||
"version": "2.0.0-experimental.3536b48", | ||
"version": "2.0.0-experimental.35de86b", | ||
"description": "A library for making calls to the Solana JSON RPC API", | ||
@@ -49,26 +49,30 @@ "exports": { | ||
"dependencies": { | ||
"@metaplex-foundation/umi-serializers": "^0.8.9" | ||
"@solana/addresses": "2.0.0-experimental.35de86b", | ||
"@solana/codecs-core": "2.0.0-experimental.35de86b", | ||
"@solana/codecs-strings": "2.0.0-experimental.35de86b", | ||
"@solana/keys": "2.0.0-experimental.35de86b", | ||
"@solana/rpc-parsed-types": "2.0.0-experimental.35de86b", | ||
"@solana/rpc-transport": "2.0.0-experimental.35de86b", | ||
"@solana/rpc-types": "2.0.0-experimental.35de86b", | ||
"@solana/transactions": "2.0.0-experimental.35de86b" | ||
}, | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.28", | ||
"@types/jest": "^29.5.3", | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@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.2.3", | ||
"eslint-plugin-jest": "^27.4.2", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.6.1", | ||
"jest-environment-jsdom": "^29.6.4", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-fetch-mock-fork": "^3.0.4", | ||
"jest-runner-eslint": "^2.1.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^2.8", | ||
"tsup": "7.2.0", | ||
"typescript": "^5.1.6", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
"version-from-git": "^1.1.1", | ||
"@solana/addresses": "2.0.0-experimental.3536b48", | ||
"@solana/rpc-transport": "2.0.0-experimental.3536b48", | ||
"@solana/transactions": "2.0.0-experimental.3536b48", | ||
"build-scripts": "0.0.0", | ||
@@ -88,11 +92,11 @@ "test-config": "0.0.0", | ||
"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/*", | ||
"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", | ||
@@ -99,0 +103,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", |
@@ -18,7 +18,1 @@ [![npm][npm-image]][npm-url] | ||
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
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
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
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
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
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
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
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
601311
21
168
6278
8
18
+ Added@solana/addresses@2.0.0-experimental.35de86b(transitive)
+ Added@solana/assertions@2.0.0-experimental.35de86b(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.35de86b(transitive)
+ Added@solana/codecs-data-structures@2.0.0-experimental.35de86b(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.35de86b(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.35de86b(transitive)
+ Added@solana/functional@2.0.0-experimental.35de86b(transitive)
+ Added@solana/keys@2.0.0-experimental.35de86b(transitive)
+ Added@solana/rpc-parsed-types@2.0.0-experimental.35de86b(transitive)
+ Added@solana/rpc-transport@2.0.0-experimental.35de86b(transitive)
+ Added@solana/rpc-types@2.0.0-experimental.35de86b(transitive)
+ Added@solana/transactions@2.0.0-experimental.35de86b(transitive)
+ Addedfastestsmallesttextencoderdecoder@1.0.22(transitive)
+ Addedws@8.18.0(transitive)
- Removed@metaplex-foundation/umi-options@0.8.9(transitive)
- Removed@metaplex-foundation/umi-public-keys@0.8.9(transitive)
- Removed@metaplex-foundation/umi-serializers@0.8.9(transitive)
- Removed@metaplex-foundation/umi-serializers-core@0.8.9(transitive)
- Removed@metaplex-foundation/umi-serializers-encodings@0.8.9(transitive)
- Removed@metaplex-foundation/umi-serializers-numbers@0.8.9(transitive)