diff --git a/.changeset/gorgeous-foxes-type.md b/.changeset/gorgeous-foxes-type.md new file mode 100644 index 00000000000..e50915adfd5 --- /dev/null +++ b/.changeset/gorgeous-foxes-type.md @@ -0,0 +1,8 @@ +--- +'@solana/rpc-subscriptions-spec': patch +'@solana/rpc-spec-types': patch +'@solana/rpc-spec': patch +'@solana/rpc-api': patch +--- + +Rename `RpcResponse` type to `RpcResponseData` to make room for a new `RpcResponse` type diff --git a/packages/rpc-api/src/__tests__/get-stake-minimum-delegation-test.ts b/packages/rpc-api/src/__tests__/get-stake-minimum-delegation-test.ts index f41b05de178..5d2fd27f28f 100644 --- a/packages/rpc-api/src/__tests__/get-stake-minimum-delegation-test.ts +++ b/packages/rpc-api/src/__tests__/get-stake-minimum-delegation-test.ts @@ -11,7 +11,7 @@ describe('getStakeMinimumDelegation', () => { }); (['confirmed', 'finalized', 'processed'] as Commitment[]).forEach(commitment => { describe(`when called with \`${commitment}\` commitment`, () => { - it('returns the result as a bigint wrapped in an RpcResponse', async () => { + it('returns the result as a bigint wrapped in an RpcResponseData', async () => { expect.assertions(1); const result = await rpc.getStakeMinimumDelegation({ commitment }).send(); expect(result.value).toEqual(expect.any(BigInt)); diff --git a/packages/rpc-api/src/__tests__/is-blockhash-valid-test.ts b/packages/rpc-api/src/__tests__/is-blockhash-valid-test.ts index 90e8510b091..a007953ebb1 100644 --- a/packages/rpc-api/src/__tests__/is-blockhash-valid-test.ts +++ b/packages/rpc-api/src/__tests__/is-blockhash-valid-test.ts @@ -11,7 +11,7 @@ describe('isBlockhashValid', () => { }); (['confirmed', 'finalized', 'processed'] as Commitment[]).forEach(commitment => { describe(`when called with \`${commitment}\` commitment`, () => { - it('returns the result as a bool wrapped in an RpcResponse', async () => { + it('returns the result as a bool wrapped in an RpcResponseData', async () => { expect.assertions(1); const blockhash = '9PCVWkKP3bq1sT5eLFurUysMvVs4PxJsTfza5QSBB4d1' as Blockhash; const result = await rpc.isBlockhashValid(blockhash, { commitment }).send(); diff --git a/packages/rpc-spec-types/src/rpc-response.ts b/packages/rpc-spec-types/src/rpc-response.ts index 9b391507e5e..485323271f7 100644 --- a/packages/rpc-spec-types/src/rpc-response.ts +++ b/packages/rpc-spec-types/src/rpc-response.ts @@ -2,10 +2,11 @@ interface IHasIdentifier { readonly id: number; } -type RpcErrorResponse = Readonly<{ +type RpcErrorResponsePayload = Readonly<{ code: number; data?: unknown; message: string; }>; -export type RpcResponse = IHasIdentifier & Readonly<{ error: RpcErrorResponse } | { result: TResponse }>; +export type RpcResponseData = IHasIdentifier & + Readonly<{ error: RpcErrorResponsePayload } | { result: TResponse }>; diff --git a/packages/rpc-spec/src/rpc.ts b/packages/rpc-spec/src/rpc.ts index dec275b7f66..c94667009b1 100644 --- a/packages/rpc-spec/src/rpc.ts +++ b/packages/rpc-spec/src/rpc.ts @@ -3,7 +3,7 @@ import { createRpcMessage, Flatten, OverloadImplementations, - RpcResponse, + RpcResponseData, UnionToIntersection, } from '@solana/rpc-spec-types'; @@ -69,7 +69,7 @@ function createPendingRpcRequest { const { methodName, params, responseTransformer } = pendingRequest; const payload = createRpcMessage(methodName, params); - const response = await rpcConfig.transport>({ + const response = await rpcConfig.transport>({ payload, signal: options?.abortSignal, }); diff --git a/packages/rpc-subscriptions-spec/src/rpc-subscriptions.ts b/packages/rpc-subscriptions-spec/src/rpc-subscriptions.ts index 694fe0df939..4c956e65838 100644 --- a/packages/rpc-subscriptions-spec/src/rpc-subscriptions.ts +++ b/packages/rpc-subscriptions-spec/src/rpc-subscriptions.ts @@ -9,7 +9,7 @@ import { createRpcMessage, Flatten, OverloadImplementations, - RpcResponse, + RpcResponseData, UnionToIntersection, } from '@solana/rpc-spec-types'; @@ -155,7 +155,7 @@ function createPendingRpcSubscription< * STEP 2: Wait for the acknowledgement from the server with the subscription id. */ for await (const message of connection as AsyncIterable< - RpcNotification | RpcResponse + RpcNotification | RpcResponseData >) { if ('id' in message && message.id === subscribeMessage.id) { if ('error' in message) { @@ -175,7 +175,7 @@ function createPendingRpcSubscription< return { async *[Symbol.asyncIterator]() { for await (const message of connection as AsyncIterable< - RpcNotification | RpcResponse + RpcNotification | RpcResponseData >) { if (!('params' in message) || message.params.subscription !== subscriptionId) { continue;