Skip to content

Commit e22e893

Browse files
authored
Merge pull request #7 from coinbase/main-1701903076
v0.2.0 Release
2 parents 30761b2 + 1201cc4 commit e22e893

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2357
-2400
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
vendor/
2626

2727
# Cloud API key
28-
.coinbase_cloud_api_key_*.json
28+
.coinbase_cloud_api_key*.json
2929

3030
# Example binary
3131
staking-client-*

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,25 @@ To test that your API Key gives you access as expected to the Staking APIs:
4646
### Create an Ethereum Kiln workflow
4747
To test creating an Ethereum Kiln workflow perform the following:
4848
49-
1. Run `go run examples/ethereum_kiln/example.go`
50-
2. To proceed with the entire example.go, you will need to set the following variables in the example.go file and run the code again:
49+
1. Open `examples/ethereum_kiln/example.go` and set the following variables:
5150
* `projectID` - this is the project ID of your Coinbase Cloud project
5251
* `privateKey` - this is the private key of the address with this you want to perform staking actions
5352
* `stakerAddress` - this is the address with which you want to perform staking actions
53+
* `integratorContractAddress` - this is the integrator contract address to which you want to stake. This is typically procured by engaging with the Coinbase Cloud sales team.
54+
2. Run `go run examples/ethereum_kiln/example.go`
5455
5556
### Create a Polygon workflow
5657
To test creating a Polygon workflow perform the following:
5758
58-
1. Run `go run examples/polygon/example.go`
59-
2. To proceed with the entire example.go, you will need to set the following variables in the example.go file and run the code again:
59+
1. Open `examples/polygon/example.go` and set the following variables:
6060
* `projectID` - this is the project ID of your Coinbase Cloud project
6161
* `privateKey` - this is the private key of the address with this you want to perform staking actions
6262
* `delegatorAddress` - this is the address with which you want to perform staking actions
63+
2. Run `go run examples/polygon/example.go`
64+
65+
### Listing workflows
66+
To test listing workflows within a project, perform the following:
67+
68+
1. Open `examples/example_list_workflows.go` and set the following variables:
69+
* `projectID` - this is the project ID of your Coinbase Cloud project
70+
2. Run `go run examples/example_list_workflows.go`

client/v1alpha1/create_workflow.go

-27
This file was deleted.

client/v1alpha1/get_workflow.go

-27
This file was deleted.

client/v1alpha1/perform_workflow_step.go

-27
This file was deleted.

client/v1alpha1/refresh_workflow_step.go

-27
This file was deleted.

client/v1alpha1/validator.go client/v1alpha1/staking_target.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,61 @@ import (
1313
stakingpb "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/v1alpha1"
1414
)
1515

