Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-wombats-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/proxyd': minor
---

Fixed JSON-RPC 2.0 specification compliance by adding the optional data field on an RPCError
1 change: 1 addition & 0 deletions proxyd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (r *RPCRes) MarshalJSON() ([]byte, error) {
type RPCErr struct {
Code int `json:"code"`
Message string `json:"message"`
Data string `json:"data,omitempty"`
HTTPErrorCode int `json:"-"`
}

Expand Down
15 changes: 14 additions & 1 deletion proxyd/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestRPCResJSON(t *testing.T) {
`{"jsonrpc":"2.0","result":null,"id":123}`,
},
{
"error result",
"error result without data",
&RPCRes{
JSONRPC: JSONRPCVersion,
Error: &RPCErr{
Expand All @@ -56,6 +56,19 @@ func TestRPCResJSON(t *testing.T) {
},
`{"jsonrpc":"2.0","error":{"code":1234,"message":"test err"},"id":123}`,
},
{
"error result with data",
&RPCRes{
JSONRPC: JSONRPCVersion,
Error: &RPCErr{
Code: 1234,
Message: "test err",
Data: "revert",
},
ID: []byte("123"),
},
`{"jsonrpc":"2.0","error":{"code":1234,"message":"test err","data":"revert"},"id":123}`,
},
{
"string ID",
&RPCRes{
Expand Down