-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RpcRequest in createRpcMessage helper
- Loading branch information
1 parent
f1cee41
commit d064590
Showing
6 changed files
with
32 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@solana/rpc-subscriptions-spec': patch | ||
'@solana/rpc-spec-types': patch | ||
'@solana/rpc-spec': patch | ||
--- | ||
|
||
Use RpcRequest in createRpcMessage helper |
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,15 +1,17 @@ | ||
import { RpcRequest } from './rpc-request'; | ||
|
||
let _nextMessageId = 0; | ||
function getNextMessageId() { | ||
const id = _nextMessageId; | ||
_nextMessageId = (_nextMessageId + 1) % Number.MAX_SAFE_INTEGER; | ||
return id; | ||
} | ||
|
||
export function createRpcMessage<TParams>(method: string, params: TParams) { | ||
export function createRpcMessage<TParams>(request: RpcRequest<TParams>) { | ||
return { | ||
id: getNextMessageId(), | ||
jsonrpc: '2.0', | ||
method, | ||
params, | ||
method: request.methodName, | ||
params: request.params, | ||
}; | ||
} |
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