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

Better error handling between SDK and API #45

Merged
merged 1 commit into from
Dec 2, 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
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## [0.0.15] - 2024-12-02

### Added

- Add `WithIntegratorContractAddress` to allow for setting an explicit integrator contract address for Shared ETH staking.

### Fixed

- Better error handling between the SDK and the API.

## [0.0.14] - 2024-11-26

### Added
Expand All @@ -21,7 +31,7 @@
- Added constants for supported network names
- Added `IsFailedState` and `IsCompleteState` methods to `StakingOperation` to check if the operation is in a failed or complete state

### Changes
### Changed

- Exposed `IsTerminalState` method on `StakingOperation` to check if the operation is in a terminal state.

Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
"Correlation-Context",
fmt.Sprintf(
"%s,%s",
fmt.Sprintf("%s=%s", "sdk_version", "0.0.14"),
fmt.Sprintf("%s=%s", "sdk_version", "0.0.15"),
fmt.Sprintf("%s=%s", "sdk_language", "go"),
),
)
Expand Down
5 changes: 5 additions & 0 deletions pkg/coinbase/staking_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func WithStakingOperationMode(mode string) StakingOperationOption {
return WithStakingOperationOption("mode", mode)
}

// WithIntegratorContractAddress allows for the setting of the integrator contract address for Shared ETH staking.
func WithIntegratorContractAddress(integratorContractAddress string) StakingOperationOption {
return WithStakingOperationOption("integrator_contract_address", integratorContractAddress)
}

// WithStakingOperationOption allows for the passing of custom options
// to the staking operation, like `mode` or `withdrawal_address`.
func WithStakingOperationOption(optionKey, optionValue string) StakingOperationOption {
Expand Down
4 changes: 2 additions & 2 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func MapToUserFacing(err error, resp *http.Response) error {
var openAPIError *client.GenericOpenAPIError
if errors.As(err, &openAPIError) {
var clientError client.Error
if err := clientError.UnmarshalJSON(openAPIError.Body()); err != nil {
if unmarshalErr := clientError.UnmarshalJSON(openAPIError.Body()); unmarshalErr != nil {
return &APIError{
Code: "unknown",
Message: err.Error(),
Message: err.Error(), // relay back the original error message as is.
}
}

Expand Down
Loading