Comparing version 4.6.1-dev.f44dc5b.0 to 4.6.1-dev.f4e55bd.0
@@ -29,2 +29,3 @@ "use strict"; | ||
exports.getTransactionGasPricing = void 0; | ||
const web3_types_1 = require("web3-types"); | ||
const web3_validator_1 = require("web3-validator"); | ||
@@ -38,9 +39,13 @@ const web3_errors_1 = require("web3-errors"); | ||
function getEip1559GasPricing(transaction, web3Context, returnFormat) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const block = yield (0, rpc_method_wrappers_js_1.getBlock)(web3Context, web3Context.defaultBlock, false, returnFormat); | ||
const block = yield (0, rpc_method_wrappers_js_1.getBlock)(web3Context, web3Context.defaultBlock, false, web3_types_1.ETH_DATA_FORMAT); | ||
if ((0, web3_validator_1.isNullish)(block.baseFeePerGas)) | ||
throw new web3_errors_1.Eip1559NotSupportedError(); | ||
if (!(0, web3_validator_1.isNullish)(transaction.gasPrice)) { | ||
const convertedTransactionGasPrice = (0, web3_utils_1.format)({ format: 'uint' }, transaction.gasPrice, returnFormat); | ||
let gasPrice; | ||
if ((0, web3_validator_1.isNullish)(transaction.gasPrice) && BigInt(block.baseFeePerGas) === BigInt(0)) { | ||
gasPrice = yield (0, rpc_method_wrappers_js_1.getGasPrice)(web3Context, returnFormat); | ||
} | ||
if (!(0, web3_validator_1.isNullish)(transaction.gasPrice) || !(0, web3_validator_1.isNullish)(gasPrice)) { | ||
const convertedTransactionGasPrice = (0, web3_utils_1.format)({ format: 'uint' }, (_a = transaction.gasPrice) !== null && _a !== void 0 ? _a : gasPrice, returnFormat); | ||
return { | ||
@@ -52,5 +57,5 @@ maxPriorityFeePerGas: convertedTransactionGasPrice, | ||
return { | ||
maxPriorityFeePerGas: (0, web3_utils_1.format)({ format: 'uint' }, (_a = transaction.maxPriorityFeePerGas) !== null && _a !== void 0 ? _a : web3Context.defaultMaxPriorityFeePerGas, returnFormat), | ||
maxFeePerGas: (0, web3_utils_1.format)({ format: 'uint' }, ((_b = transaction.maxFeePerGas) !== null && _b !== void 0 ? _b : BigInt(block.baseFeePerGas) * BigInt(2) + | ||
BigInt((_c = transaction.maxPriorityFeePerGas) !== null && _c !== void 0 ? _c : web3Context.defaultMaxPriorityFeePerGas)), returnFormat), | ||
maxPriorityFeePerGas: (0, web3_utils_1.format)({ format: 'uint' }, (_b = transaction.maxPriorityFeePerGas) !== null && _b !== void 0 ? _b : web3Context.defaultMaxPriorityFeePerGas, returnFormat), | ||
maxFeePerGas: (0, web3_utils_1.format)({ format: 'uint' }, ((_c = transaction.maxFeePerGas) !== null && _c !== void 0 ? _c : BigInt(block.baseFeePerGas) * BigInt(2) + | ||
BigInt((_d = transaction.maxPriorityFeePerGas) !== null && _d !== void 0 ? _d : web3Context.defaultMaxPriorityFeePerGas)), returnFormat), | ||
}; | ||
@@ -57,0 +62,0 @@ }); |
@@ -72,3 +72,7 @@ "use strict"; | ||
if (this.options.checkRevertBeforeSending !== false) { | ||
const reason = yield (0, get_revert_reason_js_1.getRevertReason)(this.web3Context, tx, this.options.contractAbi); | ||
let formatTx = tx; | ||
if ((0, web3_validator_1.isNullish)(tx.data) && (0, web3_validator_1.isNullish)(tx.input) && (0, web3_validator_1.isNullish)(tx.gas)) { // eth.call runs into error if data isnt filled and gas is not defined, its a simple transaction so we fill it with 21000 | ||
formatTx = Object.assign(Object.assign({}, tx), { gas: 21000 }); | ||
} | ||
const reason = yield (0, get_revert_reason_js_1.getRevertReason)(this.web3Context, formatTx, this.options.contractAbi); | ||
if (reason !== undefined) { | ||
@@ -75,0 +79,0 @@ throw yield (0, get_transaction_error_js_1.getTransactionError)(this.web3Context, tx, undefined, undefined, this.options.contractAbi, reason); |
@@ -26,2 +26,3 @@ /* | ||
}; | ||
import { ETH_DATA_FORMAT, } from 'web3-types'; | ||
import { isNullish } from 'web3-validator'; | ||
@@ -35,9 +36,13 @@ import { Eip1559NotSupportedError, UnsupportedTransactionTypeError } from 'web3-errors'; | ||
function getEip1559GasPricing(transaction, web3Context, returnFormat) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const block = yield getBlock(web3Context, web3Context.defaultBlock, false, returnFormat); | ||
const block = yield getBlock(web3Context, web3Context.defaultBlock, false, ETH_DATA_FORMAT); | ||
if (isNullish(block.baseFeePerGas)) | ||
throw new Eip1559NotSupportedError(); | ||
if (!isNullish(transaction.gasPrice)) { | ||
const convertedTransactionGasPrice = format({ format: 'uint' }, transaction.gasPrice, returnFormat); | ||
let gasPrice; | ||
if (isNullish(transaction.gasPrice) && BigInt(block.baseFeePerGas) === BigInt(0)) { | ||
gasPrice = yield getGasPrice(web3Context, returnFormat); | ||
} | ||
if (!isNullish(transaction.gasPrice) || !isNullish(gasPrice)) { | ||
const convertedTransactionGasPrice = format({ format: 'uint' }, (_a = transaction.gasPrice) !== null && _a !== void 0 ? _a : gasPrice, returnFormat); | ||
return { | ||
@@ -49,5 +54,5 @@ maxPriorityFeePerGas: convertedTransactionGasPrice, | ||
return { | ||
maxPriorityFeePerGas: format({ format: 'uint' }, (_a = transaction.maxPriorityFeePerGas) !== null && _a !== void 0 ? _a : web3Context.defaultMaxPriorityFeePerGas, returnFormat), | ||
maxFeePerGas: format({ format: 'uint' }, ((_b = transaction.maxFeePerGas) !== null && _b !== void 0 ? _b : BigInt(block.baseFeePerGas) * BigInt(2) + | ||
BigInt((_c = transaction.maxPriorityFeePerGas) !== null && _c !== void 0 ? _c : web3Context.defaultMaxPriorityFeePerGas)), returnFormat), | ||
maxPriorityFeePerGas: format({ format: 'uint' }, (_b = transaction.maxPriorityFeePerGas) !== null && _b !== void 0 ? _b : web3Context.defaultMaxPriorityFeePerGas, returnFormat), | ||
maxFeePerGas: format({ format: 'uint' }, ((_c = transaction.maxFeePerGas) !== null && _c !== void 0 ? _c : BigInt(block.baseFeePerGas) * BigInt(2) + | ||
BigInt((_d = transaction.maxPriorityFeePerGas) !== null && _d !== void 0 ? _d : web3Context.defaultMaxPriorityFeePerGas)), returnFormat), | ||
}; | ||
@@ -54,0 +59,0 @@ }); |
@@ -69,3 +69,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (this.options.checkRevertBeforeSending !== false) { | ||
const reason = yield getRevertReason(this.web3Context, tx, this.options.contractAbi); | ||
let formatTx = tx; | ||
if (isNullish(tx.data) && isNullish(tx.input) && isNullish(tx.gas)) { // eth.call runs into error if data isnt filled and gas is not defined, its a simple transaction so we fill it with 21000 | ||
formatTx = Object.assign(Object.assign({}, tx), { gas: 21000 }); | ||
} | ||
const reason = yield getRevertReason(this.web3Context, formatTx, this.options.contractAbi); | ||
if (reason !== undefined) { | ||
@@ -72,0 +76,0 @@ throw yield getTransactionError(this.web3Context, tx, undefined, undefined, this.options.contractAbi, reason); |
{ | ||
"name": "web3-eth", | ||
"version": "4.6.1-dev.f44dc5b.0+f44dc5b", | ||
"version": "4.6.1-dev.f4e55bd.0+f4e55bd", | ||
"description": "Web3 module to interact with the Ethereum blockchain and smart contracts.", | ||
@@ -62,18 +62,18 @@ "main": "./lib/commonjs/index.js", | ||
"typescript": "^4.7.4", | ||
"web3-providers-http": "4.1.1-dev.f44dc5b.0+f44dc5b" | ||
"web3-providers-http": "4.1.1-dev.f4e55bd.0+f4e55bd" | ||
}, | ||
"dependencies": { | ||
"setimmediate": "^1.0.5", | ||
"web3-core": "4.3.3-dev.f44dc5b.0+f44dc5b", | ||
"web3-errors": "1.1.5-dev.f44dc5b.0+f44dc5b", | ||
"web3-eth-abi": "4.2.2-dev.f44dc5b.0+f44dc5b", | ||
"web3-eth-accounts": "4.1.3-dev.f44dc5b.0+f44dc5b", | ||
"web3-net": "4.0.8-dev.f44dc5b.0+f44dc5b", | ||
"web3-providers-ws": "4.0.8-dev.f44dc5b.0+f44dc5b", | ||
"web3-rpc-methods": "1.2.1-dev.f44dc5b.0+f44dc5b", | ||
"web3-types": "1.6.1-dev.f44dc5b.0+f44dc5b", | ||
"web3-utils": "4.2.4-dev.f44dc5b.0+f44dc5b", | ||
"web3-validator": "2.0.6-dev.f44dc5b.0+f44dc5b" | ||
"web3-core": "4.3.3-dev.f4e55bd.0+f4e55bd", | ||
"web3-errors": "1.1.5-dev.f4e55bd.0+f4e55bd", | ||
"web3-eth-abi": "4.2.2-dev.f4e55bd.0+f4e55bd", | ||
"web3-eth-accounts": "4.1.3-dev.f4e55bd.0+f4e55bd", | ||
"web3-net": "4.0.8-dev.f4e55bd.0+f4e55bd", | ||
"web3-providers-ws": "4.0.8-dev.f4e55bd.0+f4e55bd", | ||
"web3-rpc-methods": "1.2.1-dev.f4e55bd.0+f4e55bd", | ||
"web3-types": "1.6.1-dev.f4e55bd.0+f4e55bd", | ||
"web3-utils": "4.2.4-dev.f4e55bd.0+f4e55bd", | ||
"web3-validator": "2.0.6-dev.f4e55bd.0+f4e55bd" | ||
}, | ||
"gitHead": "f44dc5b6ad00648bff4abfc4339386ed6076275a" | ||
"gitHead": "f4e55bd30441b8e69c822d5ff1c6041291fd5a09" | ||
} |
@@ -41,10 +41,13 @@ /* | ||
): Promise<FormatType<{ maxPriorityFeePerGas?: Numbers; maxFeePerGas?: Numbers }, ReturnFormat>> { | ||
const block = await getBlock(web3Context, web3Context.defaultBlock, false, returnFormat); | ||
const block = await getBlock(web3Context, web3Context.defaultBlock, false, ETH_DATA_FORMAT); | ||
if (isNullish(block.baseFeePerGas)) throw new Eip1559NotSupportedError(); | ||
if (!isNullish(transaction.gasPrice)) { | ||
let gasPrice: Numbers | undefined; | ||
if (isNullish(transaction.gasPrice) && BigInt(block.baseFeePerGas) === BigInt(0)) { | ||
gasPrice = await getGasPrice(web3Context, returnFormat); | ||
} | ||
if (!isNullish(transaction.gasPrice) || !isNullish(gasPrice)) { | ||
const convertedTransactionGasPrice = format( | ||
{ format: 'uint' }, | ||
transaction.gasPrice as Numbers, | ||
transaction.gasPrice ?? gasPrice, | ||
returnFormat, | ||
@@ -51,0 +54,0 @@ ); |
@@ -125,3 +125,10 @@ /* | ||
if (this.options.checkRevertBeforeSending !== false) { | ||
const reason = await getRevertReason(this.web3Context, tx, this.options.contractAbi); | ||
let formatTx = tx; | ||
if (isNullish(tx.data) && isNullish(tx.input) && isNullish(tx.gas)) { // eth.call runs into error if data isnt filled and gas is not defined, its a simple transaction so we fill it with 21000 | ||
formatTx = { | ||
...tx, | ||
gas: 21000 | ||
} | ||
} | ||
const reason = await getRevertReason(this.web3Context, formatTx, this.options.contractAbi); | ||
if (reason !== undefined) { | ||
@@ -128,0 +135,0 @@ throw await getTransactionError<ReturnFormat>( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1314113
23293