@kaiachain/viem-ext
Version:
viem extension for kaia blockchain
23 lines (22 loc) • 772 B
JavaScript
import { getEstimateGasPayload } from '../utils.js';
import { isKlaytnTxType } from '@kaiachain/js-ext-core';
export const prepareTransactionRequest = async (client, txObj) => {
const req = await client.prepareTransactionRequest(txObj);
if (isKlaytnTxType(req.type) || req.type === 0) {
// only tx type 1, 2 use dynamic fee
delete req?.maxPriorityFeePerGas;
delete req?.maxFeePerGas;
req.gasPrice = await client.request({
method: 'klay_gasPrice',
params: [],
});
req.gasLimit = await getEstimateGasPayload(client, {
from: req?.from,
to: req?.to,
data: req?.data,
key: req?.key,
type: req?.type,
});
}
return req;
};