Skip to content

Commit

Permalink
fix: 🩹 mev: blxrResponse
Browse files Browse the repository at this point in the history
Signed-off-by: thanhpp <[email protected]>
  • Loading branch information
thanhpp committed Jan 11, 2024
1 parent 32257f1 commit 0a1c340
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions pkg/mev/bloxroute_submit_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *BloxrouteClient) SendBundle(
return SendBundleResponse{}, fmt.Errorf("new http request error: %w", err)
}

resp, err := doRequest[SendBundleResponse](s.c, httpReq, [2]string{"Authorization", s.auth})
resp, err := doRequest[BLXRSubmitBundleResponse](s.c, httpReq, [2]string{"Authorization", s.auth})
if err != nil {
return SendBundleResponse{}, err
}
Expand All @@ -93,7 +93,7 @@ func (s *BloxrouteClient) SendBundle(
resp.Error.Code, resp.Error.Messange)
}

return resp, nil
return SendBundleResponse(resp), nil
}

type BLXRSubmitBundleRequest struct {
Expand Down Expand Up @@ -129,6 +129,13 @@ func (p *BLXRSubmitBundleParams) SetBlockNumber(block uint64) *BLXRSubmitBundleP
return p
}

type BLXRSubmitBundleResponse struct {
Jsonrpc string `json:"jsonrpc,omitempty"`
ID int `json:"id,string,omitempty"`
Result SendBundleResult `json:"result,omitempty"`
Error SendBundbleError `json:"error,omitempty"`
}

func bloxrouteSignFlashbot(key *ecdsa.PrivateKey, p *BLXRSubmitBundleParams) (string, error) {
param := new(SendBundleParams)
param.Txs = p.Transaction
Expand Down
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,string,omitempty"`
ID int `json:"id,omitempty"`
Result SendBundleResult `json:"result,omitempty"`
Error SendBundbleError `json:"error,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/mev/send_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestSendBundle(t *testing.T) {
func TestUnmarshal(t *testing.T) {
var (
data = "{\"id\":\"1\",\"result\":{\"bundleHash\":\"0xe0e0592348830d57fac820a6bec9fdbf0ac20a2b503351c63217cf8c274b70a8\"},\"jsonrpc\":\"2.0\"}\n" // nolint:lll
resp mev.SendBundleResponse
resp mev.BLXRSubmitBundleResponse
)

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

0 comments on commit 0a1c340

Please sign in to comment.