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

Json methods for ExchangeCapabilities #14523

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Updated Sepolia bootnodes.
- Make committee aware packing the default by deprecating `--enable-committee-aware-packing`.
- Moved `ConvertKzgCommitmentToVersionedHash` to the `primitives` package.
- Fix `engine_exchangeCapabilities` implementation.

### Deprecated
- `--disable-grpc-gateway` flag is deprecated due to grpc gateway removal.
Expand Down
31 changes: 31 additions & 0 deletions proto/engine/v1/json_marshal_unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,34 @@ func RecastHexutilByteSlice(h []hexutil.Bytes) [][]byte {
}
return r
}

type ExchangeCapabilitiesJSON struct {
SupportedMethods []string `json:"supported_methods"`
}

func (b *ExchangeCapabilities) MarshalJSON() ([]byte, error) {
supportedMethods := make([]string, len(b.SupportedMethods))
for i, sm := range b.SupportedMethods {
supportedMethods[i] = sm
}
return json.Marshal(ExchangeCapabilitiesJSON{
SupportedMethods: supportedMethods,
})
}

func (b *ExchangeCapabilities) UnmarshalJSON(enc []byte) error {
var decoded *ExchangeCapabilitiesJSON
err := json.Unmarshal(enc, &decoded)
if err != nil {
return err
}
if len(decoded.SupportedMethods) == 0 {
b.SupportedMethods = make([]string, 0)
}
supportedMethods := make([]string, len(decoded.SupportedMethods))
for i, sm := range decoded.SupportedMethods {
supportedMethods[i] = sm
}
b.SupportedMethods = supportedMethods
return nil
}
Loading