Skip to content

Commit

Permalink
add delegation by tx hash endpoint (#104)
Browse files Browse the repository at this point in the history
* add delegation by tx hash endpoint

* resolve comments
  • Loading branch information
jeremy-babylonlabs authored Nov 14, 2024
1 parent a839cdd commit 4109d25
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 192 deletions.
114 changes: 80 additions & 34 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,39 +399,30 @@ const docTemplate = `{
}
}
},
"/v2/finality-providers": {
"/v2/delegation": {
"get": {
"description": "Fetches finality providers with optional filtering and pagination",
"description": "Retrieves a delegation by a given transaction hash",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "List Finality Providers",
"summary": "Get a delegation",
"parameters": [
{
"type": "string",
"description": "Pagination key to fetch the next page",
"name": "pagination_key",
"in": "query"
},
{
"enum": [
"active",
"standby"
],
"type": "string",
"description": "Filter by state",
"name": "state",
"in": "query"
"description": "Staking transaction hash in hex format",
"name": "staking_tx_hash_hex",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "List of finality providers and pagination token",
"description": "Staker delegation",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-array_v2service_FinalityProviderPublic"
"$ref": "#/definitions/handler.PublicResponse-v2service_StakerDelegationPublic"
}
},
"400": {
Expand All @@ -443,56 +434,80 @@ const docTemplate = `{
}
}
},
"/v2/global-params": {
"/v2/delegations": {
"get": {
"description": "Fetches global parameters for babylon chain and BTC chain",
"description": "Fetches delegations for babylon staking including tvl, total delegations, active tvl, active delegations and total stakers.",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Global Parameters",
"summary": "Get Delegations",
"parameters": [
{
"type": "string",
"description": "Staker public key in hex format",
"name": "staker_pk_hex",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Pagination key to fetch the next page of delegations",
"name": "pagination_key",
"in": "query"
}
],
"responses": {
"200": {
"description": "Global parameters",
"description": "List of staker delegations and pagination token",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-v2service_GlobalParamsPublic"
"$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic"
}
},
"400": {
"description": "Error: Bad Request",
"schema": {
"$ref": "#/definitions/github_com_babylonlabs-io_staking-api-service_internal_shared_types.Error"
}
}
}
}
},
"/v2/staker/delegations": {
"/v2/finality-providers": {
"get": {
"description": "Fetches staker delegations for babylon staking including tvl, total delegations, active tvl, active delegations and total stakers.",
"description": "Fetches finality providers with optional filtering and pagination",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Staker Delegations",
"summary": "List Finality Providers",
"parameters": [
{
"type": "string",
"description": "Staker public key in hex format",
"name": "staker_pk_hex",
"in": "query",
"required": true
"description": "Pagination key to fetch the next page",
"name": "pagination_key",
"in": "query"
},
{
"enum": [
"active",
"standby"
],
"type": "string",
"description": "Pagination key to fetch the next page of delegations",
"name": "pagination_key",
"description": "Filter by state",
"name": "state",
"in": "query"
}
],
"responses": {
"200": {
"description": "List of staker delegations and pagination token",
"description": "List of finality providers and pagination token",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic"
"$ref": "#/definitions/handler.PublicResponse-array_v2service_FinalityProviderPublic"
}
},
"400": {
Expand All @@ -504,6 +519,26 @@ const docTemplate = `{
}
}
},
"/v2/global-params": {
"get": {
"description": "Fetches global parameters for babylon chain and BTC chain",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Global Parameters",
"responses": {
"200": {
"description": "Global parameters",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-v2service_GlobalParamsPublic"
}
}
}
}
},
"/v2/staker/stats": {
"get": {
"description": "Fetches staker stats for babylon staking including active tvl, total tvl, active delegations and total delegations.",
Expand Down Expand Up @@ -688,6 +723,17 @@ const docTemplate = `{
}
}
},
"handler.PublicResponse-v2service_StakerDelegationPublic": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/v2service.StakerDelegationPublic"
},
"pagination": {
"$ref": "#/definitions/handler.paginationResponse"
}
}
},
"handler.PublicResponse-v2service_StakerStatsPublic": {
"type": "object",
"properties": {
Expand Down
114 changes: 80 additions & 34 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,39 +391,30 @@
}
}
},
"/v2/finality-providers": {
"/v2/delegation": {
"get": {
"description": "Fetches finality providers with optional filtering and pagination",
"description": "Retrieves a delegation by a given transaction hash",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "List Finality Providers",
"summary": "Get a delegation",
"parameters": [
{
"type": "string",
"description": "Pagination key to fetch the next page",
"name": "pagination_key",
"in": "query"
},
{
"enum": [
"active",
"standby"
],
"type": "string",
"description": "Filter by state",
"name": "state",
"in": "query"
"description": "Staking transaction hash in hex format",
"name": "staking_tx_hash_hex",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "List of finality providers and pagination token",
"description": "Staker delegation",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-array_v2service_FinalityProviderPublic"
"$ref": "#/definitions/handler.PublicResponse-v2service_StakerDelegationPublic"
}
},
"400": {
Expand All @@ -435,56 +426,80 @@
}
}
},
"/v2/global-params": {
"/v2/delegations": {
"get": {
"description": "Fetches global parameters for babylon chain and BTC chain",
"description": "Fetches delegations for babylon staking including tvl, total delegations, active tvl, active delegations and total stakers.",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Global Parameters",
"summary": "Get Delegations",
"parameters": [
{
"type": "string",
"description": "Staker public key in hex format",
"name": "staker_pk_hex",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Pagination key to fetch the next page of delegations",
"name": "pagination_key",
"in": "query"
}
],
"responses": {
"200": {
"description": "Global parameters",
"description": "List of staker delegations and pagination token",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-v2service_GlobalParamsPublic"
"$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic"
}
},
"400": {
"description": "Error: Bad Request",
"schema": {
"$ref": "#/definitions/github_com_babylonlabs-io_staking-api-service_internal_shared_types.Error"
}
}
}
}
},
"/v2/staker/delegations": {
"/v2/finality-providers": {
"get": {
"description": "Fetches staker delegations for babylon staking including tvl, total delegations, active tvl, active delegations and total stakers.",
"description": "Fetches finality providers with optional filtering and pagination",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Staker Delegations",
"summary": "List Finality Providers",
"parameters": [
{
"type": "string",
"description": "Staker public key in hex format",
"name": "staker_pk_hex",
"in": "query",
"required": true
"description": "Pagination key to fetch the next page",
"name": "pagination_key",
"in": "query"
},
{
"enum": [
"active",
"standby"
],
"type": "string",
"description": "Pagination key to fetch the next page of delegations",
"name": "pagination_key",
"description": "Filter by state",
"name": "state",
"in": "query"
}
],
"responses": {
"200": {
"description": "List of staker delegations and pagination token",
"description": "List of finality providers and pagination token",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic"
"$ref": "#/definitions/handler.PublicResponse-array_v2service_FinalityProviderPublic"
}
},
"400": {
Expand All @@ -496,6 +511,26 @@
}
}
},
"/v2/global-params": {
"get": {
"description": "Fetches global parameters for babylon chain and BTC chain",
"produces": [
"application/json"
],
"tags": [
"v2"
],
"summary": "Get Global Parameters",
"responses": {
"200": {
"description": "Global parameters",
"schema": {
"$ref": "#/definitions/handler.PublicResponse-v2service_GlobalParamsPublic"
}
}
}
}
},
"/v2/staker/stats": {
"get": {
"description": "Fetches staker stats for babylon staking including active tvl, total tvl, active delegations and total delegations.",
Expand Down Expand Up @@ -680,6 +715,17 @@
}
}
},
"handler.PublicResponse-v2service_StakerDelegationPublic": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/v2service.StakerDelegationPublic"
},
"pagination": {
"$ref": "#/definitions/handler.paginationResponse"
}
}
},
"handler.PublicResponse-v2service_StakerStatsPublic": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 4109d25

Please sign in to comment.