UNPKG

@tevm/tx

Version:

A custom implementation of ethereumjs tx

117 lines (114 loc) 3.68 kB
'use strict'; var tx = require('@ethereumjs/tx'); var errors = require('@tevm/errors'); var utils = require('@tevm/utils'); // src/index.ts var createImpersonatedTx = (txData, opts) => { let tx$1; try { tx$1 = new tx.FeeMarket1559Tx(txData, opts); } catch (e) { if (!(e instanceof Error)) { throw new errors.InternalError("Unknown Error", { cause: ( /** @type any*/ e ) }); } if (e.message.includes("EIP-1559 not enabled on Common")) { throw new errors.InternalError( "EIP-1559 is not enabled on Common. Tevm currently only supports 1559 and it should be enabled by default", { cause: e } ); } if (e.message.includes("gasLimit cannot exceed MAX_UINT64 (2^64-1)") || e.message.includes("gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)")) { throw new errors.InvalidGasLimitError(e.message, { cause: e }); } if (e.message.includes( "maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)" )) { throw new errors.InvalidGasLimitError(e.message, { cause: e }); } throw new errors.InternalError(e.message, { cause: e }); } return ( /** @type {import('./ImpersonatedTx.js').ImpersonatedTx}*/ new Proxy(tx$1, { get(target, prop) { if (prop === "isImpersonated") { return true; } if (prop === "hash") { return () => { try { return target.hash(); } catch (e) { return utils.keccak256(target.getHashedMessageToSign(), "bytes"); } }; } if (prop === "isSigned") { return () => true; } if (prop === "getSenderAddress") { return () => txData.impersonatedAddress; } return Reflect.get(target, prop); } }) ); }; Object.defineProperty(exports, "AccessListEIP2930Transaction", { enumerable: true, get: function () { return tx.AccessList2930Tx; } }); Object.defineProperty(exports, "BlobEIP4844Transaction", { enumerable: true, get: function () { return tx.Blob4844Tx; } }); Object.defineProperty(exports, "Capability", { enumerable: true, get: function () { return tx.Capability; } }); Object.defineProperty(exports, "FeeMarketEIP1559Transaction", { enumerable: true, get: function () { return tx.FeeMarket1559Tx; } }); Object.defineProperty(exports, "LegacyTransaction", { enumerable: true, get: function () { return tx.LegacyTx; } }); Object.defineProperty(exports, "TransactionFactory", { enumerable: true, get: function () { return tx.createTx; } }); Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return tx.TransactionType; } }); Object.defineProperty(exports, "createTxFromBlockBodyData", { enumerable: true, get: function () { return tx.createTxFromBlockBodyData; } }); Object.defineProperty(exports, "createTxFromRLP", { enumerable: true, get: function () { return tx.createTxFromRLP; } }); Object.defineProperty(exports, "isAccessListEIP2930Tx", { enumerable: true, get: function () { return tx.isAccessList2930Tx; } }); Object.defineProperty(exports, "isBlobEIP4844Tx", { enumerable: true, get: function () { return tx.isBlob4844Tx; } }); Object.defineProperty(exports, "isFeeMarketEIP1559Tx", { enumerable: true, get: function () { return tx.isFeeMarket1559Tx; } }); Object.defineProperty(exports, "isLegacyTx", { enumerable: true, get: function () { return tx.isLegacyTx; } }); exports.createImpersonatedTx = createImpersonatedTx; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map