Skip to content

Commit

Permalink
Expose staking operation states
Browse files Browse the repository at this point in the history
  • Loading branch information
drohit-cb committed Sep 30, 2024
1 parent 9fde58d commit 3b28478
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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

0 comments on commit 3b28478

Please sign in to comment.