Skip to content

Commit

Permalink
fix(TransactionController): Remove unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
gantunesr committed Sep 8, 2021
1 parent a289caf commit d2c0bbc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
14 changes: 0 additions & 14 deletions src/transaction/TransactionController.ts
Expand Up @@ -110,20 +110,6 @@ export enum TransactionStatus {
unapproved = 'unapproved',
}

/**
* Status of a transaction according to Etherscan.
* According to the documentation: "The status field returns
* 0 for failed transactions and 1 for successful transactions"
* successful: 1
* failed: 0
* error: Indicates an error while fetching the data
*/
export enum EtherscanTransactionStatus {
successful = 'successful',
failed = 'failed',
error = 'error',
}

/**
* Options for wallet device.
*/
Expand Down
39 changes: 0 additions & 39 deletions src/util.ts
Expand Up @@ -17,7 +17,6 @@ import {
FetchAllOptions,
GasPriceValue,
FeeMarketEIP1559Values,
EtherscanTransactionStatus,
} from './transaction/TransactionController';
import { MessageParams } from './message-manager/MessageManager';
import { PersonalMessageParams } from './message-manager/PersonalMessageManager';
Expand Down Expand Up @@ -230,44 +229,6 @@ export async function handleTransactionFetch(
return [etherscanTxResponse, etherscanTokenResponse];
}

/**
* Method to fetch tHe status of a single transaction in Etherscan,
* from the Etherscan docs: "The status field returns 0 for failed transactions
* and 1 for successful transactions."
* @param networkType - Network type of desired network
* @param transactionHash - Hash of the required transaction
* @param opt? - Object that can contain fromBlock and Etherscan service API key
* @returns Promise with the status of the transaction
*/
export async function handletransationStatusFetch(
networkType: string,
transactionHash: string,
opt?: FetchAllOptions,
): Promise<EtherscanTransactionStatus> {
const urlParams = {
module: 'transaction',
action: 'gettxreceiptstatus',
txhash: transactionHash,
apikey: opt?.etherscanApiKey,
};
const etherscanTxUrl = getEtherscanApiUrl(networkType, urlParams);

try {
const response = await handleFetch(etherscanTxUrl);
const { status, result } = response;

if (status === '0') {
return EtherscanTransactionStatus.error;
}

return result.status === '1'
? EtherscanTransactionStatus.successful
: EtherscanTransactionStatus.failed;
} catch (e) {
return EtherscanTransactionStatus.error;
}
}

/**
* Converts a hex string to a BN object
*
Expand Down

0 comments on commit d2c0bbc

Please sign in to comment.