Skip to content

Commit

Permalink
Merge pull request #32 from axone-protocol/style/gov
Browse files Browse the repository at this point in the history
style: fixed styles, removed d from response
  • Loading branch information
yevhen-burkovskyi authored Jun 18, 2024
2 parents dd42094 + ace86eb commit 0bd0b65
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
17 changes: 0 additions & 17 deletions .editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDE
.idea
.vscode
.editorconfig

# dependencies
/node_modules
Expand Down
26 changes: 14 additions & 12 deletions src/modules/governance/services/governance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { Log } from "@core/loggers/log";
export class GovernanceService implements OnModuleInit {
constructor(
private readonly okp4Service: Okp4Service,
private readonly cache: GovernanceCache,
) { }
private readonly cache: GovernanceCache
) {}

async onModuleInit() {
await this.fetchAndCacheGovOverview();
Expand All @@ -21,16 +21,18 @@ export class GovernanceService implements OnModuleInit {
try {
const govResponse = await this.okp4Service.getGovParams();
const govProposals = await this.okp4Service.getProposals();

const govOverview: GovOverviewDto = {
totalProposals: Number.parseInt(govProposals.pagination.total),
currentProposals: this.currentProposals(govProposals.proposals),
votingPeriod: this.votingPeriodToView(govResponse.voting_params.voting_period),
depositRequired: govResponse?.params?.min_deposit[0]?.amount || '0',
}
votingPeriod: this.votingPeriodToView(
govResponse.voting_params.voting_period
),
depositRequired: govResponse?.params?.min_deposit[0]?.amount || "0",
};

this.cache.setGovOverview(govOverview);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
Log.warn("Failed to fetch and cache gov overview " + e.message);
}
Expand All @@ -49,14 +51,14 @@ export class GovernanceService implements OnModuleInit {
return count;
}
return acc;
}, 0)
}, 0);
}

private votingPeriodToView(votingPeriod: string) {
const totalSeconds = Number.parseInt(votingPeriod.slice(0, -1), 10);

const days = totalSeconds / 86400;
return `${Number.isInteger(days) ? days : days.toFixed(1)} D`;

return `${Number.isInteger(days) ? days : days.toFixed(1)}`;
}
}
}

0 comments on commit 0bd0b65

Please sign in to comment.