Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🩹 mev: blxrResponse #19

Merged
merged 1 commit into from
Jan 11, 2024
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
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
Loading