Skip to content

Commit

Permalink
Add GET endpoints for stake and locked stake entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazy Nina authored and lazynina committed Jan 23, 2024
1 parent 961e5a8 commit 87ea138
Show file tree
Hide file tree
Showing 3 changed files with 331 additions and 21 deletions.
1 change: 1 addition & 0 deletions routes/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package routes
30 changes: 30 additions & 0 deletions routes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ const (
RoutePathStake = "/api/v0/stake"
RoutePathUnstake = "/api/v0/unstake"
RoutePathUnlockStake = "/api/v0/unlock-stake"
RoutePathLockedStake = "/api/v0/locked-stake"
)

// APIServer provides the interface between the blockchain and things like the
Expand Down Expand Up @@ -1330,6 +1331,29 @@ func (fes *APIServer) NewRouter() *muxtrace.Router {
fes.CreateUnlockStakeTxn,
PublicAccess,
},
{
"GetStakeForValidatorAndStaker",
[]string{"GET"},
RoutePathStake + "/" + makePublicKeyParamRegex("validatorPublicKeyBase58Check") + "/" +
makePublicKeyParamRegex("stakerPublicKeyBase58Check"),
fes.GetStakeForValidatorAndStaker,
PublicAccess,
},
{
"GetStakesForValidator",
[]string{"GET"},
RoutePathStake + "/validator/" + makePublicKeyParamRegex("validatorPublicKeyBase58Check"),
fes.GetStakesForValidator,
PublicAccess,
},
{
"GetLockedStakeForValidatorAndStaker",
[]string{"GET"},
RoutePathLockedStake + "/" + makePublicKeyParamRegex("validatorPublicKeyBase58Check") + "/" +
makePublicKeyParamRegex("stakerPublicKeyBase58Check"),
fes.GetLockedStakesForValidatorAndStaker,
PublicAccess,
},
// Jumio Routes
{
"JumioBegin",
Expand Down Expand Up @@ -2842,3 +2866,9 @@ func (fes *APIServer) makePKIDMapJSONEncodable(restrictedKeysMap map[lib.PKID][]
}
return outputMap
}

const publicKeyParamRegex = "t?BC[1-9A-HJ-NP-Za-km-z]{51,53}"

func makePublicKeyParamRegex(paramName string) string {
return fmt.Sprintf("{%s:%s}", paramName, publicKeyParamRegex)
}
Loading

0 comments on commit 87ea138

Please sign in to comment.