From 3b284786572c8818e7db7db033486491a0275128 Mon Sep 17 00:00:00 2001 From: Rohit Durvasula Date: Mon, 30 Sep 2024 15:32:03 -0700 Subject: [PATCH] Expose staking operation states --- CHANGELOG.md | 10 ++++++++++ pkg/auth/transport.go | 2 +- pkg/coinbase/staking_operation.go | 12 ++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb4c9e..884321c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pkg/auth/transport.go b/pkg/auth/transport.go index 34c7519..344edff 100644 --- a/pkg/auth/transport.go +++ b/pkg/auth/transport.go @@ -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"), ), ) diff --git a/pkg/coinbase/staking_operation.go b/pkg/coinbase/staking_operation.go index 5af4269..a2150fa 100644 --- a/pkg/coinbase/staking_operation.go +++ b/pkg/coinbase/staking_operation.go @@ -210,7 +210,7 @@ func (c *Client) Wait(ctx context.Context, stakingOperation *StakingOperation, o return err } - if stakingOperation.isTerminalState() { + if stakingOperation.IsTerminalState() { return nil } @@ -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")