Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 51e03f4

Browse files
authored
Merge pull request #308 from Zilliqa/feat/remove-get-pending-txn
feat/remove-get-pending-txn
2 parents 5f847eb + c4e8a4a commit 51e03f4

File tree

5 files changed

+13
-70
lines changed

5 files changed

+13
-70
lines changed

packages/zilliqa-js-blockchain/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,19 @@ for (const tx of batchResults) {
248248
}
249249
```
250250

251+
### `getTransactionStatus(txHash: string): Promise<RPCResponse<TransactionStatusObj>`
252+
253+
Returns the status of a specified transaction. This API is available from Zilliqa V7.0.0 onwards and supports all transaction statuses (unconfirmed, confirmed, and rejected).
254+
255+
**Parameters**
256+
- `txHash`: `string` - Specified TX id to check for the status.
257+
258+
**Returns**
259+
260+
- `Promise<RPCResponse<TransactionStatusObj>` - Status code of the transaction. Refer to [GetTransactionStatus](https://dev.zilliqa.com/docs/apis/api-transaction-get-transaction-status) for the full list of status code.
261+
262+
*Note: This API is available only on https://api.zilliqa.com/. It is disabled for community-hosted or private-hosted seed nodes.*
263+
251264
### `getTxnBodiesForTxBlock(txBlock: number): Promise<RPCResponse<TransactionObj[], string>>`
252265

253266
Returns the validated transactions (in verbose form) included within a specified final transaction block.

packages/zilliqa-js-blockchain/src/chain.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {
2525
DsBlockObj,
2626
GET_TX_ATTEMPTS,
2727
TransactionStatusObj,
28-
TransactionStatus,
29-
PendingTxns,
3028
Provider,
3129
RPCMethod,
3230
RPCResponse,
@@ -649,31 +647,6 @@ export class Blockchain implements ZilliqaModule {
649647
return this.provider.send<string, string>(RPCMethod.GetMinimumGasPrice);
650648
}
651649

652-
/**
653-
* getPendingTxns
654-
*
655-
* Returns the pending status of all unvalidated Transactions.
656-
*
657-
*/
658-
async getPendingTxns(): Promise<PendingTxns> {
659-
try {
660-
const response = await this.provider.send(RPCMethod.GetPendingTxns);
661-
if (response.error) {
662-
return Promise.reject(response.error);
663-
}
664-
665-
if (response.result.Txns.length) {
666-
response.result.Txns.forEach((txn: TransactionStatus) => {
667-
txn.info = this.pendingErrorMap[txn.code];
668-
});
669-
}
670-
671-
return response.result;
672-
} catch (err) {
673-
throw err;
674-
}
675-
}
676-
677650
/**
678651
* getBalance
679652
*

packages/zilliqa-js-blockchain/test/chain.spec.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -308,37 +308,6 @@ describe('Module: Blockchain', () => {
308308
expect(result.statusMessage).toEqual('Confirmed');
309309
});
310310

311-
it('should receive pending transaction list', async () => {
312-
const responses = [
313-
{
314-
id: 1,
315-
jsonrpc: '2.0',
316-
result: {
317-
Txns: [
318-
{
319-
code: 1,
320-
TxnHash:
321-
'ec5ef8110a285563d0104269081aa77820058067091a9b3f3ae70f38b94abda3',
322-
},
323-
],
324-
},
325-
},
326-
].map((res) => [JSON.stringify(res)] as [string]);
327-
328-
fetch.mockResponses(...responses);
329-
const result = await blockchain.getPendingTxns();
330-
expect(result.Txns).toBeDefined();
331-
// @ts-ignore
332-
expect(result.Txns).toEqual([
333-
{
334-
code: 1,
335-
TxnHash:
336-
'ec5ef8110a285563d0104269081aa77820058067091a9b3f3ae70f38b94abda3',
337-
info: 'Pending - Dispatched',
338-
},
339-
]);
340-
});
341-
342311
it('should receive miner info', async () => {
343312
const responses = [
344313
{

packages/zilliqa-js-core/src/net.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export enum RPCMethod {
5858
GetNumTxnsTxEpoch = 'GetNumTxnsTxEpoch',
5959
GetNumTxnsDSEpoch = 'GetNumTxnsDSEpoch',
6060
GetMinimumGasPrice = 'GetMinimumGasPrice',
61-
GetPendingTxn = 'GetPendingTxn',
62-
GetPendingTxns = 'GetPendingTxns',
6361

6462
// Contract-related methods
6563
GetSmartContracts = 'GetSmartContracts',

packages/zilliqa-js-core/src/types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,12 @@ export interface EventParam {
258258
value: any;
259259
}
260260

261-
export interface PendingTxns {
262-
Txns: TransactionStatus[];
263-
}
264-
265261
export interface TransactionStatus {
266262
code: number;
267263
TxnHash: string;
268264
info: string;
269265
}
270266

271-
export interface PendingTxnResult {
272-
code: number;
273-
confirmed: boolean;
274-
pending: boolean;
275-
}
276-
277267
export interface MinerInfo {
278268
dscommittee: string[];
279269
shards: ShardInfo[];

0 commit comments

Comments
 (0)