@solana/rpc-core
Advanced tools
| 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 {}; | ||
| //# sourceMappingURL=params-patcher.d.ts.map |
| {"version":3,"file":"params-patcher.d.ts","sourceRoot":"","sources":["../../src/params-patcher.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AACpF,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;KAAG,QAAQ,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CAAE,GAAG,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;AA+BrH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,iBAAiB,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC,CAEhH"} |
| import { createSolanaRpcApi } from './index'; | ||
| import { KeyPath } from './response-patcher'; | ||
| /** | ||
| * 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 const ALLOWED_NUMERIC_KEYPATHS: Partial<Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>>; | ||
| //# sourceMappingURL=response-patcher-allowed-numeric-values.d.ts.map |
| {"version":3,"file":"response-patcher-allowed-numeric-values.d.ts","sourceRoot":"","sources":["../../src/response-patcher-allowed-numeric-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAC1C,MAAM,CAAC,MAAM,UAAU,CAAC,OAAO,kBAAkB,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC,CAG1E,CAAC"} |
| export type KeyPathWildcard = { | ||
| readonly __keyPathWildcard: unique symbol; | ||
| }; | ||
| export declare const KEYPATH_WILDCARD: KeyPathWildcard; | ||
| //# sourceMappingURL=response-patcher-types.d.ts.map |
| {"version":3,"file":"response-patcher-types.d.ts","sourceRoot":"","sources":["../../src/response-patcher-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,iBAAiB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAE5E,eAAO,MAAM,gBAAgB,iBAAwB,CAAC"} |
| import { createSolanaRpcApi } from './index'; | ||
| import { KeyPathWildcard } from './response-patcher-types'; | ||
| export type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>; | ||
| export declare function patchResponseForSolanaLabsRpc<T>(rawResponse: unknown, methodName?: keyof ReturnType<typeof createSolanaRpcApi>): T; | ||
| //# sourceMappingURL=response-patcher.d.ts.map |
| {"version":3,"file":"response-patcher.d.ts","sourceRoot":"","sources":["../../src/response-patcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAoB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE7E,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAuCjF,wBAAgB,6BAA6B,CAAC,CAAC,EAC3C,WAAW,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,MAAM,UAAU,CAAC,OAAO,kBAAkB,CAAC,GACzD,CAAC,CAGH"} |
| export type Commitment = 'confirmed' | 'finalized' | 'processed'; | ||
| export type DataSlice = Readonly<{ | ||
| offset: number; | ||
| length: number; | ||
| }>; | ||
| export type Slot = U64UnsafeBeyond2Pow53Minus1; | ||
| export type U64UnsafeBeyond2Pow53Minus1 = bigint; | ||
| //# sourceMappingURL=common.d.ts.map |
| {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/rpc-methods/common.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAK/C,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC"} |
| import { Base58EncodedAddress } from '@solana/keys'; | ||
| import { Commitment, DataSlice, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
| type Base58EncodedBytes = string & { | ||
| readonly __base58EncodedBytes: unique symbol; | ||
| }; | ||
| type Base64EncodedBytes = string & { | ||
| readonly __base64EncodedBytes: unique symbol; | ||
| }; | ||
| type Base64EncodedZStdCompressedBytes = string & { | ||
| readonly __base64EncodedZStdCompressedBytes: unique symbol; | ||
| }; | ||
| type Base58EncodedDataResponse = [Base58EncodedBytes, 'base58']; | ||
| type Base64EncodedDataResponse = [Base64EncodedBytes, 'base64']; | ||
| type Base64EncodedZStdCompressedDataResponse = [Base64EncodedZStdCompressedBytes, 'base64+zstd']; | ||
| type GetAccountInfoApiResponseBase = Readonly<{ | ||
| context: Readonly<{ | ||
| slot: Slot; | ||
| }>; | ||
| value: Readonly<{ | ||
| executable: boolean; | ||
| lamports: U64UnsafeBeyond2Pow53Minus1; | ||
| owner: Base58EncodedAddress; | ||
| rentEpoch: U64UnsafeBeyond2Pow53Minus1; | ||
| space: U64UnsafeBeyond2Pow53Minus1; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithDefaultData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base58EncodedBytes; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base58EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase64EncodedData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base64EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base64EncodedZStdCompressedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithJsonData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Readonly<{ | ||
| program: string; | ||
| parsed: unknown; | ||
| space: U64UnsafeBeyond2Pow53Minus1; | ||
| }> | Base64EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiCommonConfig = Readonly<{ | ||
| commitment?: Commitment; | ||
| minContextSlot?: Slot; | ||
| }>; | ||
| type GetAccountInfoApiSliceableCommonConfig = Readonly<{ | ||
| dataSlice?: DataSlice; | ||
| }>; | ||
| export interface GetAccountInfoApi { | ||
| /** | ||
| * Returns all information associated with the account of provided public key | ||
| */ | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base64'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base64+zstd'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & Readonly<{ | ||
| encoding: 'jsonParsed'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithJsonData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base58'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED; | ||
| getAccountInfo(address: Base58EncodedAddress, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithDefaultData; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getAccountInfo.d.ts.map |
| {"version":3,"file":"getAccountInfo.d.ts","sourceRoot":"","sources":["../../../src/rpc-methods/getAccountInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEpF,KAAK,kBAAkB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,oBAAoB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AACpF,KAAK,kBAAkB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,oBAAoB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AACpF,KAAK,gCAAgC,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,kCAAkC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAEhH,KAAK,yBAAyB,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAChE,KAAK,yBAAyB,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAChE,KAAK,uCAAuC,GAAG,CAAC,gCAAgC,EAAE,aAAa,CAAC,CAAC;AAEjG,KAAK,6BAA6B,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,QA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EAAE,UAAU,CAAC;IAExB,cAAc,CAAC,EAAE,IAAI,CAAC;CACzB,CAAC,CAAC;AAEH,KAAK,sCAAsC,GAAG,QAAQ,CAAC;IAEnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,6BAA6B,GACjC,sCAAsC,GACtC,QAAQ,CAAC;QACL,QAAQ,EAAE,QAAQ,CAAC;KACtB,CAAC,GACP,6BAA6B,GAAG,8CAA8C,CAAC;IAClF,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,6BAA6B,GACjC,sCAAsC,GACtC,QAAQ,CAAC;QACL,QAAQ,EAAE,aAAa,CAAC;KAC3B,CAAC,GACP,6BAA6B,GAAG,4DAA4D,CAAC;IAChG,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,6BAA6B,GACjC,QAAQ,CAAC;QACL,QAAQ,EAAE,YAAY,CAAC;KAC1B,CAAC,GACP,6BAA6B,GAAG,qCAAqC,CAAC;IACzE,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,6BAA6B,GACjC,sCAAsC,GACtC,QAAQ,CAAC;QACL,QAAQ,EAAE,QAAQ,CAAC;KACtB,CAAC,GACP,6BAA6B,GAAG,yDAAyD,CAAC;IAC7F,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,6BAA6B,GACvC,6BAA6B,GAAG,wCAAwC,CAAC;CAC/E"} |
| import { U64UnsafeBeyond2Pow53Minus1, Commitment, Slot } from './common'; | ||
| type GetBlockHeightApiResponse = U64UnsafeBeyond2Pow53Minus1; | ||
| export interface GetBlockHeightApi { | ||
| /** | ||
| * Returns the current block height of the node | ||
| */ | ||
| getBlockHeight(config?: Readonly<{ | ||
| commitment?: Commitment; | ||
| minContextSlot?: Slot; | ||
| }>): GetBlockHeightApiResponse; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getBlockHeight.d.ts.map |
| {"version":3,"file":"getBlockHeight.d.ts","sourceRoot":"","sources":["../../../src/rpc-methods/getBlockHeight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEzE,KAAK,yBAAyB,GAAG,2BAA2B,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,cAAc,CACV,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,UAAU,CAAC;QAExB,cAAc,CAAC,EAAE,IAAI,CAAC;KACzB,CAAC,GACH,yBAAyB,CAAC;CAChC"} |
| import { Slot, Commitment } from './common'; | ||
| type GetBlocksApiResponse = Slot[]; | ||
| export interface GetBlocksApi { | ||
| /** | ||
| * Returns a list of confirmed blocks between two slots | ||
| */ | ||
| getBlocks(startSlot: Slot, endSlotInclusive?: Slot, config?: Readonly<{ | ||
| commitment?: Exclude<Commitment, 'processed'>; | ||
| }>): GetBlocksApiResponse; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getBlocks.d.ts.map |
| {"version":3,"file":"getBlocks.d.ts","sourceRoot":"","sources":["../../../src/rpc-methods/getBlocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,oBAAoB,GAAG,IAAI,EAAE,CAAC;AAEnC,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,SAAS,CACL,SAAS,EAAE,IAAI,EACf,gBAAgB,CAAC,EAAE,IAAI,EACvB,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;KACjD,CAAC,GACH,oBAAoB,CAAC;CAC3B"} |
| import { Base58EncodedAddress } from '@solana/keys'; | ||
| import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
| type GetInflationRewardApiResponse = Readonly<{ | ||
| amount: U64UnsafeBeyond2Pow53Minus1; | ||
| commission: number; | ||
| effectiveSlot: U64UnsafeBeyond2Pow53Minus1; | ||
| epoch: U64UnsafeBeyond2Pow53Minus1; | ||
| postBalance: U64UnsafeBeyond2Pow53Minus1; | ||
| }>; | ||
| export interface GetInflationRewardApi { | ||
| /** | ||
| * Returns the current block height of the node | ||
| */ | ||
| getInflationReward(addresses: Base58EncodedAddress[], config?: Readonly<{ | ||
| commitment?: Commitment; | ||
| epoch?: U64UnsafeBeyond2Pow53Minus1; | ||
| minContextSlot?: Slot; | ||
| }>): Promise<readonly (GetInflationRewardApiResponse | null)[]>; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getInflationReward.d.ts.map |
| {"version":3,"file":"getInflationReward.d.ts","sourceRoot":"","sources":["../../../src/rpc-methods/getInflationReward.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEzE,KAAK,6BAA6B,GAAG,QAAQ,CAAC;IAE1C,MAAM,EAAE,2BAA2B,CAAC;IAEpC,UAAU,EAAE,MAAM,CAAC;IAEnB,aAAa,EAAE,2BAA2B,CAAC;IAE3C,KAAK,EAAE,2BAA2B,CAAC;IAEnC,WAAW,EAAE,2BAA2B,CAAC;CAC5C,CAAC,CAAC;AAEH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,kBAAkB,CACd,SAAS,EAAE,oBAAoB,EAAE,EACjC,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,UAAU,CAAC;QAGxB,KAAK,CAAC,EAAE,2BAA2B,CAAC;QAEpC,cAAc,CAAC,EAAE,IAAI,CAAC;KACzB,CAAC,GACH,OAAO,CAAC,SAAS,CAAC,6BAA6B,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;CACjE"} |
| 'use strict'; | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| 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) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| exports.createSolanaRpcApi = createSolanaRpcApi; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.node.cjs.map |
| 'use strict'; | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| 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) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| exports.createSolanaRpcApi = createSolanaRpcApi; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.browser.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":""} | ||
| {"version":3,"sources":["../src/params-patcher.ts","../src/response-patcher-types.ts","../src/response-patcher-allowed-numeric-values.ts","../src/response-patcher.ts","../src/index.ts"],"names":["visitNode"],"mappings":";AAMA,SAAS,UAAa,OAAU,SAA8B,mBAAwD;AAClH,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM;AAAA,MAAI,CAAC,SAAS,OACvB,UAAU,SAAS,CAAC,GAAG,SAAS,EAAE,GAAG,iBAAiB;AAAA,IAC1D;AAAA,EACJ,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,MAAM,CAAC;AACb,eAAW,YAAY,OAAO;AAC1B,UAAI,OAAO,UAAU,eAAe,KAAK,OAAO,QAAQ,GAAG;AACvD,YAAI,QAAQ,IAAI,UAAU,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,QAAQ,GAAG,iBAAiB;AAAA,M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AS,8BACZ,aACA,YACC;AACD,QAAM,kBAAkB,aAAa,yBAAyB,UAAU,IAAI;AAC5E,SAAOA,WAAU,aAAa,mBAAmB,CAAC,CAAC;AACvD;;;AChCO,SAAS,mBAAmB,QAA4C;AAC3E,SAAO,IAAI,MAAM,CAAC,GAAgC;AAAA,IAC9C,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,OACO,MACL;AACE,YAAM,CAAC,GAAG,CAAC,IAAI;AACf,YAAM,aAAa,EAAE,SAAS;AAC9B,aAAO,YACA,WAGwD;AAC3D,cAAM,wBAAwB,QAAQ;AACtC,cAAM,SAAS;AAAA,UACX;AAAA,UACA,wBACM,CAAC,SAAS,UAAU,sBAAsB,YAAY,SAAS,KAAK,IACpE;AAAA,QACV;AACA,eAAO;AAAA,UACH;AAAA,UACA;AAAA,UACA,mBAAmB,iBAAe,8BAA8B,aAAa,UAAU;AAAA,QAC3F;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,CAAC;AACL","sourcesContent":["type IntegerOverflowHandler = (keyPath: (number | string)[], value: bigint) => void;\ntype Patched<T> = T extends object ? { [Property in keyof T]: Patched<T[Property]> } : T extends bigint ? number : T;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction visitNode<T>(value: T, keyPath: (number | string)[], onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n if (Array.isArray(value)) {\n return value.map((element, ii) =>\n visitNode(element, [...keyPath, ii], onIntegerOverflow)\n ) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const propName in value) {\n if (Object.prototype.hasOwnProperty.call(value, propName)) {\n out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);\n }\n }\n return out as TypescriptBug33014;\n } else if (typeof value === 'bigint') {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // downcasting `bigints` to `numbers`.\n if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {\n onIntegerOverflow(keyPath, value);\n }\n return Number(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n return visitNode(params, [], onIntegerOverflow);\n}\n","export type KeyPathWildcard = { readonly __keyPathWildcard: unique symbol };\n\nexport const KEYPATH_WILDCARD = {} as KeyPathWildcard;\n","import { createSolanaRpcApi } from './index';\nimport { KeyPath } from './response-patcher';\nimport { KEYPATH_WILDCARD } from './response-patcher-types';\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nexport const ALLOWED_NUMERIC_KEYPATHS: Partial<\n Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>\n> = {\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n};\n","import { createSolanaRpcApi } from './index';\nimport { ALLOWED_NUMERIC_KEYPATHS } from './response-patcher-allowed-numeric-values';\nimport { KEYPATH_WILDCARD, KeyPathWildcard } from './response-patcher-types';\n\nexport type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction getNextAllowedKeypaths(keyPaths: readonly KeyPath[], property: number | string) {\n return keyPaths\n .filter(keyPath => (keyPath[0] === KEYPATH_WILDCARD && typeof property === 'number') || keyPath[0] === property)\n .map(keyPath => keyPath.slice(1));\n}\n\nfunction visitNode<T>(value: unknown, allowedKeypaths: readonly KeyPath[]): T {\n if (Array.isArray(value)) {\n return value.map((element, ii) => {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);\n return visitNode(element, nextAllowedKeypaths);\n }) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const [propName, innerValue] of Object.entries(value)) {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);\n out[propName] = visitNode(innerValue, nextAllowedKeypaths);\n }\n return out as TypescriptBug33014;\n } else if (\n typeof value === 'number' &&\n // The presence of an allowed keypath on the route to this value implies it's allowlisted;\n // Upcast the value to `bigint` unless an allowed keypath is present.\n allowedKeypaths.length === 0\n ) {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // upcasting `numbers` to `bigints`.\n return BigInt(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchResponseForSolanaLabsRpc<T>(\n rawResponse: unknown,\n methodName?: keyof ReturnType<typeof createSolanaRpcApi>\n): T {\n const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : undefined;\n return visitNode(rawResponse, allowedKeypaths ?? []);\n}\n","import {\n IRpcApi,\n TransportRequest,\n} from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types';\nimport { patchParamsForSolanaLabsRpc } from './params-patcher';\nimport { patchResponseForSolanaLabsRpc } from './response-patcher';\nimport { GetAccountInfoApi } from './rpc-methods/getAccountInfo';\nimport { GetBlockHeightApi } from './rpc-methods/getBlockHeight';\nimport { GetBlocksApi } from './rpc-methods/getBlocks';\nimport { GetInflationRewardApi } from './rpc-methods/getInflationReward';\n\ntype Config = Readonly<{\n onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;\n}>;\n\nexport type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;\n\nexport function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods> {\n return new Proxy({} as IRpcApi<SolanaRpcMethods>, {\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n get<TMethodName extends keyof IRpcApi<SolanaRpcMethods>>(\n ...args: Parameters<NonNullable<ProxyHandler<IRpcApi<SolanaRpcMethods>>['get']>>\n ) {\n const [_, p] = args;\n const methodName = p.toString() as keyof SolanaRpcMethods;\n return function (\n ...rawParams: Parameters<\n SolanaRpcMethods[TMethodName] extends CallableFunction ? SolanaRpcMethods[TMethodName] : never\n >\n ): TransportRequest<ReturnType<SolanaRpcMethods[TMethodName]>> {\n const handleIntegerOverflow = config?.onIntegerOverflow;\n const params = patchParamsForSolanaLabsRpc(\n rawParams,\n handleIntegerOverflow\n ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value)\n : undefined\n );\n return {\n methodName,\n params,\n responseProcessor: rawResponse => patchResponseForSolanaLabsRpc(rawResponse, methodName),\n };\n };\n },\n });\n}\n"]} |
@@ -0,3 +1,96 @@ | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| return new Proxy({}, { | ||
| defineProperty() { | ||
| return false; | ||
| }, | ||
| deleteProperty() { | ||
| return false; | ||
| }, | ||
| get(...args) { | ||
| const [_, p] = args; | ||
| const methodName = p.toString(); | ||
| return function(...rawParams) { | ||
| const handleIntegerOverflow = config?.onIntegerOverflow; | ||
| const params = patchParamsForSolanaLabsRpc( | ||
| rawParams, | ||
| handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
| ); | ||
| return { | ||
| methodName, | ||
| params, | ||
| responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| export { createSolanaRpcApi }; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.browser.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":""} | ||
| {"version":3,"sources":["../src/params-patcher.ts","../src/response-patcher-types.ts","../src/response-patcher-allowed-numeric-values.ts","../src/response-patcher.ts","../src/index.ts"],"names":["visitNode"],"mappings":";AAMA,SAAS,UAAa,OAAU,SAA8B,mBAAwD;AAClH,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM;AAAA,MAAI,CAAC,SAAS,OACvB,UAAU,SAAS,CAAC,GAAG,SAAS,EAAE,GAAG,iBAAiB;AAAA,IAC1D;AAAA,EACJ,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,MAAM,CAAC;AACb,eAAW,YAAY,OAAO;AAC1B,UAAI,OAAO,UAAU,eAAe,KAAK,OAAO,QAAQ,GAAG;AACvD,YAAI,QAAQ,IAAI,UAAU,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,QAAQ,GAAG,iBAAiB;AAAA,MACxF;AAAA,IACJ;AACA,WAAO;AAAA,EACX,WAAW,OAAO,UAAU,UAAU;AAIlC,QAAI,sBAAsB,QAAQ,OAAO,oBAAoB,QAAQ,CAAC,OAAO,mBAAmB;AAC5F,wBAAkB,SAAS,KAAK;AAAA,IACpC;AACA,WAAO,OAAO,KAAK;AAAA,EACvB,OAAO;AACH,WAAO;AAAA,EACX;AACJ;AAEO,SAAS,4BAA+B,QAAW,mBAAwD;AAC9G,SAAO,UAAU,QAAQ,CAAC,GAAG,iBAAiB;AAClD;;;AChCO,IAAM,mBAAmB,CAAC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AC9B,aAAO,YACA,WAGwD;AAC3D,cAAM,wBAAwB,QAAQ;AACtC,cAAM,SAAS;AAAA,UACX;AAAA,UACA,wBACM,CAAC,SAAS,UAAU,sBAAsB,YAAY,SAAS,KAAK,IACpE;AAAA,QACV;AACA,eAAO;AAAA,UACH;AAAA,UACA;AAAA,UACA,mBAAmB,iBAAe,8BAA8B,aAAa,UAAU;AAAA,QAC3F;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,CAAC;AACL","sourcesContent":["type IntegerOverflowHandler = (keyPath: (number | string)[], value: bigint) => void;\ntype Patched<T> = T extends object ? { [Property in keyof T]: Patched<T[Property]> } : T extends bigint ? number : T;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction visitNode<T>(value: T, keyPath: (number | string)[], onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n if (Array.isArray(value)) {\n return value.map((element, ii) =>\n visitNode(element, [...keyPath, ii], onIntegerOverflow)\n ) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const propName in value) {\n if (Object.prototype.hasOwnProperty.call(value, propName)) {\n out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);\n }\n }\n return out as TypescriptBug33014;\n } else if (typeof value === 'bigint') {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // downcasting `bigints` to `numbers`.\n if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {\n onIntegerOverflow(keyPath, value);\n }\n return Number(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n return visitNode(params, [], onIntegerOverflow);\n}\n","export type KeyPathWildcard = { readonly __keyPathWildcard: unique symbol };\n\nexport const KEYPATH_WILDCARD = {} as KeyPathWildcard;\n","import { createSolanaRpcApi } from './index';\nimport { KeyPath } from './response-patcher';\nimport { KEYPATH_WILDCARD } from './response-patcher-types';\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nexport const ALLOWED_NUMERIC_KEYPATHS: Partial<\n Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>\n> = {\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n};\n","import { createSolanaRpcApi } from './index';\nimport { ALLOWED_NUMERIC_KEYPATHS } from './response-patcher-allowed-numeric-values';\nimport { KEYPATH_WILDCARD, KeyPathWildcard } from './response-patcher-types';\n\nexport type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction getNextAllowedKeypaths(keyPaths: readonly KeyPath[], property: number | string) {\n return keyPaths\n .filter(keyPath => (keyPath[0] === KEYPATH_WILDCARD && typeof property === 'number') || keyPath[0] === property)\n .map(keyPath => keyPath.slice(1));\n}\n\nfunction visitNode<T>(value: unknown, allowedKeypaths: readonly KeyPath[]): T {\n if (Array.isArray(value)) {\n return value.map((element, ii) => {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);\n return visitNode(element, nextAllowedKeypaths);\n }) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const [propName, innerValue] of Object.entries(value)) {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);\n out[propName] = visitNode(innerValue, nextAllowedKeypaths);\n }\n return out as TypescriptBug33014;\n } else if (\n typeof value === 'number' &&\n // The presence of an allowed keypath on the route to this value implies it's allowlisted;\n // Upcast the value to `bigint` unless an allowed keypath is present.\n allowedKeypaths.length === 0\n ) {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // upcasting `numbers` to `bigints`.\n return BigInt(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchResponseForSolanaLabsRpc<T>(\n rawResponse: unknown,\n methodName?: keyof ReturnType<typeof createSolanaRpcApi>\n): T {\n const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : undefined;\n return visitNode(rawResponse, allowedKeypaths ?? []);\n}\n","import {\n IRpcApi,\n TransportRequest,\n} from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types';\nimport { patchParamsForSolanaLabsRpc } from './params-patcher';\nimport { patchResponseForSolanaLabsRpc } from './response-patcher';\nimport { GetAccountInfoApi } from './rpc-methods/getAccountInfo';\nimport { GetBlockHeightApi } from './rpc-methods/getBlockHeight';\nimport { GetBlocksApi } from './rpc-methods/getBlocks';\nimport { GetInflationRewardApi } from './rpc-methods/getInflationReward';\n\ntype Config = Readonly<{\n onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;\n}>;\n\nexport type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;\n\nexport function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods> {\n return new Proxy({} as IRpcApi<SolanaRpcMethods>, {\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n get<TMethodName extends keyof IRpcApi<SolanaRpcMethods>>(\n ...args: Parameters<NonNullable<ProxyHandler<IRpcApi<SolanaRpcMethods>>['get']>>\n ) {\n const [_, p] = args;\n const methodName = p.toString() as keyof SolanaRpcMethods;\n return function (\n ...rawParams: Parameters<\n SolanaRpcMethods[TMethodName] extends CallableFunction ? SolanaRpcMethods[TMethodName] : never\n >\n ): TransportRequest<ReturnType<SolanaRpcMethods[TMethodName]>> {\n const handleIntegerOverflow = config?.onIntegerOverflow;\n const params = patchParamsForSolanaLabsRpc(\n rawParams,\n handleIntegerOverflow\n ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value)\n : undefined\n );\n return {\n methodName,\n params,\n responseProcessor: rawResponse => patchResponseForSolanaLabsRpc(rawResponse, methodName),\n };\n };\n },\n });\n}\n"]} |
+93
-0
@@ -0,3 +1,96 @@ | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| return new Proxy({}, { | ||
| defineProperty() { | ||
| return false; | ||
| }, | ||
| deleteProperty() { | ||
| return false; | ||
| }, | ||
| get(...args) { | ||
| const [_, p] = args; | ||
| const methodName = p.toString(); | ||
| return function(...rawParams) { | ||
| const handleIntegerOverflow = config?.onIntegerOverflow; | ||
| const params = patchParamsForSolanaLabsRpc( | ||
| rawParams, | ||
| handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
| ); | ||
| return { | ||
| methodName, | ||
| params, | ||
| responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| export { createSolanaRpcApi }; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.native.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":""} | ||
| {"version":3,"sources":["../src/params-patcher.ts","../src/response-patcher-types.ts","../src/response-patcher-allowed-numeric-values.ts","../src/response-patcher.ts","../src/index.ts"],"names":["visitNode"],"mappings":";AAMA,SAAS,UAAa,OAAU,SAA8B,mBAAwD;AAClH,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM;AAAA,MAAI,CAAC,SAAS,OACvB,UAAU,SAAS,CAAC,GAAG,SAAS,EAAE,GAAG,iBAAiB;AAAA,IAC1D;AAAA,EACJ,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,MAAM,CAAC;AACb,eAAW,YAAY,OAAO;AAC1B,UAAI,OAAO,UAAU,eAAe,KAAK,OAAO,QAAQ,GAAG;AACvD,YAAI,QAAQ,IAAI,UAAU,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,QAAQ,GAAG,iBAAiB;AAAA,MACxF;AAAA,IACJ;AACA,WAAO;AAAA,EACX,WAAW,OAAO,UAAU,UAAU;AAIlC,QAAI,sBAAsB,QAAQ,OAAO,oBAAoB,QAAQ,CAAC,OAAO,mBAAmB;AAC5F,wBAAkB,SAAS,KAAK;AAAA,IACpC;AACA,WAAO,OAAO,KAAK;AAAA,EACvB,OAAO;AACH,WAAO;AAAA,EACX;AACJ;AAEO,SAAS,4BAA+B,QAAW,mBAAwD;AAC9G,SAAO,UAAU,QAAQ,CAAC,GAAG,iBAAiB;AAClD;;;AChCO,IAAM,mBAAmB,CAAC;;;ACM1B,IAAM,2BAET;AAAA,EACA,oBAAoB,CAAC,CAAC,kBAAkB,YAAY,CAAC;AACzD;;;ACHA,SAAS,uBAAuB,UAA8B,UAA2B;AACrF,SAAO,SACF,OAAO,aAAY,QAAQ,CAAC,MAAM,oBAAoB,OAAO,aAAa,YAAa,QAAQ,CAAC,MAAM,QAAQ,EAC9G,IAAI,aAAW,QAAQ,MAAM,CAAC,CAAC;AACxC;AAEA,SAASA,WAAa,OAAgB,iBAAwC;AAC1E,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAA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\ntype Patched<T> = T extends object ? { [Property in keyof T]: Patched<T[Property]> } : T extends bigint ? number : T;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction visitNode<T>(value: T, keyPath: (number | string)[], onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n if (Array.isArray(value)) {\n return value.map((element, ii) =>\n visitNode(element, [...keyPath, ii], onIntegerOverflow)\n ) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const propName in value) {\n if (Object.prototype.hasOwnProperty.call(value, propName)) {\n out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);\n }\n }\n return out as TypescriptBug33014;\n } else if (typeof value === 'bigint') {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // downcasting `bigints` to `numbers`.\n if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {\n onIntegerOverflow(keyPath, value);\n }\n return Number(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n return visitNode(params, [], onIntegerOverflow);\n}\n","export type KeyPathWildcard = { readonly __keyPathWildcard: unique symbol };\n\nexport const KEYPATH_WILDCARD = {} as KeyPathWildcard;\n","import { createSolanaRpcApi } from './index';\nimport { KeyPath } from './response-patcher';\nimport { KEYPATH_WILDCARD } from './response-patcher-types';\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nexport const ALLOWED_NUMERIC_KEYPATHS: Partial<\n Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>\n> = {\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n};\n","import { createSolanaRpcApi } from './index';\nimport { ALLOWED_NUMERIC_KEYPATHS } from './response-patcher-allowed-numeric-values';\nimport { KEYPATH_WILDCARD, KeyPathWildcard } from './response-patcher-types';\n\nexport type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction getNextAllowedKeypaths(keyPaths: readonly KeyPath[], property: number | string) {\n return keyPaths\n .filter(keyPath => (keyPath[0] === KEYPATH_WILDCARD && typeof property === 'number') || keyPath[0] === property)\n .map(keyPath => keyPath.slice(1));\n}\n\nfunction visitNode<T>(value: unknown, allowedKeypaths: readonly KeyPath[]): T {\n if (Array.isArray(value)) {\n return value.map((element, ii) => {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);\n return visitNode(element, nextAllowedKeypaths);\n }) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const [propName, innerValue] of Object.entries(value)) {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);\n out[propName] = visitNode(innerValue, nextAllowedKeypaths);\n }\n return out as TypescriptBug33014;\n } else if (\n typeof value === 'number' &&\n // The presence of an allowed keypath on the route to this value implies it's allowlisted;\n // Upcast the value to `bigint` unless an allowed keypath is present.\n allowedKeypaths.length === 0\n ) {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // upcasting `numbers` to `bigints`.\n return BigInt(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchResponseForSolanaLabsRpc<T>(\n rawResponse: unknown,\n methodName?: keyof ReturnType<typeof createSolanaRpcApi>\n): T {\n const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : undefined;\n return visitNode(rawResponse, allowedKeypaths ?? []);\n}\n","import {\n IRpcApi,\n TransportRequest,\n} from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types';\nimport { patchParamsForSolanaLabsRpc } from './params-patcher';\nimport { patchResponseForSolanaLabsRpc } from './response-patcher';\nimport { GetAccountInfoApi } from './rpc-methods/getAccountInfo';\nimport { GetBlockHeightApi } from './rpc-methods/getBlockHeight';\nimport { GetBlocksApi } from './rpc-methods/getBlocks';\nimport { GetInflationRewardApi } from './rpc-methods/getInflationReward';\n\ntype Config = Readonly<{\n onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;\n}>;\n\nexport type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;\n\nexport function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods> {\n return new Proxy({} as IRpcApi<SolanaRpcMethods>, {\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n get<TMethodName extends keyof IRpcApi<SolanaRpcMethods>>(\n ...args: Parameters<NonNullable<ProxyHandler<IRpcApi<SolanaRpcMethods>>['get']>>\n ) {\n const [_, p] = args;\n const methodName = p.toString() as keyof SolanaRpcMethods;\n return function (\n ...rawParams: Parameters<\n SolanaRpcMethods[TMethodName] extends CallableFunction ? SolanaRpcMethods[TMethodName] : never\n >\n ): TransportRequest<ReturnType<SolanaRpcMethods[TMethodName]>> {\n const handleIntegerOverflow = config?.onIntegerOverflow;\n const params = patchParamsForSolanaLabsRpc(\n rawParams,\n handleIntegerOverflow\n ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value)\n : undefined\n );\n return {\n methodName,\n params,\n responseProcessor: rawResponse => patchResponseForSolanaLabsRpc(rawResponse, methodName),\n };\n };\n },\n });\n}\n"]} |
+94
-0
| 'use strict'; | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| 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) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| exports.createSolanaRpcApi = createSolanaRpcApi; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.node.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":""} | ||
| {"version":3,"sources":["../src/params-patcher.ts","../src/response-patcher-types.ts","../src/response-patcher-allowed-numeric-values.ts","../src/response-patcher.ts","../src/index.ts"],"names":["visitNode"],"mappings":";AAMA,SAAS,UAAa,OAAU,SAA8B,mBAAwD;AAClH,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM;AAAA,MAAI,CAAC,SAAS,OACvB,UAAU,SAAS,CAAC,GAAG,SAAS,EAAE,GAAG,iBAAiB;AAAA,IAC1D;AAAA,EACJ,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,MAAM,CAAC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BAAmB;AAAA,IAC7D;AACA,WAAO;AAAA,EACX,WACI,OAAO,UAAU;AAAA;AAAA,EAGjB,gBAAgB,WAAW,GAC7B;AAIE,WAAO,OAAO,KAAK;AAAA,EACvB,OAAO;AACH,WAAO;AAAA,EACX;AACJ;AAEO,SAAS,8BACZ,aACA,YACC;AACD,QAAM,kBAAkB,aAAa,yBAAyB,UAAU,IAAI;AAC5E,SAAOA,WAAU,aAAa,mBAAmB,CAAC,CAAC;AACvD;;;AChCO,SAAS,mBAAmB,QAA4C;AAC3E,SAAO,IAAI,MAAM,CAAC,GAAgC;AAAA,IAC9C,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,OACO,MACL;AACE,YAAM,CAAC,GAAG,CAAC,IAAI;AACf,YAAM,aAAa,EAAE,SAAS;AAC9B,aAAO,YACA,WAGwD;AAC3D,cAAM,wBAAwB,QAAQ;AACtC,cAAM,SAAS;AAAA,UACX;AAAA,UACA,wBACM,CAAC,SAAS,UAAU,sBAAsB,YAAY,SAAS,KAAK,IACpE;AAAA,QACV;AACA,eAAO;AAAA,UACH;AAAA,UACA;AAAA,UACA,mBAAmB,iBAAe,8BAA8B,aAAa,UAAU;AAAA,QAC3F;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,CAAC;AACL","sourcesContent":["type IntegerOverflowHandler = (keyPath: (number | string)[], value: bigint) => void;\ntype Patched<T> = T extends object ? { [Property in keyof T]: Patched<T[Property]> } : T extends bigint ? number : T;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction visitNode<T>(value: T, keyPath: (number | string)[], onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n if (Array.isArray(value)) {\n return value.map((element, ii) =>\n visitNode(element, [...keyPath, ii], onIntegerOverflow)\n ) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const propName in value) {\n if (Object.prototype.hasOwnProperty.call(value, propName)) {\n out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);\n }\n }\n return out as TypescriptBug33014;\n } else if (typeof value === 'bigint') {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // downcasting `bigints` to `numbers`.\n if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {\n onIntegerOverflow(keyPath, value);\n }\n return Number(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n return visitNode(params, [], onIntegerOverflow);\n}\n","export type KeyPathWildcard = { readonly __keyPathWildcard: unique symbol };\n\nexport const KEYPATH_WILDCARD = {} as KeyPathWildcard;\n","import { createSolanaRpcApi } from './index';\nimport { KeyPath } from './response-patcher';\nimport { KEYPATH_WILDCARD } from './response-patcher-types';\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nexport const ALLOWED_NUMERIC_KEYPATHS: Partial<\n Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>\n> = {\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n};\n","import { createSolanaRpcApi } from './index';\nimport { ALLOWED_NUMERIC_KEYPATHS } from './response-patcher-allowed-numeric-values';\nimport { KEYPATH_WILDCARD, KeyPathWildcard } from './response-patcher-types';\n\nexport type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction getNextAllowedKeypaths(keyPaths: readonly KeyPath[], property: number | string) {\n return keyPaths\n .filter(keyPath => (keyPath[0] === KEYPATH_WILDCARD && typeof property === 'number') || keyPath[0] === property)\n .map(keyPath => keyPath.slice(1));\n}\n\nfunction visitNode<T>(value: unknown, allowedKeypaths: readonly KeyPath[]): T {\n if (Array.isArray(value)) {\n return value.map((element, ii) => {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);\n return visitNode(element, nextAllowedKeypaths);\n }) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const [propName, innerValue] of Object.entries(value)) {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);\n out[propName] = visitNode(innerValue, nextAllowedKeypaths);\n }\n return out as TypescriptBug33014;\n } else if (\n typeof value === 'number' &&\n // The presence of an allowed keypath on the route to this value implies it's allowlisted;\n // Upcast the value to `bigint` unless an allowed keypath is present.\n allowedKeypaths.length === 0\n ) {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // upcasting `numbers` to `bigints`.\n return BigInt(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchResponseForSolanaLabsRpc<T>(\n rawResponse: unknown,\n methodName?: keyof ReturnType<typeof createSolanaRpcApi>\n): T {\n const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : undefined;\n return visitNode(rawResponse, allowedKeypaths ?? []);\n}\n","import {\n IRpcApi,\n TransportRequest,\n} from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types';\nimport { patchParamsForSolanaLabsRpc } from './params-patcher';\nimport { patchResponseForSolanaLabsRpc } from './response-patcher';\nimport { GetAccountInfoApi } from './rpc-methods/getAccountInfo';\nimport { GetBlockHeightApi } from './rpc-methods/getBlockHeight';\nimport { GetBlocksApi } from './rpc-methods/getBlocks';\nimport { GetInflationRewardApi } from './rpc-methods/getInflationReward';\n\ntype Config = Readonly<{\n onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;\n}>;\n\nexport type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;\n\nexport function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods> {\n return new Proxy({} as IRpcApi<SolanaRpcMethods>, {\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n get<TMethodName extends keyof IRpcApi<SolanaRpcMethods>>(\n ...args: Parameters<NonNullable<ProxyHandler<IRpcApi<SolanaRpcMethods>>['get']>>\n ) {\n const [_, p] = args;\n const methodName = p.toString() as keyof SolanaRpcMethods;\n return function (\n ...rawParams: Parameters<\n SolanaRpcMethods[TMethodName] extends CallableFunction ? SolanaRpcMethods[TMethodName] : never\n >\n ): TransportRequest<ReturnType<SolanaRpcMethods[TMethodName]>> {\n const handleIntegerOverflow = config?.onIntegerOverflow;\n const params = patchParamsForSolanaLabsRpc(\n rawParams,\n handleIntegerOverflow\n ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value)\n : undefined\n );\n return {\n methodName,\n params,\n responseProcessor: rawResponse => patchResponseForSolanaLabsRpc(rawResponse, methodName),\n };\n };\n },\n });\n}\n"]} |
+93
-0
@@ -0,3 +1,96 @@ | ||
| // src/params-patcher.ts | ||
| function visitNode(value, keyPath, onIntegerOverflow) { | ||
| if (Array.isArray(value)) { | ||
| return value.map( | ||
| (element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow) | ||
| ); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const propName in value) { | ||
| if (Object.prototype.hasOwnProperty.call(value, propName)) { | ||
| out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow); | ||
| } | ||
| } | ||
| return out; | ||
| } else if (typeof value === "bigint") { | ||
| if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) { | ||
| onIntegerOverflow(keyPath, value); | ||
| } | ||
| return Number(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) { | ||
| return visitNode(params, [], onIntegerOverflow); | ||
| } | ||
| // src/response-patcher-types.ts | ||
| var KEYPATH_WILDCARD = {}; | ||
| // src/response-patcher-allowed-numeric-values.ts | ||
| var ALLOWED_NUMERIC_KEYPATHS = { | ||
| getInflationReward: [[KEYPATH_WILDCARD, "commission"]] | ||
| }; | ||
| // src/response-patcher.ts | ||
| function getNextAllowedKeypaths(keyPaths, property) { | ||
| return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1)); | ||
| } | ||
| function visitNode2(value, allowedKeypaths) { | ||
| if (Array.isArray(value)) { | ||
| return value.map((element, ii) => { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii); | ||
| return visitNode2(element, nextAllowedKeypaths); | ||
| }); | ||
| } else if (typeof value === "object" && value !== null) { | ||
| const out = {}; | ||
| for (const [propName, innerValue] of Object.entries(value)) { | ||
| const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName); | ||
| out[propName] = visitNode2(innerValue, nextAllowedKeypaths); | ||
| } | ||
| return out; | ||
| } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted; | ||
| // Upcast the value to `bigint` unless an allowed keypath is present. | ||
| allowedKeypaths.length === 0) { | ||
| return BigInt(value); | ||
| } else { | ||
| return value; | ||
| } | ||
| } | ||
| function patchResponseForSolanaLabsRpc(rawResponse, methodName) { | ||
| const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0; | ||
| return visitNode2(rawResponse, allowedKeypaths ?? []); | ||
| } | ||
| // src/index.ts | ||
| function createSolanaRpcApi(config) { | ||
| return new Proxy({}, { | ||
| defineProperty() { | ||
| return false; | ||
| }, | ||
| deleteProperty() { | ||
| return false; | ||
| }, | ||
| get(...args) { | ||
| const [_, p] = args; | ||
| const methodName = p.toString(); | ||
| return function(...rawParams) { | ||
| const handleIntegerOverflow = config?.onIntegerOverflow; | ||
| const params = patchParamsForSolanaLabsRpc( | ||
| rawParams, | ||
| handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0 | ||
| ); | ||
| return { | ||
| methodName, | ||
| params, | ||
| responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName) | ||
| }; | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| export { createSolanaRpcApi }; | ||
| //# sourceMappingURL=out.js.map | ||
| //# sourceMappingURL=index.node.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":""} | ||
| {"version":3,"sources":["../src/params-patcher.ts","../src/response-patcher-types.ts","../src/response-patcher-allowed-numeric-values.ts","../src/response-patcher.ts","../src/index.ts"],"names":["visitNode"],"mappings":";AAMA,SAAS,UAAa,OAAU,SAA8B,mBAAwD;AAClH,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM;AAAA,MAAI,CAAC,SAAS,OACvB,UAAU,SAAS,CAAC,GAAG,SAAS,EAAE,GAAG,iBAAiB;AAAA,IAC1D;AAAA,EACJ,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,MAAM,CAAC;AACb,eAAW,YAAY,OAAO;AAC1B,UAAI,OAAO,UAAU,eAAe,KAAK,OAAO,QAAQ,GAAG;AACvD,YAAI,QAAQ,IAAI,UAAU,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,QAAQ,GAAG,iBAAiB;AAAA,MACxF;AAAA,IACJ;AACA,WAAO;AAAA,EACX,WAAW,OAAO,UAAU,UAAU;AAIlC,QAAI,sBAAsB,QAAQ,OAAO,oBAAoB,QAAQ,CAAC,OAAO,mBAAmB;AAC5F,wBAAkB,SAAS,KAAK;AAAA,IACpC;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,CAAC,GAAgC;AAAA,IAC9C,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,iBAAiB;AACb,aAAO;AAAA,IACX;AAAA,IACA,OACO,MACL;AACE,YAAM,CAAC,GAAG,CAAC,IAAI;AACf,YAAM,aAAa,EAAE,SAAS;AAC9B,aAAO,YACA,WAGwD;AAC3D,cAAM,wBAAwB,QAAQ;AACtC,cAAM,SAAS;AAAA,UACX;AAAA,UACA,wBACM,CAAC,SAAS,UAAU,sBAAsB,YAAY,SAAS,KAAK,IACpE;AAAA,QACV;AACA,eAAO;AAAA,UACH;AAAA,UACA;AAAA,UACA,mBAAmB,iBAAe,8BAA8B,aAAa,UAAU;AAAA,QAC3F;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,CAAC;AACL","sourcesContent":["type IntegerOverflowHandler = (keyPath: (number | string)[], value: bigint) => void;\ntype Patched<T> = T extends object ? { [Property in keyof T]: Patched<T[Property]> } : T extends bigint ? number : T;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction visitNode<T>(value: T, keyPath: (number | string)[], onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n if (Array.isArray(value)) {\n return value.map((element, ii) =>\n visitNode(element, [...keyPath, ii], onIntegerOverflow)\n ) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const propName in value) {\n if (Object.prototype.hasOwnProperty.call(value, propName)) {\n out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);\n }\n }\n return out as TypescriptBug33014;\n } else if (typeof value === 'bigint') {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // downcasting `bigints` to `numbers`.\n if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {\n onIntegerOverflow(keyPath, value);\n }\n return Number(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchParamsForSolanaLabsRpc<T>(params: T, onIntegerOverflow?: IntegerOverflowHandler): Patched<T> {\n return visitNode(params, [], onIntegerOverflow);\n}\n","export type KeyPathWildcard = { readonly __keyPathWildcard: unique symbol };\n\nexport const KEYPATH_WILDCARD = {} as KeyPathWildcard;\n","import { createSolanaRpcApi } from './index';\nimport { KeyPath } from './response-patcher';\nimport { KEYPATH_WILDCARD } from './response-patcher-types';\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nexport const ALLOWED_NUMERIC_KEYPATHS: Partial<\n Record<keyof ReturnType<typeof createSolanaRpcApi>, readonly KeyPath[]>\n> = {\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n};\n","import { createSolanaRpcApi } from './index';\nimport { ALLOWED_NUMERIC_KEYPATHS } from './response-patcher-allowed-numeric-values';\nimport { KEYPATH_WILDCARD, KeyPathWildcard } from './response-patcher-types';\n\nexport type KeyPath = ReadonlyArray<KeyPathWildcard | number | string | KeyPath>;\n// FIXME(https://github.com/microsoft/TypeScript/issues/33014)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TypescriptBug33014 = any;\n\nfunction getNextAllowedKeypaths(keyPaths: readonly KeyPath[], property: number | string) {\n return keyPaths\n .filter(keyPath => (keyPath[0] === KEYPATH_WILDCARD && typeof property === 'number') || keyPath[0] === property)\n .map(keyPath => keyPath.slice(1));\n}\n\nfunction visitNode<T>(value: unknown, allowedKeypaths: readonly KeyPath[]): T {\n if (Array.isArray(value)) {\n return value.map((element, ii) => {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);\n return visitNode(element, nextAllowedKeypaths);\n }) as TypescriptBug33014;\n } else if (typeof value === 'object' && value !== null) {\n const out = {} as TypescriptBug33014;\n for (const [propName, innerValue] of Object.entries(value)) {\n const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);\n out[propName] = visitNode(innerValue, nextAllowedKeypaths);\n }\n return out as TypescriptBug33014;\n } else if (\n typeof value === 'number' &&\n // The presence of an allowed keypath on the route to this value implies it's allowlisted;\n // Upcast the value to `bigint` unless an allowed keypath is present.\n allowedKeypaths.length === 0\n ) {\n // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana\n // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely\n // upcasting `numbers` to `bigints`.\n return BigInt(value) as TypescriptBug33014;\n } else {\n return value as TypescriptBug33014;\n }\n}\n\nexport function patchResponseForSolanaLabsRpc<T>(\n rawResponse: unknown,\n methodName?: keyof ReturnType<typeof createSolanaRpcApi>\n): T {\n const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : undefined;\n return visitNode(rawResponse, allowedKeypaths ?? []);\n}\n","import {\n IRpcApi,\n TransportRequest,\n} from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types';\nimport { patchParamsForSolanaLabsRpc } from './params-patcher';\nimport { patchResponseForSolanaLabsRpc } from './response-patcher';\nimport { GetAccountInfoApi } from './rpc-methods/getAccountInfo';\nimport { GetBlockHeightApi } from './rpc-methods/getBlockHeight';\nimport { GetBlocksApi } from './rpc-methods/getBlocks';\nimport { GetInflationRewardApi } from './rpc-methods/getInflationReward';\n\ntype Config = Readonly<{\n onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void;\n}>;\n\nexport type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi;\n\nexport function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods> {\n return new Proxy({} as IRpcApi<SolanaRpcMethods>, {\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n get<TMethodName extends keyof IRpcApi<SolanaRpcMethods>>(\n ...args: Parameters<NonNullable<ProxyHandler<IRpcApi<SolanaRpcMethods>>['get']>>\n ) {\n const [_, p] = args;\n const methodName = p.toString() as keyof SolanaRpcMethods;\n return function (\n ...rawParams: Parameters<\n SolanaRpcMethods[TMethodName] extends CallableFunction ? SolanaRpcMethods[TMethodName] : never\n >\n ): TransportRequest<ReturnType<SolanaRpcMethods[TMethodName]>> {\n const handleIntegerOverflow = config?.onIntegerOverflow;\n const params = patchParamsForSolanaLabsRpc(\n rawParams,\n handleIntegerOverflow\n ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value)\n : undefined\n );\n return {\n methodName,\n params,\n responseProcessor: rawResponse => patchResponseForSolanaLabsRpc(rawResponse, methodName),\n };\n };\n },\n });\n}\n"]} |
@@ -1,2 +0,12 @@ | ||
| export * from './types/jsonRpcApi'; | ||
| import { IRpcApi } from '@solana/rpc-transport/dist/types/json-rpc-transport/json-rpc-transport-types'; | ||
| import { GetAccountInfoApi } from './rpc-methods/getAccountInfo'; | ||
| import { GetBlockHeightApi } from './rpc-methods/getBlockHeight'; | ||
| import { GetBlocksApi } from './rpc-methods/getBlocks'; | ||
| import { GetInflationRewardApi } from './rpc-methods/getInflationReward'; | ||
| type Config = Readonly<{ | ||
| onIntegerOverflow?: (methodName: string, keyPath: (number | string)[], value: bigint) => void; | ||
| }>; | ||
| export type SolanaRpcMethods = GetAccountInfoApi & GetBlockHeightApi & GetBlocksApi & GetInflationRewardApi; | ||
| export declare function createSolanaRpcApi(config?: Config): IRpcApi<SolanaRpcMethods>; | ||
| export {}; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EAEV,MAAM,8EAA8E,CAAC;AAGtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,KAAK,MAAM,GAAG,QAAQ,CAAC;IACnB,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjG,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,YAAY,GAAG,qBAAqB,CAAC;AAE5G,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiC7E"} |
+14
-10
| { | ||
| "name": "@solana/rpc-core", | ||
| "version": "2.0.0-experimental.cf4231e", | ||
| "version": "2.0.0-experimental.f10010c", | ||
| "description": "A library for making calls to the Solana JSON RPC API", | ||
@@ -49,13 +49,13 @@ "exports": { | ||
| "dependencies": { | ||
| "@solana/keys": "2.0.0-experimental.cf4231e" | ||
| "@solana/keys": "2.0.0-experimental.f10010c" | ||
| }, | ||
| "devDependencies": { | ||
| "@solana/eslint-config-solana": "^0.0.4", | ||
| "@solana/eslint-config-solana": "^1.0.0", | ||
| "@swc/core": "^1.3.18", | ||
| "@swc/jest": "^0.2.23", | ||
| "@types/jest": "^29.5.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.43.0", | ||
| "@typescript-eslint/parser": "^5.43.0", | ||
| "agadoo": "^2.0.0", | ||
| "eslint": "^8.27.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.57.1", | ||
| "@typescript-eslint/parser": "^5.57.1", | ||
| "agadoo": "^3.0.0", | ||
| "eslint": "^8.37.0", | ||
| "eslint-plugin-jest": "^27.1.5", | ||
@@ -66,2 +66,3 @@ "eslint-plugin-react-hooks": "^4.6.0", | ||
| "jest-environment-jsdom": "^29.5.0", | ||
| "jest-fetch-mock": "^3.0.3", | ||
| "jest-runner-eslint": "^2.0.0", | ||
@@ -74,4 +75,5 @@ "jest-runner-prettier": "^1.0.0", | ||
| "turbo": "^1.6.3", | ||
| "typescript": "^4.9", | ||
| "typescript": "^5.0.3", | ||
| "version-from-git": "^1.1.1", | ||
| "@solana/rpc-transport": "2.0.0-experimental.f10010c", | ||
| "build-scripts": "0.0.0", | ||
@@ -92,3 +94,3 @@ "test-config": "0.0.0", | ||
| "compile:typedefs": "tsc -p ./tsconfig.declarations.json", | ||
| "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch", | ||
| "dev": "jest -c node_modules/test-config/jest-dev.config.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --watch", | ||
| "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
@@ -100,4 +102,6 @@ "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
| "test:treeshakability:node": "agadoo dist/index.native.js", | ||
| "test:typecheck": "tsc --noEmit" | ||
| "test:typecheck": "tsc --noEmit", | ||
| "test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --silent", | ||
| "test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --globalSetup test-config/test-validator-setup.js --globalTeardown test-config/test-validator-teardown.js --rootDir . --silent" | ||
| } | ||
| } |
| import { GetAccountInfoApi } from './rpc-methods/getAccountInfo'; | ||
| import { GetBlockHeightApi } from './rpc-methods/getBlockHeight'; | ||
| import { GetBlocksApi } from './rpc-methods/getBlocks'; | ||
| import { GetInflationRewardApi } from './rpc-methods/getInflationReward'; | ||
| export interface SolanaJsonRpcApi extends GetAccountInfoApi, GetBlockHeightApi, GetBlocksApi, GetInflationRewardApi { | ||
| } | ||
| //# sourceMappingURL=jsonRpcApi.d.ts.map |
| {"version":3,"file":"jsonRpcApi.d.ts","sourceRoot":"","sources":["../../../src/types/jsonRpcApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,qBAAqB;CAAG"} |
| export type Commitment = 'confirmed' | 'finalized' | 'processed'; | ||
| export type DataSlice = Readonly<{ | ||
| offset: number; | ||
| length: number; | ||
| }>; | ||
| export type Slot = U64UnsafeBeyond2Pow53Minus1; | ||
| export type U64UnsafeBeyond2Pow53Minus1 = bigint; | ||
| //# sourceMappingURL=common.d.ts.map |
| {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/types/rpc-methods/common.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAK/C,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC"} |
| import { Base58EncodedAddress } from '@solana/keys'; | ||
| import { Commitment, DataSlice, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
| type Base58EncodedBytes = string & { | ||
| readonly __base58EncodedBytes: unique symbol; | ||
| }; | ||
| type Base64EncodedBytes = string & { | ||
| readonly __base64EncodedBytes: unique symbol; | ||
| }; | ||
| type Base64EncodedZStdCompressedBytes = string & { | ||
| readonly __base64EncodedZStdCompressedBytes: unique symbol; | ||
| }; | ||
| type Base58EncodedDataResponse = [Base58EncodedBytes, 'base58']; | ||
| type Base64EncodedDataResponse = [Base64EncodedBytes, 'base64']; | ||
| type Base64EncodedZStdCompressedDataResponse = [Base64EncodedZStdCompressedBytes, 'base64+zstd']; | ||
| type GetAccountInfoApiResponseBase = Readonly<{ | ||
| context: Readonly<{ | ||
| slot: Slot; | ||
| }>; | ||
| value: Readonly<{ | ||
| executable: boolean; | ||
| lamports: U64UnsafeBeyond2Pow53Minus1; | ||
| owner: Base58EncodedAddress; | ||
| rentEpoch: U64UnsafeBeyond2Pow53Minus1; | ||
| space: U64UnsafeBeyond2Pow53Minus1; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithDefaultData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base58EncodedBytes; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base58EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase64EncodedData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base64EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Base64EncodedZStdCompressedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiResponseWithJsonData = Readonly<{ | ||
| value: Readonly<{ | ||
| data: Readonly<{ | ||
| program: string; | ||
| parsed: unknown; | ||
| space: U64UnsafeBeyond2Pow53Minus1; | ||
| }> | Base64EncodedDataResponse; | ||
| }> | null; | ||
| }>; | ||
| type GetAccountInfoApiCommonConfig = Readonly<{ | ||
| commitment?: Commitment; | ||
| minContextSlot?: Slot; | ||
| }>; | ||
| type GetAccountInfoApiSliceableCommonConfig = Readonly<{ | ||
| dataSlice?: DataSlice; | ||
| }>; | ||
| export interface GetAccountInfoApi { | ||
| /** | ||
| * Returns all information associated with the account of provided public key | ||
| */ | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base64'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base64+zstd'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & Readonly<{ | ||
| encoding: 'jsonParsed'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithJsonData; | ||
| getAccountInfo(address: Base58EncodedAddress, config: GetAccountInfoApiCommonConfig & GetAccountInfoApiSliceableCommonConfig & Readonly<{ | ||
| encoding: 'base58'; | ||
| }>): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED; | ||
| getAccountInfo(address: Base58EncodedAddress, config?: GetAccountInfoApiCommonConfig): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithDefaultData; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getAccountInfo.d.ts.map |
| {"version":3,"file":"getAccountInfo.d.ts","sourceRoot":"","sources":["../../../../src/types/rpc-methods/getAccountInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEpF,KAAK,kBAAkB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,oBAAoB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AACpF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AAE,6BAA6B,GACjC,sCAAsC,GACtC,QAAQ,CAAC;QACL,QAAQ,EAAE,QAAQ,CAAC;KACtB,CAAC,GACP,6BAA6B,GAAG,yDAAyD,CAAC;IAC7F,cAAc,CACV,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,6BAA6B,GACvC,6BAA6B,GAAG,wCAAwC,CAAC;CAC/E"} |
| import { U64UnsafeBeyond2Pow53Minus1, Commitment, Slot } from './common'; | ||
| type GetBlockHeightApiResponse = U64UnsafeBeyond2Pow53Minus1; | ||
| export interface GetBlockHeightApi { | ||
| /** | ||
| * Returns the current block height of the node | ||
| */ | ||
| getBlockHeight(config?: Readonly<{ | ||
| commitment?: Commitment; | ||
| minContextSlot?: Slot; | ||
| }>): GetBlockHeightApiResponse; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getBlockHeight.d.ts.map |
| {"version":3,"file":"getBlockHeight.d.ts","sourceRoot":"","sources":["../../../../src/types/rpc-methods/getBlockHeight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEzE,KAAK,yBAAyB,GAAG,2BAA2B,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,cAAc,CACV,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,UAAU,CAAC;QAExB,cAAc,CAAC,EAAE,IAAI,CAAC;KACzB,CAAC,GACH,yBAAyB,CAAC;CAChC"} |
| import { Slot, Commitment } from './common'; | ||
| type GetBlocksApiResponse = Slot[]; | ||
| export interface GetBlocksApi { | ||
| /** | ||
| * Returns a list of confirmed blocks between two slots | ||
| */ | ||
| getBlocks(startSlot: Slot, endSlotInclusive?: Slot, config?: Readonly<{ | ||
| commitment?: Exclude<Commitment, 'processed'>; | ||
| }>): GetBlocksApiResponse; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getBlocks.d.ts.map |
| {"version":3,"file":"getBlocks.d.ts","sourceRoot":"","sources":["../../../../src/types/rpc-methods/getBlocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,oBAAoB,GAAG,IAAI,EAAE,CAAC;AAEnC,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,SAAS,CACL,SAAS,EAAE,IAAI,EACf,gBAAgB,CAAC,EAAE,IAAI,EACvB,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;KACjD,CAAC,GACH,oBAAoB,CAAC;CAC3B"} |
| import { Base58EncodedAddress } from '@solana/keys'; | ||
| import { Commitment, Slot, U64UnsafeBeyond2Pow53Minus1 } from './common'; | ||
| type GetInflationRewardApiResponse = Readonly<{ | ||
| amount: U64UnsafeBeyond2Pow53Minus1; | ||
| commission: number; | ||
| effectiveSlot: U64UnsafeBeyond2Pow53Minus1; | ||
| epoch: U64UnsafeBeyond2Pow53Minus1; | ||
| postBalance: U64UnsafeBeyond2Pow53Minus1; | ||
| }>; | ||
| export interface GetInflationRewardApi { | ||
| /** | ||
| * Returns the current block height of the node | ||
| */ | ||
| getInflationReward(addresses: Base58EncodedAddress[], config?: Readonly<{ | ||
| commitment?: Commitment; | ||
| epoch?: U64UnsafeBeyond2Pow53Minus1; | ||
| minContextSlot?: Slot; | ||
| }>): Promise<readonly (GetInflationRewardApiResponse | null)[]>; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=getInflationReward.d.ts.map |
| {"version":3,"file":"getInflationReward.d.ts","sourceRoot":"","sources":["../../../../src/types/rpc-methods/getInflationReward.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEzE,KAAK,6BAA6B,GAAG,QAAQ,CAAC;IAE1C,MAAM,EAAE,2BAA2B,CAAC;IAEpC,UAAU,EAAE,MAAM,CAAC;IAEnB,aAAa,EAAE,2BAA2B,CAAC;IAE3C,KAAK,EAAE,2BAA2B,CAAC;IAEnC,WAAW,EAAE,2BAA2B,CAAC;CAC5C,CAAC,CAAC;AAEH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,kBAAkB,CACd,SAAS,EAAE,oBAAoB,EAAE,EACjC,MAAM,CAAC,EAAE,QAAQ,CAAC;QAEd,UAAU,CAAC,EAAE,UAAU,CAAC;QAGxB,KAAK,CAAC,EAAE,2BAA2B,CAAC;QAEpC,cAAc,CAAC,EAAE,IAAI,CAAC;KACzB,CAAC,GACH,OAAO,CAAC,SAAS,CAAC,6BAA6B,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;CACjE"} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
86210
445.77%33
22.22%706
380.27%27
8%1
Infinity%+ Added
- Removed