Skip to content

Commit

Permalink
fix: 👽️ mev: fix blxr submit bundle response
Browse files Browse the repository at this point in the history
"RequestID": "cmf3bbuqatl9dhab2ie0", "error": "send bundle error: unmarshal response error: json: cannot unmarshal string into Go struct field SendBundleResponse.id of type int, data: [{\"id\":\"1\",\"result\":{\"bundleHash\":\"0xe0e0592348830d57fac820a6bec9fdbf0ac20a2b503351c63217cf8c274b70a8\"},\"jsonrpc\":\"2.0\"}
]"

Signed-off-by: thanhpp <[email protected]>
  • Loading branch information
thanhpp committed Jan 10, 2024
1 parent 66c24ee commit 9d135f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/mev/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func doRequest[T any](c *http.Client, req *http.Request, headers ...[2]string) (

type SendBundleResponse struct {
Jsonrpc string `json:"jsonrpc,omitempty"`
ID int `json:"id,omitempty"`
ID int `json:"id,string,omitempty"`
Result SendBundleResult `json:"result,omitempty"`
Error SendBundbleError `json:"error,omitempty"`
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/mev/send_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mev_test

import (
"context"
"encoding/json"
"math/big"
"net/http"
"testing"
Expand Down Expand Up @@ -61,3 +62,14 @@ func TestSendBundle(t *testing.T) {

t.Log("send bundle response", resp)
}

func TestUnmarshal(t *testing.T) {
var (
data = "{\"id\":\"1\",\"result\":{\"bundleHash\":\"0xe0e0592348830d57fac820a6bec9fdbf0ac20a2b503351c63217cf8c274b70a8\"},\"jsonrpc\":\"2.0\"}\n" // nolint:lll
resp mev.SendBundleResponse
)

require.NoError(t, json.Unmarshal([]byte(data), &resp))

t.Logf("%+v", resp)
}

0 comments on commit 9d135f2

Please sign in to comment.