From 0a1c340266fffe804fce978b577fc3fa7cdd814a Mon Sep 17 00:00:00 2001 From: thanhpp Date: Thu, 11 Jan 2024 10:44:24 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=A9=B9=20mev:=20blxrResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: thanhpp --- pkg/mev/bloxroute_submit_bundle.go | 11 +++++++++-- pkg/mev/pkg.go | 2 +- pkg/mev/send_bundle_test.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/mev/bloxroute_submit_bundle.go b/pkg/mev/bloxroute_submit_bundle.go index 68ff816..204074e 100644 --- a/pkg/mev/bloxroute_submit_bundle.go +++ b/pkg/mev/bloxroute_submit_bundle.go @@ -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 } @@ -93,7 +93,7 @@ func (s *BloxrouteClient) SendBundle( resp.Error.Code, resp.Error.Messange) } - return resp, nil + return SendBundleResponse(resp), nil } type BLXRSubmitBundleRequest struct { @@ -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 diff --git a/pkg/mev/pkg.go b/pkg/mev/pkg.go index 1ea629f..8b42f2e 100644 --- a/pkg/mev/pkg.go +++ b/pkg/mev/pkg.go @@ -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"` } diff --git a/pkg/mev/send_bundle_test.go b/pkg/mev/send_bundle_test.go index 5f1d05a..bbc0ce9 100644 --- a/pkg/mev/send_bundle_test.go +++ b/pkg/mev/send_bundle_test.go @@ -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))