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

Expose staking operation states #40

Merged
merged 1 commit into from
Sep 30, 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# Coinbase Go SDK Changelog

## Unreleased

## [0.0.12] - 2024-09-30

### Added

- 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

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

## [0.0.11] - 2024-09-23

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.11"),
fmt.Sprintf("%s=%s", "sdk_version", "0.0.12"),
fmt.Sprintf("%s=%s", "sdk_language", "go"),
),
)
Expand Down
12 changes: 10 additions & 2 deletions pkg/coinbase/staking_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (c *Client) Wait(ctx context.Context, stakingOperation *StakingOperation, o
return err
}

if stakingOperation.isTerminalState() {
if stakingOperation.IsTerminalState() {
return nil
}

Expand Down Expand Up @@ -271,10 +271,18 @@ func (s *StakingOperation) hasTransactionByUnsignedPayload(unsignedPayload strin
return false
}

func (s *StakingOperation) isTerminalState() bool {
func (s *StakingOperation) IsTerminalState() bool {
return s.Status() == "complete" || s.Status() == "failed"
}

func (s *StakingOperation) IsFailedState() bool {
return s.Status() == "failed"
}

func (s *StakingOperation) IsCompleteState() bool {
return s.Status() == "complete"
}

func newStakingOperationFromModel(m *client.StakingOperation) (*StakingOperation, error) {
if m == nil {
return nil, fmt.Errorf("staking operation model is nil")
Expand Down