-
Notifications
You must be signed in to change notification settings - Fork 911
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
RpcResponse
provide the resopnse payload directly
- Loading branch information
1 parent
e36ee23
commit 50e9859
Showing
14 changed files
with
41 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { createJsonRpcResponseTransformer } from '@solana/rpc-spec'; | ||
import { RpcResponseTransformer } from '@solana/rpc-spec'; | ||
|
||
type JsonRpcResponse = { result: unknown }; | ||
|
||
export function getResultResponseTransformer() { | ||
return createJsonRpcResponseTransformer(json => (json as JsonRpcResponse).result); | ||
export function getResultResponseTransformer(): RpcResponseTransformer { | ||
return json => (json as JsonRpcResponse).result; | ||
} |
8 changes: 4 additions & 4 deletions
8
packages/rpc-transformers/src/response-transformer-throw-solana-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { getSolanaErrorFromJsonRpcError } from '@solana/errors'; | ||
import { createJsonRpcResponseTransformer } from '@solana/rpc-spec'; | ||
import { RpcResponseTransformer } from '@solana/rpc-spec'; | ||
|
||
type JsonRpcResponse = { error: Parameters<typeof getSolanaErrorFromJsonRpcError>[0] } | { result: unknown }; | ||
|
||
export function getThrowSolanaErrorResponseTransformer() { | ||
return createJsonRpcResponseTransformer(json => { | ||
export function getThrowSolanaErrorResponseTransformer(): RpcResponseTransformer { | ||
return json => { | ||
const jsonRpcResponse = json as JsonRpcResponse; | ||
if ('error' in jsonRpcResponse) { | ||
throw getSolanaErrorFromJsonRpcError(jsonRpcResponse.error); | ||
} | ||
return jsonRpcResponse; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.