Skip to content

Commit

Permalink
rename properties in electra.ExecutionRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Oct 4, 2024
1 parent c40caeb commit f6f8068
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion spec/electra/consolidationrequest_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (e *ConsolidationRequest) MarshalYAML() ([]byte, error) {
func (e *ConsolidationRequest) UnmarshalYAML(input []byte) error {
// This is very inefficient, but YAML is only used for spec tests so we do this
// rather than maintain a custom YAML unmarshaller.
var unmarshaled consolidationRequestYAML
var unmarshaled consolidationRequestJSON
if err := yaml.Unmarshal(input, &unmarshaled); err != nil {
return errors.Wrap(err, "failed to unmarshal YAML")
}
Expand Down
6 changes: 3 additions & 3 deletions spec/electra/executionrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (

// ExecutionRequests represents an execution layer payload.
type ExecutionRequests struct {
DepositRequests []*DepositRequest `ssz-max:"8192"`
WithdrawalRequests []*WithdrawalRequest `ssz-max:"16"`
ConsolidationRequests []*ConsolidationRequest `ssz-max:"1"`
Deposits []*DepositRequest `ssz-max:"8192"`
Withdrawals []*WithdrawalRequest `ssz-max:"16"`
Consolidations []*ConsolidationRequest `ssz-max:"1"`
}

// String returns a string version of the structure.
Expand Down
40 changes: 20 additions & 20 deletions spec/electra/executionrequests_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import (

// executionRequestsJSON is the spec representation of the struct.
type executionRequestsJSON struct {
DepositRequests []*DepositRequest `json:"deposit_requests"`
WithdrawalRequests []*WithdrawalRequest `json:"withdrawal_requests"`
ConsolidationRequests []*ConsolidationRequest `json:"consolidation_requests"`
Deposits []*DepositRequest `json:"deposits"`
Withdrawals []*WithdrawalRequest `json:"withdrawals"`
Consolidations []*ConsolidationRequest `json:"consolidations"`
}

// MarshalJSON implements json.Marshaler.
func (e *ExecutionRequests) MarshalJSON() ([]byte, error) {
return json.Marshal(&executionRequestsJSON{
DepositRequests: e.DepositRequests,
WithdrawalRequests: e.WithdrawalRequests,
ConsolidationRequests: e.ConsolidationRequests,
Deposits: e.Deposits,
Withdrawals: e.Withdrawals,
Consolidations: e.Consolidations,
})
}

Expand All @@ -44,29 +44,29 @@ func (e *ExecutionRequests) UnmarshalJSON(input []byte) error {
return err
}

if err := json.Unmarshal(raw["deposit_requests"], &e.DepositRequests); err != nil {
return errors.Wrap(err, "deposit_requests")
if err := json.Unmarshal(raw["deposits"], &e.Deposits); err != nil {
return errors.Wrap(err, "deposits")
}
for i := range e.DepositRequests {
if e.DepositRequests[i] == nil {
return fmt.Errorf("deposit receipts entry %d missing", i)
for i := range e.Deposits {
if e.Deposits[i] == nil {
return fmt.Errorf("deposits entry %d missing", i)
}
}

if err := json.Unmarshal(raw["withdrawal_requests"], &e.WithdrawalRequests); err != nil {
return errors.Wrap(err, "withdrawal_requests")
if err := json.Unmarshal(raw["withdrawals"], &e.Withdrawals); err != nil {
return errors.Wrap(err, "withdrawals")
}
for i := range e.WithdrawalRequests {
if e.WithdrawalRequests[i] == nil {
return fmt.Errorf("withdraw requests entry %d missing", i)
for i := range e.Withdrawals {
if e.Withdrawals[i] == nil {
return fmt.Errorf("withdrawals entry %d missing", i)
}
}

if err := json.Unmarshal(raw["consolidation_requests"], &e.ConsolidationRequests); err != nil {
return errors.Wrap(err, "consolidation_requests")
if err := json.Unmarshal(raw["consolidations"], &e.Consolidations); err != nil {
return errors.Wrap(err, "consolidations")
}
for i := range e.ConsolidationRequests {
if e.ConsolidationRequests[i] == nil {
for i := range e.Consolidations {
if e.Consolidations[i] == nil {
return fmt.Errorf("consolidation requests entry %d missing", i)
}
}
Expand Down
66 changes: 33 additions & 33 deletions spec/electra/executionrequests_ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions spec/electra/executionrequests_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import (

// executionRequestsYAML is the spec representation of the struct.
type executionRequestsYAML struct {
DepositRequests []*DepositRequest `yaml:"deposit_requests"`
WithdrawalRequests []*WithdrawalRequest `yaml:"withdrawal_requests"`
ConsolidationRequests []*ConsolidationRequest `yaml:"consolidation_requests"`
Deposits []*DepositRequest `yaml:"deposits"`
Withdrawals []*WithdrawalRequest `yaml:"withdrawals"`
Consolidations []*ConsolidationRequest `yaml:"consolidations"`
}

// MarshalYAML implements yaml.Marshaler.
func (e *ExecutionRequests) MarshalYAML() ([]byte, error) {
yamlBytes, err := yaml.MarshalWithOptions(&executionRequestsYAML{
DepositRequests: e.DepositRequests,
WithdrawalRequests: e.WithdrawalRequests,
ConsolidationRequests: e.ConsolidationRequests,
Deposits: e.Deposits,
Withdrawals: e.Withdrawals,
Consolidations: e.Consolidations,
}, yaml.Flow(true))
if err != nil {
return nil, err
Expand Down

0 comments on commit f6f8068

Please sign in to comment.