Skip to content

Commit

Permalink
Merge branch 'development' into SERVICES-1551-tokens-module
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiulataretu committed Sep 1, 2023
2 parents a93a118 + 7609e88 commit a47fb42
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/modules/governance/entities/lkmex.proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class GovernanceLKMEXProposal extends GovernanceProposalModel {
actions: [],
rootHash: "",
totalQuorum: "6742520471308000000000000000000",
totalVotingPower: "2596636400000000",
feePayment: new EsdtTokenPaymentModel({
tokenIdentifier: "LKMEX-aab910",
tokenNonce: 0,
Expand Down
2 changes: 0 additions & 2 deletions src/modules/governance/models/governance.proposal.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export class GovernanceProposalModel {
withdrawPercentageDefeated: number;
@Field()
totalQuorum: string;
@Field()
totalVotingPower: string;
@Field(() => Int)
proposalStartBlock: number;
@Field()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ export class GovernanceProposalResolver {
.proposalVotes(governanceProposal.contractAddress, governanceProposal.proposalId);
}

@ResolveField()
async totalVotingPower(@Parent() governanceProposal: GovernanceProposalModel): Promise<string> {
return this.governanceServiceFactory
.userService(governanceProposal.contractAddress)
.totalVotingPower(governanceProposal.contractAddress, governanceProposal.proposalId);
}

@UseGuards(JwtOrNativeAuthGuard)
@ResolveField()
async hasVoted(
Expand Down
19 changes: 0 additions & 19 deletions src/modules/governance/services/governance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,6 @@ export class GovernanceTokenSnapshotService {
return this.smoothingFunction(userQuorum);
}

@ErrorLoggerAsync({ className: GovernanceTokenSnapshotService.name })
@GetOrSetCache({
baseKey: 'governance',
remoteTtl: CacheTtlInfo.ContractState.remoteTtl,
localTtl: CacheTtlInfo.ContractState.localTtl,
})
async totalVotingPower(scAddress: string, proposalId: number): Promise<string> {
return await this.totalVotingPowerRaw(scAddress, proposalId);
}

async totalVotingPowerRaw(scAddress: string, proposalId: number): Promise<string> {
const proposal = await this.governanceAbiFactory.useAbi(scAddress).proposals(scAddress);
const proposalIndex = proposal.findIndex((p) => p.proposalId === proposalId);
if (proposalIndex === -1) {
throw new Error(`Proposal with id ${proposalId} not found`);
}
return this.smoothingFunction(proposal[proposalIndex].totalQuorum);
}

protected smoothingFunction(quorum: string): string {
return new BigNumber(quorum).integerValue().toFixed();
}
Expand Down

0 comments on commit a47fb42

Please sign in to comment.