Skip to content

Commit

Permalink
Merge pull request #152 from sotatek-dev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Sotatek-TanHoang authored Oct 4, 2024
2 parents 79226f1 + 6f70628 commit d345fb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/database/repositories/event-log.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ export class EventLogRepository extends BaseRepository<EventLog> {
return queryBuilder.getManyAndCount();
}

public async sumAmountBridgeOfUserInDay(address: string) {
public async sumAmountBridgeOfUserInDay(address: string): Promise<{ totalamount: string }> {
const qb = this.createQb();
qb.select([`${this.alias}.sender_address`, `SUM(CAST(${this.alias}.amount_from as DECIMAL(100,2))) as totalamount`])
.where(`${this.alias}.sender_address = :address`, { address })
.andWhere(`${this.alias}.block_time_lock BETWEEN ${startOfDayUnix(new Date())} AND ${endOfDayUnix(new Date())}`)
.groupBy(`${this.alias}.sender_address`);
return qb.getRawOne();
return qb.getRawOne() as any;
}

async getValidatorPendingSignature(validator: string, network: ENetworkName) {
Expand Down
12 changes: 7 additions & 5 deletions src/modules/crawler/job-unlock.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ export class JobUnlockProvider {
const fromDecimal = this.configService.get(
networkReceived === ENetworkName.MINA ? EEnvKey.DECIMAL_TOKEN_EVM : EEnvKey.DECIMAL_TOKEN_MINA,
);
const [dailyQuota, totalamount] = await Promise.all([
const [dailyQuota, todayData] = await Promise.all([
await this.commonConfigRepository.getCommonConfig(),
await this.eventLogRepository.sumAmountBridgeOfUserInDay(address),
]);
assert(!!dailyQuota, 'daily quota undefined');

if (totalamount && BigNumber(totalamount.totalamount).isLessThan(addDecimal(dailyQuota.dailyQuota, fromDecimal))) {
return false;
if (
todayData?.totalamount &&
BigNumber(todayData.totalamount).isGreaterThan(addDecimal(dailyQuota.dailyQuota, fromDecimal))
) {
return true;
}
return true;
return false;
}
}

0 comments on commit d345fb9

Please sign in to comment.