Skip to content

Commit

Permalink
Apply review suggestions, make cursor string
Browse files Browse the repository at this point in the history
  • Loading branch information
daria305 committed Aug 7, 2023
1 parent 4a64c33 commit 91d81af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
11 changes: 5 additions & 6 deletions nodeclient/apimodels/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,16 @@ type (

// AccountStakingListResponse defines the response for the staking REST API call.
AccountStakingListResponse struct {
Stakers []*ValidatorResponse `serix:"0,mapKey=stakers"`
PageSize uint32 `serix:"1,mapKey=pageSize"`
Coursor uint32 `serix:"2,mapKey=coursor"`
RequestedAt iotago.SlotIndex `serix:"3,mapKey=requestedAt"`
Stakers []*ValidatorResponse `serix:"0,mapKey=stakers"`
PageSize uint32 `serix:"1,mapKey=pageSize"`
Cursor string `serix:"2,mapKey=cursor,omitempty"`
}

// ManaRewardsResponse defines the response for the mana rewards REST API call.
ManaRewardsResponse struct {
// EpochIndexStart is the starting epoch for range for which the mana rewards are returned.
// EpochIndexStart is the starting epoch for the range for which the mana rewards are returned.
EpochIndexStart iotago.EpochIndex `serix:"0,mapKey=epochIndexStart"`
// EpochIndexEnd is the ending epoch for range for which the mana rewards are returned.
// EpochIndexEnd is the ending epoch for the range for which the mana rewards are returned.
EpochIndexEnd iotago.EpochIndex `serix:"1,mapKey=epochIndexEnd"`
// The amount of totally available rewards the requested output may claim.
Rewards iotago.Mana `serix:"2,mapKey=rewards"`
Expand Down
20 changes: 10 additions & 10 deletions nodeclient/http_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ const (
// MIMEVendorIOTASerializer => bytes.
RouteCongestion = "/api/core/v3/accounts/%s/congestion"

// RouteRewards is the route for getting the rewards for staking or delegation based on provieded output.
// RouteRewards is the route for getting the rewards for staking or delegation based on the provided output.
// GET returns the rewards for the output.
// MIMEApplicationJSON => json.
// MIMEVendorIOTASerializer => bytes.
RouteRewards = "/api/core/v3/rewards/%s"

// RouteStaking is the route for getting the information about current validators.
// GET returns the information about current validators.
// RouteValidators is the route for getting the information about current registered validators.
// GET returns the paginated information about about registered validators.
// MIMEApplicationJSON => json.
// MIMEVendorIOTASerializer => bytes.
RouteStaking = "/api/core/v3/staking"
RouteValidators = "/api/core/v3/validators"

// RouteStakingAccount is the route for getting an account by its accountID.
// RouteValidatorsAccount is the route for getting validator by its accountID.
// GET returns the account details.
// MIMEApplicationJSON => json.
// MIMEVendorIOTASerializer => bytes.
RouteStakingAccount = "/api/core/v3/staking/%s"
RouteValidatorsAccount = "/api/core/v3/validators/%s"

// RouteCommittee is the route for getting the information about current committee.
// GET returns the information about current committee.
// RouteCommittee is the route for getting the information about the current committee.
// GET returns the information about the current committee.
// MIMEApplicationJSON => json.
// MIMEVendorIOTASerializer => bytes.
RouteCommittee = "/api/core/v3/committee"
Expand Down Expand Up @@ -380,7 +380,7 @@ func (client *Client) Rewards(ctx context.Context, outputID iotago.OutputID) (*a
func (client *Client) Staking(ctx context.Context) (*apimodels.AccountStakingListResponse, error) {
res := &apimodels.AccountStakingListResponse{}
//nolint:bodyclose
if _, err := client.Do(ctx, http.MethodGet, RouteStaking, nil, res); err != nil {
if _, err := client.Do(ctx, http.MethodGet, RouteValidators, nil, res); err != nil {
return nil, err
}

Expand All @@ -389,7 +389,7 @@ func (client *Client) Staking(ctx context.Context) (*apimodels.AccountStakingLis

func (client *Client) StakingAccount(ctx context.Context, accountID iotago.AccountID) (*apimodels.ValidatorResponse, error) {
res := &apimodels.ValidatorResponse{}
query := fmt.Sprintf(RouteStakingAccount, hexutil.EncodeHex(accountID[:]))
query := fmt.Sprintf(RouteValidatorsAccount, hexutil.EncodeHex(accountID[:]))
//nolint:bodyclose
if _, err := client.Do(ctx, http.MethodGet, query, nil, res); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions nodeclient/http_api_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestClient_Staking(t *testing.T) {
},
}}

mockGetJSON(nodeclient.RouteStaking, 200, originRes)
mockGetJSON(nodeclient.RouteValidators, 200, originRes)

nodeAPI := nodeClient(t)
res, err := nodeAPI.Staking(context.Background())
Expand All @@ -282,7 +282,7 @@ func TestClient_StakingByAccountID(t *testing.T) {
LatestSupportedProtocolVersion: 1,
}

mockGetJSON(fmt.Sprintf(nodeclient.RouteStakingAccount, accID.ToHex()), 200, originRes)
mockGetJSON(fmt.Sprintf(nodeclient.RouteValidatorsAccount, accID.ToHex()), 200, originRes)

nodeAPI := nodeClient(t)
res, err := nodeAPI.StakingAccount(context.Background(), accID)
Expand Down

0 comments on commit 91d81af

Please sign in to comment.