2021-02-04 19:15:23 +01:00
|
|
|
import { NETWORK_TO_NAME_MAP } from '../../../../shared/constants/network';
|
2021-07-16 20:53:01 +02:00
|
|
|
import { TRANSACTION_ENVELOPE_TYPES } from '../../../../shared/constants/transaction';
|
2018-04-12 23:17:36 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export const getNetworkDisplayName = (key) => NETWORK_TO_NAME_MAP[key];
|
2018-04-12 23:17:36 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function formatTxMetaForRpcResult(txMeta) {
|
2021-07-16 20:53:01 +02:00
|
|
|
const { r, s, v, hash, txReceipt, txParams } = txMeta;
|
|
|
|
const {
|
|
|
|
to,
|
|
|
|
data,
|
|
|
|
nonce,
|
|
|
|
gas,
|
|
|
|
from,
|
|
|
|
value,
|
|
|
|
gasPrice,
|
|
|
|
accessList,
|
|
|
|
maxFeePerGas,
|
|
|
|
maxPriorityFeePerGas,
|
|
|
|
} = txParams;
|
|
|
|
|
|
|
|
const formattedTxMeta = {
|
|
|
|
v,
|
|
|
|
r,
|
|
|
|
s,
|
|
|
|
to,
|
|
|
|
gas,
|
|
|
|
from,
|
|
|
|
hash,
|
|
|
|
nonce,
|
|
|
|
input: data || '0x',
|
|
|
|
value: value || '0x0',
|
|
|
|
accessList: accessList || null,
|
|
|
|
blockHash: txReceipt?.blockHash || null,
|
|
|
|
blockNumber: txReceipt?.blockNumber || null,
|
|
|
|
transactionIndex: txReceipt?.transactionIndex || null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2021-07-16 20:53:01 +02:00
|
|
|
|
|
|
|
if (maxFeePerGas && maxPriorityFeePerGas) {
|
2021-07-30 22:40:19 +02:00
|
|
|
formattedTxMeta.gasPrice = maxFeePerGas;
|
2021-07-16 20:53:01 +02:00
|
|
|
formattedTxMeta.maxFeePerGas = maxFeePerGas;
|
|
|
|
formattedTxMeta.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
|
|
formattedTxMeta.type = TRANSACTION_ENVELOPE_TYPES.FEE_MARKET;
|
|
|
|
} else {
|
|
|
|
formattedTxMeta.gasPrice = gasPrice;
|
|
|
|
formattedTxMeta.type = TRANSACTION_ENVELOPE_TYPES.LEGACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return formattedTxMeta;
|
2019-10-30 23:15:54 +01:00
|
|
|
}
|