Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core-api): return the database timestamp instead of deserialised #1957

Merged
merged 5 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/core-api/src/repositories/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export class TransactionsRepository extends Repository implements IRepository {
* @return {Object}
*/
public async findAllLegacy(parameters: any = {}): Promise<any> {
const selectQuery = this.query.select(this.query.block_id, this.query.serialized).from(this.query);
const countQuery = this._makeEstimateQuery();
const selectQuery = this.query
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query);

if (parameters.senderId) {
parameters.senderPublicKey = this.__publicKeyFromAddress(parameters.senderId);
Expand Down Expand Up @@ -107,8 +108,9 @@ export class TransactionsRepository extends Repository implements IRepository {
* @return {Object}
*/
public async findAllByWallet(wallet, parameters: any = {}): Promise<any> {
const selectQuery = this.query.select(this.query.block_id, this.query.serialized).from(this.query);
const countQuery = this._makeEstimateQuery();
const selectQuery = this.query
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query);

const applyConditions = queries => {
for (const item of queries) {
Expand Down Expand Up @@ -192,7 +194,7 @@ export class TransactionsRepository extends Repository implements IRepository {
*/
public async findById(id): Promise<any> {
const query = this.query
.select(this.query.block_id, this.query.serialized)
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query)
.where(this.query.id.equals(id));

Expand All @@ -209,7 +211,7 @@ export class TransactionsRepository extends Repository implements IRepository {
*/
public async findByTypeAndId(type, id): Promise<any> {
const query = this.query
.select(this.query.block_id, this.query.serialized)
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query)
.where(this.query.id.equals(id).and(this.query.type.equals(type)));

Expand All @@ -225,7 +227,7 @@ export class TransactionsRepository extends Repository implements IRepository {
*/
public async findByIds(ids): Promise<any> {
const query = this.query
.select(this.query.block_id, this.query.serialized)
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query)
.where(this.query.id.in(ids));

Expand All @@ -238,7 +240,7 @@ export class TransactionsRepository extends Repository implements IRepository {
*/
public async findWithVendorField(): Promise<any> {
const query = this.query
.select(this.query.block_id, this.query.serialized)
.select(this.query.block_id, this.query.serialized, this.query.timestamp)
.from(this.query)
.where(this.query.vendor_field_hex.isNotNull());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function transformTransactionLegacy(model) {
id: data.id,
blockid: model.blockId,
type: data.type,
timestamp: data.timestamp,
timestamp: model.timestamp || data.timestamp,
amount: +bignumify(data.amount).toFixed(),
fee: +bignumify(data.fee).toFixed(),
recipientId: data.recipientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export function transformTransaction(model) {
vendorField: data.vendorField,
asset: data.asset,
confirmations: model.block ? lastBlock.data.height - model.block.height : 0,
timestamp: formatTimestamp(data.timestamp),
timestamp: formatTimestamp(model.timestamp || data.timestamp),
};
}
2 changes: 1 addition & 1 deletion packages/core-snapshots-cli/src/commands/import.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { app } from "@arkecosystem/core-container";
import { SnapshotManager } from "@arkecosystem/core-snapshots";
import { EventEmitter } from "@arkecosystem/core-interfaces";
import { SnapshotManager } from "@arkecosystem/core-snapshots";
import _cliProgress from "cli-progress";

export async function importSnapshot(options) {
Expand Down