Skip to content

Commit

Permalink
Remove assertion in sendTransactionFromTxParams
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Mar 31, 2021
1 parent ce12760 commit 55e9e6d
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Transaction } from "@ethereumjs/tx";
import { bufferToHex, toBuffer, zeroAddress } from "ethereumjs-util";

import { RpcTransactionRequestInput } from "../../../../src/internal/hardhat-network/provider/input";
import { TransactionParams } from "../../../../src/internal/hardhat-network/provider/node-types";
import { numberToRpcQuantity } from "../../../../src/internal/hardhat-network/provider/output";
import { HardhatNetworkProvider } from "../../../../src/internal/hardhat-network/provider/provider";
Expand Down Expand Up @@ -54,17 +55,19 @@ export async function sendTransactionFromTxParams(
provider: EthereumProvider,
txParams: TransactionParams
) {
return provider.send("eth_sendTransaction", [
{
to: bufferToHex(txParams.to!),
from: bufferToHex(txParams.from),
data: bufferToHex(txParams.data),
nonce: numberToRpcQuantity(txParams.nonce),
value: numberToRpcQuantity(txParams.value),
gas: numberToRpcQuantity(txParams.gasLimit),
gasPrice: numberToRpcQuantity(txParams.gasPrice),
},
]);
const rpcTxParams: RpcTransactionRequestInput = {
from: bufferToHex(txParams.from),
data: bufferToHex(txParams.data),
nonce: numberToRpcQuantity(txParams.nonce),
value: numberToRpcQuantity(txParams.value),
gas: numberToRpcQuantity(txParams.gasLimit),
gasPrice: numberToRpcQuantity(txParams.gasPrice),
};

if (txParams.to !== undefined) {
rpcTxParams.to = bufferToHex(txParams.to!);
}
return provider.send("eth_sendTransaction", [rpcTxParams]);
}

export async function getSignedTxHash(
Expand Down

0 comments on commit 55e9e6d

Please sign in to comment.