-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
milestone and category list interface.
- Loading branch information
1 parent
978e29d
commit af9e8a7
Showing
13 changed files
with
323 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Entity, Column, PrimaryColumn, Index } from "typeorm"; | ||
import { BaseEntity } from "./base.entity"; | ||
import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; | ||
import { hexTransformer } from "../transformers/hex.transformer"; | ||
|
||
@Entity({ name: "transactionDataOfPoints" }) | ||
@Index(["userAddress", "txHash", "nonce"], { unique: true }) | ||
export class TransactionDataOfPoints extends BaseEntity { | ||
@PrimaryColumn({ type: "bytea", transformer: hexTransformer }) | ||
public readonly userAddress: string; | ||
|
||
@PrimaryColumn({ type: "bytea", transformer: hexTransformer }) | ||
public readonly contractAddress: string; | ||
|
||
@PrimaryColumn({ type: "bytea", transformer: hexTransformer }) | ||
public readonly tokenAddress: string; | ||
|
||
@PrimaryColumn({ type: "smallint" }) | ||
public readonly decimals: number; | ||
|
||
@Column({ type: "varchar", length: 100, nullable: true }) | ||
public readonly price: string; | ||
|
||
@Column({ type: "bigint", transformer: bigIntNumberTransformer }) | ||
public readonly quantity: string; | ||
|
||
@Column({ type: "varchar", length: 100 }) | ||
public readonly nonce: string; | ||
|
||
@Column({ type: "timestamp" }) | ||
public readonly timestamp: Date; | ||
|
||
@PrimaryColumn({ type: "bytea", transformer: hexTransformer }) | ||
public readonly txHash: string; | ||
|
||
@Index() | ||
@Column({ type: "bigint", transformer: bigIntNumberTransformer }) | ||
public readonly blockNumber: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { UnitOfWork as UnitOfWork } from "../unitOfWork"; | ||
import { BaseRepository } from "./base.repository"; | ||
import { TransactionDataOfPoints } from "../entities"; | ||
|
||
export interface TransactionDataOfPointsDto { | ||
userAddress: string; | ||
contractAddress: string; | ||
tokenAddress: string; | ||
decimals: number; | ||
price: string; | ||
quantity: bigint; | ||
nonce: string; | ||
timestamp: Date; | ||
txHash: string; | ||
blockNumber: number; | ||
projectName: string; | ||
} | ||
@Injectable() | ||
export class TxDataOfPointsRepository extends BaseRepository<TransactionDataOfPoints> { | ||
public constructor(unitOfWork: UnitOfWork) { | ||
super(TransactionDataOfPoints, unitOfWork); | ||
} | ||
|
||
public async getListByTime( | ||
startTime: string, | ||
endTime: string, | ||
pairAddress: string[], | ||
): Promise<TransactionDataOfPointsDto[]> { | ||
const pairAddressBuffer = pairAddress.map((item) => | ||
Buffer.from(item.slice(2), "hex"), | ||
); | ||
const transactionManager = this.unitOfWork.getTransactionManager(); | ||
const result = await transactionManager.query( | ||
`SELECT * FROM public."transactionDataOfPoints" WHERE "timestamp">='${startTime}' AND "timestamp"<'${endTime}' AND "contractAddress"=ANY($1);`, | ||
[pairAddressBuffer], | ||
); | ||
return result.map((row: any) => { | ||
row.userAddress = "0x" + row.userAddress.toString("hex").toLowerCase(); | ||
row.contractAddress = | ||
"0x" + row.contractAddress.toString("hex").toLowerCase(); | ||
row.tokenAddress = "0x" + row.tokenAddress.toString("hex").toLowerCase(); | ||
row.txHash = "0x" + row.txHash.toString("hex").toLowerCase(); | ||
row.timestamp = new Date(row.timestamp); | ||
return row; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.