Skip to content

Commit

Permalink
new v3 controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gluneau committed Oct 13, 2023
1 parent 14beed2 commit c9a7bc3
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
70 changes: 69 additions & 1 deletion public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,35 @@
"tags": [
"Dapps Staking"
],
"description": "Retrieves list of dapps registered for dapps staking",
"description": "Retrieves list of dapps (full model) registered for dapps staking",
"parameters": [
{
"name": "network",
"in": "path",
"required": true,
"type": "string",
"description": "The network name. Supported networks: astar, shiden, shibuya, rocstar, development",
"enum": [
"astar",
"shiden",
"shibuya",
"rocstar"
]
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/{network}/dapps-staking/dappssimple": {
"get": {
"tags": [
"Dapps Staking"
],
"description": "Retrieves list of dapps (basic info) registered for dapps staking",
"parameters": [
{
"name": "network",
Expand Down Expand Up @@ -589,6 +617,46 @@
}
}
},
"/api/v3/{network}/dapps-staking/stats/user/{userAddress}/{period}": {
"get": {
"tags": [
"Dapps Staking"
],
"description": "Retrieves dapp staking APR for a given network.",
"parameters": [
{
"name": "network",
"in": "path",
"required": true,
"type": "string",
"description": "The network name. Supported networks: astar, shiden, shibuya, rocstar",
"enum": [
"astar",
"shiden",
"shibuya",
"rocstar"
]
},
{
"name": "userAddress",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "period",
"in": "path",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/{network}/node/tx-perblock/total": {
"get": {
"tags": [
Expand Down
7 changes: 7 additions & 0 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DiaDataPriceProvider } from './services/DiaDataPriceProvider';
import { CoinGeckoPriceProvider } from './services/CoinGeckoPriceProvider';
import { PriceProviderWithFailover } from './services/PriceProviderWithFailover';
import { DappsStakingService2 } from './services/DappsStakingService2';
import { DappsStakingEvents, IDappsStakingEvents } from './services/DappsStakingEvents';
import { IMonthlyActiveWalletsService, MonthlyActiveWalletsService } from './services/MonthlyActiveWalletsService';
import { MonthlyActiveWalletsController } from './controllers/MonthlyActiveWalletsController';
import { DappsStakingStatsService, IDappsStakingStatsService } from './services/DappsStakingStatsService';
Expand Down Expand Up @@ -71,6 +72,12 @@ container.bind<IApiFactory>(ContainerTypes.ApiFactory).to(ApiFactory).inSingleto
// services registration
container.bind<IStatsService>(ContainerTypes.StatsService).to(StatsService).inSingletonScope();

container
.bind<IDappsStakingEvents>(ContainerTypes.DappsStakingEvents)
.to(DappsStakingEvents)
.inSingletonScope()
.whenTargetNamed(networks.astar.name);

container
.bind<IDappsStakingService>(ContainerTypes.DappsStakingService)
.to(DappsStakingService2)
Expand Down
1 change: 1 addition & 0 deletions src/containertypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const ContainerTypes = {
StatsService: 'StatsService',
Api: 'Api',
ApiFactory: 'ApiFactory',
DappsStakingEvents: 'DappsStakingEvents',
DappsStakingService: 'DappsStakingService',
StatsIndexerService: 'StatsIndexerService',
FirebaseService: 'FirebaseService',
Expand Down
19 changes: 19 additions & 0 deletions src/controllers/DappsStakingController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { IStatsIndexerService } from '../services/StatsIndexerService';
import { ControllerBase } from './ControllerBase';
import { IControllerBase } from './IControllerBase';
import { IGiantSquidService } from '../services/GiantSquidService';
import { IDappsStakingEvents } from '../services/DappsStakingEvents';

@injectable()
export class DappsStakingController extends ControllerBase implements IControllerBase {
Expand All @@ -23,6 +24,7 @@ export class DappsStakingController extends ControllerBase implements IControlle
@inject(ContainerTypes.DappsStakingStatsService) private _statsService: IDappsStakingStatsService,
@inject(ContainerTypes.DappRadarService) private _dappRadarService: IDappRadarService,
@inject(ContainerTypes.GiantSquidService) private _giantSquidService: IGiantSquidService,
@inject(ContainerTypes.DappsStakingEvents) private _dappsStakingEvents: IDappsStakingEvents,
) {
super();
}
Expand Down Expand Up @@ -334,6 +336,23 @@ export class DappsStakingController extends ControllerBase implements IControlle
},
);

app.route('/api/v3/:network/dapps-staking/stats/user/:userAddress/:period').get(
async (req: Request, res: Response) => {
// this._giantSquidService.getUserCalls(req.params.network as NetworkType, req.params.userAddress, req.params.period as PeriodType);
try {
res.json(
await this._dappsStakingEvents.getStakingEvents(
req.params.network as NetworkType,
req.params.userAddress,
req.params.period as PeriodType,
),
);
} catch (err) {
this.handleError(res, err as Error);
}
},
);

app.route('/api/v1/:network/dapps-staking/stats/transactions').get(async (req: Request, res: Response) => {
/*
#swagger.ignore = true
Expand Down

0 comments on commit c9a7bc3

Please sign in to comment.