Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daria305 committed Nov 21, 2023
1 parent 5628ef4 commit f4c0817
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions components/restapi/core/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func congestionByAccountAddress(c echo.Context) (*apimodels.CongestionResponse,
}

hrp := deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP()
address, err := httpserver.ParseBech32AddressParam(c, hrp, restapipkg.ParameterAddress)
address, err := httpserver.ParseBech32AddressParam(c, hrp, restapipkg.ParameterBech32Address)
if err != nil {
return nil, err
}

accountAddress, ok := address.(*iotago.AccountAddress)
if !ok {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to assert account address %s", c.Param(restapipkg.ParameterAddress))
return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(restapipkg.ParameterBech32Address))
}

accountID := accountAddress.AccountID()
Expand Down Expand Up @@ -116,14 +116,14 @@ func validators(c echo.Context) (*apimodels.ValidatorsResponse, error) {

func validatorByAccountAddress(c echo.Context) (*apimodels.ValidatorResponse, error) {
hrp := deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP()
address, err := httpserver.ParseBech32AddressQueryParam(c, hrp, restapipkg.ParameterAddress)
address, err := httpserver.ParseBech32AddressParam(c, hrp, restapipkg.ParameterBech32Address)
if err != nil {
return nil, ierrors.Wrapf(err, "failed to parse account address %s", c.Param(restapipkg.ParameterAddress))
return nil, err
}

accountAddress, ok := address.(*iotago.AccountAddress)
if !ok {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to assert account address %s", c.Param(restapipkg.ParameterAddress))
return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(restapipkg.ParameterBech32Address))
}

latestCommittedSlot := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Slot()
Expand Down
6 changes: 3 additions & 3 deletions components/restapi/core/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ const (
RouteCommitmentByIndexUTXOChanges = "/commitments/by-index/:" + restapipkg.ParameterSlotIndex + "/utxo-changes"

// RouteCongestion is the route for getting the current congestion state and all account related useful details as block issuance credits.
// GET returns the congestion state related to the specified account. (optional query parameters: "commitmentID" to specify the used commitment)
// GET returns the congestion state related to the specified account address. (optional query parameters: "commitmentID" to specify the used commitment)
// MIMEApplicationJSON => json.
// MIMEApplicationVendorIOTASerializerV2 => bytes.
RouteCongestion = "/accounts/:" + restapipkg.ParameterAddress + "/congestion"
RouteCongestion = "/accounts/:" + restapipkg.ParameterBech32Address + "/congestion"

// RouteValidators is the route for getting informations about the current validators.
// GET returns the paginated response with the list of validators.
Expand All @@ -127,7 +127,7 @@ const (
// GET returns the validator details.
// MIMEApplicationJSON => json.
// MIMEApplicationVendorIOTASerializerV2 => bytes.
RouteValidatorsAccount = "/validators/:" + restapipkg.ParameterAddress
RouteValidatorsAccount = "/validators/:" + restapipkg.ParameterBech32Address

// RouteRewards is the route for getting the rewards for staking or delegation based on staking account or delegation output.
// Rewards are decayed up to returned epochEnd index.
Expand Down
4 changes: 2 additions & 2 deletions pkg/restapi/restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const (
// ParameterCommitmentID is used to identify a slot commitment by its ID.
ParameterCommitmentID = "commitmentID"

// ParameterAddress is used to identify an account by its address.
ParameterAddress = "address"
// ParameterBech32Address is used to to represent bech32 address.
ParameterBech32Address = "bech32Address"

// ParameterPeerID is used to identify a peer.
ParameterPeerID = "peerID"
Expand Down

0 comments on commit f4c0817

Please sign in to comment.