diff --git a/packages/zilliqa-js-blockchain/README.md b/packages/zilliqa-js-blockchain/README.md index bd2d0729..2bd0e886 100644 --- a/packages/zilliqa-js-blockchain/README.md +++ b/packages/zilliqa-js-blockchain/README.md @@ -248,6 +248,19 @@ for (const tx of batchResults) { } ``` +### `getTransactionStatus(txHash: string): Promise` + +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). + +**Parameters** +- `txHash`: `string` - Specified TX id to check for the status. + +**Returns** + +- `Promise` - 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. + +*Note: This API is available only on https://api.zilliqa.com/. It is disabled for community-hosted or private-hosted seed nodes.* + ### `getTxnBodiesForTxBlock(txBlock: number): Promise>` Returns the validated transactions (in verbose form) included within a specified final transaction block. diff --git a/packages/zilliqa-js-blockchain/src/chain.ts b/packages/zilliqa-js-blockchain/src/chain.ts index 6353ac96..0bbf1c44 100644 --- a/packages/zilliqa-js-blockchain/src/chain.ts +++ b/packages/zilliqa-js-blockchain/src/chain.ts @@ -25,8 +25,6 @@ import { DsBlockObj, GET_TX_ATTEMPTS, TransactionStatusObj, - TransactionStatus, - PendingTxns, Provider, RPCMethod, RPCResponse, @@ -649,31 +647,6 @@ export class Blockchain implements ZilliqaModule { return this.provider.send(RPCMethod.GetMinimumGasPrice); } - /** - * getPendingTxns - * - * Returns the pending status of all unvalidated Transactions. - * - */ - async getPendingTxns(): Promise { - try { - const response = await this.provider.send(RPCMethod.GetPendingTxns); - if (response.error) { - return Promise.reject(response.error); - } - - if (response.result.Txns.length) { - response.result.Txns.forEach((txn: TransactionStatus) => { - txn.info = this.pendingErrorMap[txn.code]; - }); - } - - return response.result; - } catch (err) { - throw err; - } - } - /** * getBalance * diff --git a/packages/zilliqa-js-blockchain/test/chain.spec.ts b/packages/zilliqa-js-blockchain/test/chain.spec.ts index 97c28dee..60d1ad3a 100644 --- a/packages/zilliqa-js-blockchain/test/chain.spec.ts +++ b/packages/zilliqa-js-blockchain/test/chain.spec.ts @@ -308,37 +308,6 @@ describe('Module: Blockchain', () => { expect(result.statusMessage).toEqual('Confirmed'); }); - it('should receive pending transaction list', async () => { - const responses = [ - { - id: 1, - jsonrpc: '2.0', - result: { - Txns: [ - { - code: 1, - TxnHash: - 'ec5ef8110a285563d0104269081aa77820058067091a9b3f3ae70f38b94abda3', - }, - ], - }, - }, - ].map((res) => [JSON.stringify(res)] as [string]); - - fetch.mockResponses(...responses); - const result = await blockchain.getPendingTxns(); - expect(result.Txns).toBeDefined(); - // @ts-ignore - expect(result.Txns).toEqual([ - { - code: 1, - TxnHash: - 'ec5ef8110a285563d0104269081aa77820058067091a9b3f3ae70f38b94abda3', - info: 'Pending - Dispatched', - }, - ]); - }); - it('should receive miner info', async () => { const responses = [ { diff --git a/packages/zilliqa-js-core/src/net.ts b/packages/zilliqa-js-core/src/net.ts index cd1e5d58..3be66d34 100644 --- a/packages/zilliqa-js-core/src/net.ts +++ b/packages/zilliqa-js-core/src/net.ts @@ -58,8 +58,6 @@ export enum RPCMethod { GetNumTxnsTxEpoch = 'GetNumTxnsTxEpoch', GetNumTxnsDSEpoch = 'GetNumTxnsDSEpoch', GetMinimumGasPrice = 'GetMinimumGasPrice', - GetPendingTxn = 'GetPendingTxn', - GetPendingTxns = 'GetPendingTxns', // Contract-related methods GetSmartContracts = 'GetSmartContracts', diff --git a/packages/zilliqa-js-core/src/types.ts b/packages/zilliqa-js-core/src/types.ts index 1593a3b6..7d98de80 100644 --- a/packages/zilliqa-js-core/src/types.ts +++ b/packages/zilliqa-js-core/src/types.ts @@ -258,22 +258,12 @@ export interface EventParam { value: any; } -export interface PendingTxns { - Txns: TransactionStatus[]; -} - export interface TransactionStatus { code: number; TxnHash: string; info: string; } -export interface PendingTxnResult { - code: number; - confirmed: boolean; - pending: boolean; -} - export interface MinerInfo { dscommittee: string[]; shards: ShardInfo[];