Skip to content

Commit

Permalink
feat: add contractAddress cw20 tx
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Jul 24, 2023
1 parent 42abf9c commit 457a9de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/repositories/impls/aura-tx.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BaseRepository } from './base.repository';
import { ObjectLiteral, Repository } from 'typeorm';
import { ENTITIES_CONFIG } from '../../module.config';
import { IAuraTransactionRepository } from '../iaura-tx.repository';
import { AuraTx } from '../../entities';
@Injectable()
export class AuraTxRepository
extends BaseRepository
Expand All @@ -30,14 +31,28 @@ export class AuraTxRepository
return 0;
}

async insertBulkTransaction(listTransations: any[]) {
async insertBulkTransaction(listTransations: AuraTx[]) {
console.log(listTransations);
let query = `INSERT IGNORE INTO AuraTx(CreatedAt, UpdatedAt, Id, Code, GasUsed, GasWanted, Fee, Height, RawLogs, FromAddress, ToAddress, Amount, RewardAmount, Denom, TimeStamp, TxHash, InternalChainId) VALUES`;
for (let auraTx of listTransations) {
query += ` (DEFAULT, DEFAULT, DEFAULT, ${auraTx.code}, ${auraTx.gasUsed}, ${auraTx.gasWanted}, ${auraTx.fee !== undefined ? auraTx.fee.toString() : null}, ${auraTx.height}, '${auraTx.rawLogs}', '${auraTx.fromAddress || ''}', '${auraTx.toAddress || ''}', ${auraTx.amount || null}, ${auraTx.rewardAmount || null}, '${auraTx.denom || ''}', FROM_UNIXTIME(${auraTx.timeStamp.valueOf()/1000}), '${auraTx.txHash}', '${auraTx.internalChainId}'),`;
let query = `INSERT IGNORE INTO AuraTx(CreatedAt, UpdatedAt, Id, Code, GasUsed, GasWanted, Fee, Height, RawLogs, FromAddress, ToAddress, Amount, RewardAmount, Denom, ContractAddress, TimeStamp, TxHash, InternalChainId) VALUES`;
for (const auraTx of listTransations) {
query += ` (DEFAULT, DEFAULT, DEFAULT, ${auraTx.code}, ${
auraTx.gasUsed
}, ${auraTx.gasWanted}, ${
auraTx.fee !== undefined ? auraTx.fee.toString() : null
}, ${auraTx.height}, '${auraTx.rawLogs}', '${
auraTx.fromAddress || ''
}', '${auraTx.toAddress || ''}', ${auraTx.amount || null}, ${
auraTx.rewardAmount || null
}, '${auraTx.denom || ''}', '${
auraTx.contractAddress
}', FROM_UNIXTIME(${auraTx.timeStamp.valueOf() / 1000}), '${
auraTx.txHash
}', '${auraTx.internalChainId}'),`;
}
// console.log(query);
query = query.substring(0, query.length - 1) + ';';
return await this.repos.query(query);

// return await this.repos.save(listTransations);
}
}
6 changes: 5 additions & 1 deletion src/shared/services/common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ export class CommonService {
addrs.push(toAddress);
}

if (safes[msg.sender]) addrs.push(msg.sender);
if (safes[msg.sender]) {
fromAddress = msg.sender;
toAddress = msg.msg?.transfer?.recipient;
addrs.push(msg.sender);
}

if (addrs.length === 0) break;

Expand Down

0 comments on commit 457a9de

Please sign in to comment.