Skip to content

Commit

Permalink
Update API.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Aug 1, 2024
1 parent 73e0a0b commit b30a1ff
Show file tree
Hide file tree
Showing 32 changed files with 658 additions and 564 deletions.
14 changes: 0 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ linters-settings:
disabled: true
- name: cognitive-complexity
disabled: true
- name: confusing-naming
disabled: true
- name: confusing-results
- name: function-length
disabled: true
Expand All @@ -134,8 +132,6 @@ linters-settings:
disabled: true
- name: package-comments
disabled: true
- name: redundant-import-alias
disabled: true
- name: struct-tag
arguments: ["json,allowempty"]
- name: unhandled-error
Expand All @@ -161,12 +157,10 @@ linters:
# https://golangci-lint.run/usage/linters/#disabled-by-default
disable:
- cyclop
- deadcode
- depguard
- dupl
- execinquery
- exhaustive
- exhaustivestruct
- exhaustruct
- forcetypeassert
- funlen
Expand All @@ -176,21 +170,13 @@ linters:
- gocognit
- goconst
- err113
- golint
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- maintidx
- maligned
- mnd
- musttag
- nosnakecase
- perfsprint
- scopelint
- structcheck
- varcheck
- varnamelen
- wrapcheck
- wsl
8 changes: 4 additions & 4 deletions api/bellatrix/submitblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
Expand All @@ -16,21 +16,21 @@ import (

// SubmitBlockRequest is the request from the builder to submit a block.
type SubmitBlockRequest struct {
Message *v1.BidTrace
Message *apiv1.BidTrace
ExecutionPayload *bellatrix.ExecutionPayload
Signature phase0.BLSSignature `ssz-size:"96"`
}

// submitBlockRequestJSON is the spec representation of the struct.
type submitBlockRequestJSON struct {
Message *v1.BidTrace `json:"message"`
Message *apiv1.BidTrace `json:"message"`
ExecutionPayload *bellatrix.ExecutionPayload `json:"execution_payload"`
Signature string `json:"signature"`
}

// submitBlockRequestYAML is the spec representation of the struct.
type submitBlockRequestYAML struct {
Message *v1.BidTrace `yaml:"message"`
Message *apiv1.BidTrace `yaml:"message"`
ExecutionPayload *bellatrix.ExecutionPayload `yaml:"execution_payload"`
Signature string `yaml:"signature"`
}
Expand Down
28 changes: 28 additions & 0 deletions api/builderbidopts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

import "github.com/attestantio/go-eth2-client/spec/phase0"

// BuilderBidOpts are the options for obtaining builder bids.
type BuilderBidOpts struct {
Common CommonOpts

// Slot is the slot for which to obtain a builder bid.
Slot phase0.Slot
// ParentHash is the hash of the parent execution payload.
ParentHash phase0.Hash32
// PubKey is the public key of the ?
PubKey phase0.BLSPubKey
}
4 changes: 2 additions & 2 deletions api/capella/submitblockrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package capella
import (
"fmt"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
)

// SubmitBlockRequest is the request from the builder to submit a block.
type SubmitBlockRequest struct {
Message *v1.BidTrace
Message *apiv1.BidTrace
ExecutionPayload *capella.ExecutionPayload
Signature phase0.BLSSignature `ssz-size:"96"`
}
Expand Down
4 changes: 2 additions & 2 deletions api/capella/submitblockrequest_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"fmt"
"strings"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)

// submitBlockRequestJSON is the spec representation of the struct.
type submitBlockRequestJSON struct {
Message *v1.BidTrace `json:"message"`
Message *apiv1.BidTrace `json:"message"`
ExecutionPayload *capella.ExecutionPayload `json:"execution_payload"`
Signature string `json:"signature"`
}
Expand Down
4 changes: 2 additions & 2 deletions api/capella/submitblockrequest_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"bytes"
"fmt"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/goccy/go-yaml"
)

// submitBlockRequestYAML is the spec representation of the struct.
type submitBlockRequestYAML struct {
Message *v1.BidTrace `yaml:"message"`
Message *apiv1.BidTrace `yaml:"message"`
ExecutionPayload *capella.ExecutionPayload `yaml:"execution_payload"`
Signature string `yaml:"signature"`
}
Expand Down
23 changes: 23 additions & 0 deletions api/commonopts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

import "time"

// CommonOpts are options common for all calls.
type CommonOpts struct {
// Timeout is a specific timeout for this call.
// If 0 then the default timeout is used.
Timeout time.Duration
}
4 changes: 2 additions & 2 deletions api/deneb/submitblockrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package deneb
import (
"fmt"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
)

// SubmitBlockRequest is the request from the builder to submit a block.
type SubmitBlockRequest struct {
Message *v1.BidTrace
Message *apiv1.BidTrace
ExecutionPayload *deneb.ExecutionPayload
BlobsBundle *BlobsBundle
Signature phase0.BLSSignature `ssz-size:"96"`
Expand Down
4 changes: 2 additions & 2 deletions api/deneb/submitblockrequest_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"fmt"
"strings"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)

// submitBlockRequestJSON is the spec representation of the struct.
type submitBlockRequestJSON struct {
Message *v1.BidTrace `json:"message"`
Message *apiv1.BidTrace `json:"message"`
ExecutionPayload *deneb.ExecutionPayload `json:"execution_payload"`
BlobsBundle *BlobsBundle `json:"blobs_bundle"`
Signature string `json:"signature"`
Expand Down
8 changes: 4 additions & 4 deletions api/deneb/submitblockrequest_ssz.go

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

4 changes: 2 additions & 2 deletions api/deneb/submitblockrequest_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"bytes"
"fmt"

v1 "github.com/attestantio/go-builder-client/api/v1"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/goccy/go-yaml"
)

// submitBlockRequestYAML is the spec representation of the struct.
type submitBlockRequestYAML struct {
Message *v1.BidTrace `yaml:"message"`
Message *apiv1.BidTrace `yaml:"message"`
ExecutionPayload *deneb.ExecutionPayload `yaml:"execution_payload"`
BlobsBundle *BlobsBundle `yaml:"blobs_bundle"`
Signature string `yaml:"signature"`
Expand Down
34 changes: 34 additions & 0 deletions api/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

import (
"fmt"
)

// Error represents an API error.
type Error struct {
Method string
Endpoint string
StatusCode int
Data []byte
}

func (e Error) Error() string {
if len(e.Data) > 0 {
return fmt.Sprintf("%s failed with status %d: %s", e.Method, e.StatusCode, string(e.Data))
}

return fmt.Sprintf("%s failed with status %d", e.Method, e.StatusCode)
}
20 changes: 20 additions & 0 deletions api/response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

// Response is a response from the beacon API which may contain metadata.
type Response[T any] struct {
Data T
Metadata map[string]any
}
22 changes: 22 additions & 0 deletions api/submitvalidatorregistrationsopts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

// SubmitValidatorRegistrationsOpts are the options for submitting validator registrations.
type SubmitValidatorRegistrationsOpts struct {
Common CommonOpts

// Registrations are the validator registrations.
Registrations []*VersionedSignedValidatorRegistration
}
26 changes: 26 additions & 0 deletions api/unblindproposalopts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

import (
consensusapi "github.com/attestantio/go-eth2-client/api"
)

// UnblindProposalOpts are the options for unblinding proposals.
type UnblindProposalOpts struct {
Common CommonOpts

// Proposal is the porposal to unblind.
Proposal *consensusapi.VersionedSignedBlindedProposal
}
Loading

0 comments on commit b30a1ff

Please sign in to comment.