Skip to content

Commit

Permalink
remove params from jsonrpc post payload if empty, rpc requires it (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Apr 26, 2023
1 parent cc796e5 commit a52897f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export async function post<T>(
method: string,
...params: any
): Promise<T> {
if (params && params.length < 1) {
params = null;
}
const response = await axios.post<Response<T>>(url, {
jsonrpc: "2.0",
// TODO: Generate a unique request id
Expand Down
2 changes: 1 addition & 1 deletion test/unit/server/get_health_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Server#getHealth", function() {
jsonrpc: "2.0",
id: 1,
method: "getHealth",
params: [],
params: null,
})
.returns(Promise.resolve({ data: { result } }));

Expand Down
2 changes: 1 addition & 1 deletion test/unit/server/get_latest_ledger_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Server#getLatestLedger", function() {
jsonrpc: "2.0",
id: 1,
method: "getLatestLedger",
params: [],
params: null,
})
.returns(Promise.resolve({ data: { result } }));

Expand Down
2 changes: 1 addition & 1 deletion test/unit/server/get_network_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Server#getNetwork", function() {
jsonrpc: "2.0",
id: 1,
method: "getNetwork",
params: [],
params: null,
})
.returns(Promise.resolve({ data: { result } }));

Expand Down
2 changes: 1 addition & 1 deletion test/unit/server/request_airdrop_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("Server#requestAirdrop", function() {
jsonrpc: "2.0",
id: 1,
method: "getNetwork",
params: [],
params: null,
})
.returns(Promise.resolve({ data: { result } }));
}
Expand Down

0 comments on commit a52897f

Please sign in to comment.