Skip to content

Commit 4bb146d

Browse files
asimm241zone117x
authored andcommitted
fix: fix mempool transaction issue response issue
make changes to mempool response as per rosetta
1 parent 256d442 commit 4bb146d

File tree

4 files changed

+14
-31
lines changed

4 files changed

+14
-31
lines changed

src/api/routes/rosetta/mempool.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { parseLimitQuery, parsePagingQueryInput } from '../../pagination';
66
import { rosettaValidateRequest, ValidSchema, makeRosettaError } from '../../rosetta-validate';
77
import {
88
RosettaMempoolResponse,
9+
RosettaMempoolTransactionResponse,
910
RosettaTransaction,
1011
} from '@blockstack/stacks-blockchain-api-types';
1112
import { getOperations } from '../../../rosetta-helpers';
@@ -28,23 +29,17 @@ export function createRosettaMempoolRouter(db: DataStore): RouterWithAsync {
2829
return;
2930
}
3031

31-
const limit = req.body.metadata
32-
? parseMempoolTxQueryLimit(req.body.metadata.limit ?? 100)
33-
: 100;
34-
const offset = req.body.metadata ? parsePagingQueryInput(req.body.metadata.offset ?? 0) : 0;
35-
const { results: txResults, total } = await db.getMempoolTxIdList({ offset, limit });
32+
// const limit = req.body.metadata
33+
// ? parseMempoolTxQueryLimit(req.body.metadata.limit ?? 100)
34+
// : 100;
35+
// const offset = req.body.metadata ? parsePagingQueryInput(req.body.metadata.offset ?? 0) : 0;
36+
const { results: txResults, total } = await db.getMempoolTxIdList();
3637

3738
const transaction_identifiers = txResults.map(tx => {
3839
return { hash: tx.tx_id };
3940
});
40-
const metadata = {
41-
limit: limit,
42-
total: total,
43-
offset: offset,
44-
};
4541
const response: RosettaMempoolResponse = {
4642
transaction_identifiers,
47-
metadata,
4843
};
4944
res.json(response);
5045
});
@@ -68,10 +63,13 @@ export function createRosettaMempoolRouter(db: DataStore): RouterWithAsync {
6863
}
6964

7065
const operations = getOperations(mempoolTxQuery.result);
71-
const result: RosettaTransaction = {
66+
const transaction: RosettaTransaction = {
7267
transaction_identifier: { hash: tx_id },
7368
operations: operations,
7469
};
70+
const result: RosettaMempoolTransactionResponse = {
71+
transaction: transaction,
72+
};
7573
res.json(result);
7674
});
7775

src/datastore/common.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,7 @@ export interface DataStore extends DataStoreEventEmitter {
249249
limit: number;
250250
offset: number;
251251
}): Promise<{ results: DbMempoolTx[]; total: number }>;
252-
getMempoolTxIdList(args: {
253-
limit: number;
254-
offset: number;
255-
}): Promise<{ results: DbMempoolTxId[]; total: number }>;
252+
getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[]; total: number }>;
256253
getTx(txId: string): Promise<FoundOrNot<DbTx>>;
257254
getTxList(args: {
258255
limit: number;

src/datastore/memory-store.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ export class MemoryDataStore extends (EventEmitter as { new (): DataStoreEventEm
178178
throw new Error('not yet implemented');
179179
}
180180

181-
getMempoolTxIdList(args: {
182-
limit: number;
183-
offset: number;
184-
}): Promise<{ results: DbMempoolTx[]; total: number }> {
181+
getMempoolTxIdList(): Promise<{ results: DbMempoolTx[]; total: number }> {
185182
throw new Error('not yet implemented');
186183
}
187184

src/datastore/postgres-store.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,13 +1152,7 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
11521152
return { results: parsed, total: totalQuery.rows[0].count };
11531153
}
11541154

1155-
async getMempoolTxIdList({
1156-
limit,
1157-
offset,
1158-
}: {
1159-
limit: number;
1160-
offset: number;
1161-
}): Promise<{ results: DbMempoolTxId[]; total: number }> {
1155+
async getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[]; total: number }> {
11621156
const totalQuery = await this.pool.query<{ count: number }>(
11631157
`
11641158
SELECT COUNT(*)::integer
@@ -1170,10 +1164,7 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
11701164
SELECT ${MEMPOOL_TX_ID_COLUMNS}
11711165
FROM mempool_txs
11721166
ORDER BY receipt_time DESC
1173-
LIMIT $1
1174-
OFFSET $2
1175-
`,
1176-
[limit, offset]
1167+
`
11771168
);
11781169
const parsed = resultQuery.rows.map(r => {
11791170
const tx: DbMempoolTxId = {

0 commit comments

Comments
 (0)