16-
// ValidatorIterator is an interface for iterating through the response to ListValidators.
17-
type ValidatorIterator interface {
16+
// StakingTargetIterator is an interface for iterating through the response to ListStakingTargets.
17+
type StakingTargetIterator interface {
1818
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1919
PageInfo() *iterator.PageInfo
2020

2121
// Next returns the next result. Its second return value is iterator.Done if there are no more
2222
// results. Once Next returns Done, all subsequent calls will return Done.
23-
Next() (*stakingpb.Validator, error)
23+
Next() (*stakingpb.StakingTarget, error)
2424

2525
// Response is the raw response for the current page.
2626
// Calling Next() or InternalFetch() updates this value.
27-
Response() *stakingpb.ListValidatorsResponse
27+
Response() *stakingpb.ListStakingTargetsResponse
2828
}
2929

30-
// ValidatorIteratorImpl is an implementation of ValidatorIterator that unwraps correctly.
31-
type ValidatorIteratorImpl struct {
32-
iter *innerClient.ValidatorIterator
30+
// StakingTargetIteratorImpl is an implementation of StakingTargetIterator that unwraps correctly.
31+
type StakingTargetIteratorImpl struct {
32+
iter *innerClient.StakingTargetIterator
3333
}
3434

3535
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
36-
func (n *ValidatorIteratorImpl) PageInfo() *iterator.PageInfo {
36+
func (n *StakingTargetIteratorImpl) PageInfo() *iterator.PageInfo {
3737
return n.iter.PageInfo()
3838
}
3939

4040
// Next returns the next result. Its second return value is iterator.Done if there are no more
4141
// results. Once Next returns Done, all subsequent calls will return Done.
42-
func (n *ValidatorIteratorImpl) Next() (*stakingpb.Validator, error) {
43-
validator, err := n.iter.Next()
42+
func (n *StakingTargetIteratorImpl) Next() (*stakingpb.StakingTarget, error) {
43+
stakingTarget, err := n.iter.Next()
4444
if errors.Is(err, iterator.Done) || err == nil {
45-
return validator, err
45+
return stakingTarget, err
4646
}
4747

48-
return validator, stakingerrors.FromError(err)
48+
return stakingTarget, stakingerrors.FromError(err)
4949
}
5050

5151
// Response is the raw response for the current page.
5252
// Calling Next() or InternalFetch() updates this value.
53-
func (n *ValidatorIteratorImpl) Response() *stakingpb.ListValidatorsResponse {
53+
func (n *StakingTargetIteratorImpl) Response() *stakingpb.ListStakingTargetsResponse {
5454
if n.iter.Response == nil {
5555
return nil
5656
}
5757

58-
response, ok := n.iter.Response.(*stakingpb.ListValidatorsResponse)
58+
response, ok := n.iter.Response.(*stakingpb.ListStakingTargetsResponse)
5959
if !ok {
6060
return nil
6161
}
6262

6363
return response
6464
}
6565

66-
// ListValidators lists the Validators supported by Staking API.
67-
func (s *StakingServiceClient) ListValidators(
66+
// ListStakingTargets lists the StakingTargets supported by Staking API.
67+
func (s *StakingServiceClient) ListStakingTargets(
6868
ctx context.Context,
69-
req *stakingpb.ListValidatorsRequest,
69+
req *stakingpb.ListStakingTargetsRequest,
7070
opts ...gax.CallOption,
71-
) ValidatorIterator {
72-
return &ValidatorIteratorImpl{iter: s.client.ListValidators(ctx, req, opts...)}
71+
) StakingTargetIterator {
72+
return &StakingTargetIteratorImpl{iter: s.client.ListStakingTargets(ctx, req, opts...)}
7373
}

client/v1alpha1/workflow.go

+63
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package v1alpha1
22

33
import (
44
"context"
5+
"errors"
56

67
"github.com/googleapis/gax-go/v2"
78

9+
"google.golang.org/api/iterator"
10+
811
stakingerrors "github.com/coinbase/staking-client-library-go/client/errors"
12+
innerClient "github.com/coinbase/staking-client-library-go/gen/client/coinbase/staking/v1alpha1"
913
stakingpb "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/v1alpha1"
1014
)
1115

@@ -43,6 +47,65 @@ func (s *StakingServiceClient) GetWorkflow(
4347
return wf, sae
4448
}
4549

50+
// WorkflowIterator is an interface for iterating through the response to ListWorkflows.
51+
type WorkflowIterator interface {
52+
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
53+
PageInfo() *iterator.PageInfo
54+
55+
// Next returns the next result. Its second return value is iterator.Done if there are no more
56+
// results. Once Next returns Done, all subsequent calls will return Done.
57+
Next() (*stakingpb.Workflow, error)
58+
59+
// Response is the raw response for the current page.
60+
// Calling Next() or InternalFetch() updates this value.
61+
Response() *stakingpb.ListWorkflowsResponse
62+
}
63+
64+
// WorkflowIteratorImpl is an implementation of WorkflowIterator that unwraps correctly.
65+
type WorkflowIteratorImpl struct {
66+
iter *innerClient.WorkflowIterator
67+
}
68+
69+
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
70+
func (n *WorkflowIteratorImpl) PageInfo() *iterator.PageInfo {
71+
return n.iter.PageInfo()
72+
}
73+
74+
// Next returns the next result. Its second return value is iterator.Done if there are no more
75+
// results. Once Next returns Done, all subsequent calls will return Done.
76+
func (n *WorkflowIteratorImpl) Next() (*stakingpb.Workflow, error) {
77+
workflow, err := n.iter.Next()
78+
if errors.Is(err, iterator.Done) || err == nil {
79+
return workflow, err
80+
}
81+
82+
return workflow, stakingerrors.FromError(err)
83+
}
84+
85+
// Response is the raw response for the current page.
86+
// Calling Next() or InternalFetch() updates this value.
87+
func (n *WorkflowIteratorImpl) Response() *stakingpb.ListWorkflowsResponse {
88+
if n.iter.Response == nil {
89+
return nil
90+
}
91+
92+
response, ok := n.iter.Response.(*stakingpb.ListWorkflowsResponse)
93+
if !ok {
94+
return nil
95+
}
96+
97+
return response
98+
}
99+
100+
// ListWorkflows lists the Workflows supported by Staking API.
101+
func (s *StakingServiceClient) ListWorkflows(
102+
ctx context.Context,
103+
req *stakingpb.ListWorkflowsRequest,
104+
opts ...gax.CallOption,
105+
) WorkflowIterator {
106+
return &WorkflowIteratorImpl{iter: s.client.ListWorkflows(ctx, req, opts...)}
107+
}
108+
46109
// PerformWorkflowStep helps update workflow move to the next state by returning the signed tx back.
47110
func (s *StakingServiceClient) PerformWorkflowStep(
48111
ctx context.Context,

0 commit comments

Comments
 (0)