diff --git a/src.ts/transaction/transaction.ts b/src.ts/transaction/transaction.ts index 92157feda..b9ec51d75 100644 --- a/src.ts/transaction/transaction.ts +++ b/src.ts/transaction/transaction.ts @@ -206,11 +206,9 @@ function _parseLegacy(data: Uint8Array): TransactionLike { } function _serializeLegacy(tx: Transaction, sig?: Signature): string { - assertArgument(tx.isLegacy(), "internal check failed; !legacy", "tx", tx); - const fields: Array = [ formatNumber(tx.nonce, "nonce"), - formatNumber(tx.gasPrice, "gasPrice"), + formatNumber(tx.gasPrice || 0, "gasPrice"), formatNumber(tx.gasLimit, "gasLimit"), (tx.to || "0x"), formatNumber(tx.value, "value"), @@ -312,18 +310,16 @@ function _parseEip1559(data: Uint8Array): TransactionLike { } function _serializeEip1559(tx: Transaction, sig?: Signature): string { - assertArgument(tx.isLondon(), "internal check failed; !london", "tx", tx); - const fields: Array = [ formatNumber(tx.chainId, "chainId"), formatNumber(tx.nonce, "nonce"), - formatNumber(tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"), - formatNumber(tx.maxFeePerGas, "maxFeePerGas"), + formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"), + formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"), formatNumber(tx.gasLimit, "gasLimit"), (tx.to || "0x"), formatNumber(tx.value, "value"), tx.data, - formatAccessList(tx.accessList) + formatAccessList(tx.accessList || [ ]) ]; if (sig) { @@ -364,17 +360,15 @@ function _parseEip2930(data: Uint8Array): TransactionLike { } function _serializeEip2930(tx: Transaction, sig?: Signature): string { - assertArgument(tx.isBerlin(), "internal check failed; !berlin", "tx", tx); - const fields: any = [ formatNumber(tx.chainId, "chainId"), formatNumber(tx.nonce, "nonce"), - formatNumber(tx.gasPrice, "gasPrice"), + formatNumber(tx.gasPrice || 0, "gasPrice"), formatNumber(tx.gasLimit, "gasLimit"), (tx.to || "0x"), formatNumber(tx.value, "value"), tx.data, - formatAccessList(tx.accessList) + formatAccessList(tx.accessList || [ ]) ]; if (sig) { @@ -426,20 +420,18 @@ function _parseEip4844(data: Uint8Array): TransactionLike { } function _serializeEip4844(tx: Transaction, sig?: Signature): string { - assertArgument(tx.isCancun(), "internal check failed; !cancun", "tx", tx); - const fields: Array = [ formatNumber(tx.chainId, "chainId"), formatNumber(tx.nonce, "nonce"), - formatNumber(tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"), - formatNumber(tx.maxFeePerGas, "maxFeePerGas"), + formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"), + formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"), formatNumber(tx.gasLimit, "gasLimit"), - tx.to, + (tx.to || ZeroAddress), formatNumber(tx.value, "value"), tx.data, - (formatAccessList(tx.accessList)), - formatNumber(tx.maxFeePerBlobGas, "maxFeePerBlobGas"), - formatHashes(tx.blobVersionedHashes, "blobVersionedHashes") + formatAccessList(tx.accessList || [ ]), + formatNumber(tx.maxFeePerBlobGas || 0, "maxFeePerBlobGas"), + formatHashes(tx.blobVersionedHashes || [ ], "blobVersionedHashes") ]; if (sig) {