Skip to content

Commit

Permalink
Merge pull request #88 from sotatek-dev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Sotatek-TanHoang authored Sep 25, 2024
2 parents 22a37b1 + 3392d08 commit 6774962
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/database/repositories/event-log.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class EventLogRepository extends BaseRepository<EventLog> {
public async getHistoriesOfUser(address: string, options) {
const queryBuilder = this.createQb();
queryBuilder
.where(`${this.alias}.sender_address = :address`, { address })
.where(`${this.alias}.sender_address = :address OR ${this.alias}.receive_address = :address`, { address })
.orderBy(`${this.alias}.id`, EDirection.DESC)
.select([
`${this.alias}.id`,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/crawler/crawler.evmbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export class BlockchainEVMCrawler {
await queryRunner.manager.update(EventLog, existLockTx.id, {
status: EEventStatus.COMPLETED,
txHashUnlock: event.transactionHash,
// amountReceived: event.returnValues.amount,
// protocolFee: event.returnValues.fee,
amountReceived: event.returnValues.amount,
protocolFee: event.returnValues.fee,
tokenReceivedAddress: event.returnValues.token,
tokenReceivedName: EAsset.ETH,
});
Expand Down
4 changes: 2 additions & 2 deletions src/modules/crawler/crawler.minabridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export class SCBridgeMinaCrawler {
await queryRunner.manager.update(EventLog, existLockTx.id, {
status: EEventStatus.COMPLETED,
txHashUnlock: event.event.transactionInfo.transactionHash,
// amountReceived: event.event.data.amount.toString(),
// tokenReceivedAddress: event.event.data.tokenAddress,
amountReceived: event.event.data.amount.toString(),
tokenReceivedAddress: event.event.data.tokenAddress,
tokenReceivedName: EAsset.WETH,
});

Expand Down
2 changes: 1 addition & 1 deletion src/modules/crawler/sender.evmbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class SenderEVMBridge {
status: EEventStatus.PROCESSING,
errorDetail: null,
protocolFee,
amountReceived,
amountReceived: BigNumber(amountReceived).minus(protocolFee).toFixed(0).toString(),
});
} else {
await this.handleError(result.error, dataLock);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/crawler/sender.minabridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ export class SenderMinaBridge {

const rateMINAETH = Number(rateethmina.toFixed(0)) || 2000; // refactor this

await this.eventLogRepository.update(dataLock.id, { amountReceived, protocolFee: protocolFeeAmount });

const result = await this.callUnlockFunction(amountReceived, id, receiveAddress, protocolFeeAmount, rateMINAETH);
// Update status eventLog when call function unlock
if (result.success) {
Expand All @@ -139,6 +137,8 @@ export class SenderMinaBridge {
status: EEventStatus.PROCESSING,
errorDetail: result.error,
txHashUnlock: result.data,
amountReceived: BigNumber(amountReceived).minus(protocolFeeAmount).toFixed(0).toString(),
protocolFee: protocolFeeAmount,
});
} else {
await this.eventLogRepository.updateStatusAndRetryEvenLog({
Expand Down
1 change: 0 additions & 1 deletion src/shared/utils/bignumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export const calculateFee = (amount: string, gasFee: string | number, tipPercent
.minus(BigNumber(gasFee))
.multipliedBy(tipPercent * 10)
.dividedBy(1000);

return BigNumber(gasFee).plus(tip).toFixed(0, BigNumber.ROUND_UP);
};

0 comments on commit 6774962

Please sign in to comment.