Comparing version 4.8.3-dev.9b32205.0 to 4.8.3-dev.a21078b.0
@@ -276,2 +276,3 @@ "use strict"; | ||
: (0, format_transaction_js_1.formatTransaction)(response, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -290,2 +291,3 @@ }); | ||
return response.map(transaction => (0, format_transaction_js_1.formatTransaction)(transaction, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -317,2 +319,3 @@ })); | ||
: (0, format_transaction_js_1.formatTransaction)(response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -336,3 +339,6 @@ }); | ||
// geth indexing error, we poll until transactions stopped indexing | ||
if (typeof error === 'object' && !(0, web3_validator_1.isNullish)(error) && 'message' in error && error.message === 'transaction indexing is in progress') { | ||
if (typeof error === 'object' && | ||
!(0, web3_validator_1.isNullish)(error) && | ||
'message' in error && | ||
error.message === 'transaction indexing is in progress') { | ||
console.warn('Transaction indexing is in progress.'); | ||
@@ -346,3 +352,3 @@ } | ||
? response | ||
: ((0, web3_utils_1.format)(schemas_js_1.transactionReceiptSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat)); | ||
: (0, web3_utils_1.format)(schemas_js_1.transactionReceiptSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat); | ||
}); | ||
@@ -383,3 +389,5 @@ } | ||
} | ||
let transactionFormatted = (0, format_transaction_js_1.formatTransaction)(Object.assign(Object.assign({}, transaction), { from: (0, transaction_builder_js_1.getTransactionFromOrToAttr)('from', web3Context, transaction), to: (0, transaction_builder_js_1.getTransactionFromOrToAttr)('to', web3Context, transaction) }), web3_types_1.ETH_DATA_FORMAT); | ||
let transactionFormatted = (0, format_transaction_js_1.formatTransaction)(Object.assign(Object.assign({}, transaction), { from: (0, transaction_builder_js_1.getTransactionFromOrToAttr)('from', web3Context, transaction), to: (0, transaction_builder_js_1.getTransactionFromOrToAttr)('to', web3Context, transaction) }), web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
try { | ||
@@ -514,3 +522,5 @@ transactionFormatted = yield sendTxHelper.populateGasPrice({ | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield web3_rpc_methods_1.ethRpcMethods.signTransaction(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT)); | ||
const response = yield web3_rpc_methods_1.ethRpcMethods.signTransaction(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
})); | ||
// Some clients only return the encoded signed transaction (e.g. Ganache) | ||
@@ -525,2 +535,3 @@ // while clients such as Geth return the desired SignedTransactionInfoAPI object | ||
tx: (0, format_transaction_js_1.formatTransaction)(response.tx, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -543,3 +554,5 @@ }), | ||
: (0, web3_utils_1.format)({ format: 'uint' }, blockNumber, web3_types_1.ETH_DATA_FORMAT); | ||
const response = yield web3_rpc_methods_1.ethRpcMethods.call(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT), blockNumberFormatted); | ||
const response = yield web3_rpc_methods_1.ethRpcMethods.call(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), blockNumberFormatted); | ||
return (0, web3_utils_1.format)({ format: 'bytes' }, response, returnFormat); | ||
@@ -556,3 +569,5 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const transactionFormatted = (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT); | ||
const transactionFormatted = (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
const blockNumberFormatted = (0, web3_validator_1.isBlockTag)(blockNumber) | ||
@@ -657,3 +672,5 @@ ? blockNumber | ||
: (0, web3_utils_1.format)({ format: 'uint' }, blockNumber, web3_types_1.ETH_DATA_FORMAT); | ||
const response = (yield web3_rpc_methods_1.ethRpcMethods.createAccessList(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT), blockNumberFormatted)); | ||
const response = (yield web3_rpc_methods_1.ethRpcMethods.createAccessList(web3Context.requestManager, (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), blockNumberFormatted)); | ||
return (0, web3_utils_1.format)(schemas_js_1.accessListResultSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat); | ||
@@ -660,0 +677,0 @@ }); |
import { ContractExecutionError, TransactionRevertedWithoutReasonError, TransactionRevertInstructionError, TransactionRevertWithCustomError, InvalidResponseError, TransactionPollingTimeoutError } from 'web3-errors'; | ||
import { FormatType, ETH_DATA_FORMAT, DataFormat, Bytes, ContractAbi, HexString, Numbers, Transaction, TransactionReceipt, TransactionWithFromAndToLocalWalletIndex, TransactionWithFromLocalWalletIndex, TransactionWithToLocalWalletIndex } from 'web3-types'; | ||
import { Schema } from 'web3-validator'; | ||
export declare type InternalTransaction = FormatType<Transaction, typeof ETH_DATA_FORMAT>; | ||
@@ -46,1 +47,5 @@ export declare type SendTransactionEventsBase<ReturnFormat extends DataFormat, TxType> = { | ||
} | ||
export declare type CustomTransactionSchema = { | ||
type: string; | ||
properties: Record<string, Schema>; | ||
}; |
import { DataFormat, HexStringBytes, SignedTransactionInfoAPI } from 'web3-types'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
/** | ||
@@ -11,2 +12,3 @@ * Decodes an [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/#top) encoded transaction. | ||
fillInputAndData?: boolean; | ||
transactionSchema?: CustomTransactionSchema; | ||
}): SignedTransactionInfoAPI; |
@@ -15,6 +15,11 @@ "use strict"; | ||
*/ | ||
function decodeSignedTransaction(encodedSignedTransaction, returnFormat, options = { fillInputAndData: false }) { | ||
function decodeSignedTransaction(encodedSignedTransaction, returnFormat, options = { | ||
fillInputAndData: false, | ||
}) { | ||
return { | ||
raw: (0, web3_utils_1.format)({ format: 'bytes' }, encodedSignedTransaction, returnFormat), | ||
tx: (0, format_transaction_js_1.formatTransaction)(Object.assign(Object.assign({}, web3_eth_accounts_1.TransactionFactory.fromSerializedData((0, web3_utils_1.hexToBytes)(encodedSignedTransaction)).toJSON()), { hash: (0, web3_utils_1.bytesToHex)((0, web3_utils_1.keccak256)((0, web3_utils_1.hexToBytes)(encodedSignedTransaction))), type: (0, detect_transaction_type_js_1.detectRawTransactionType)((0, web3_utils_1.hexToBytes)(encodedSignedTransaction)) }), returnFormat, { fillInputAndData: options.fillInputAndData }), | ||
tx: (0, format_transaction_js_1.formatTransaction)(Object.assign(Object.assign({}, web3_eth_accounts_1.TransactionFactory.fromSerializedData((0, web3_utils_1.hexToBytes)(encodedSignedTransaction)).toJSON()), { hash: (0, web3_utils_1.bytesToHex)((0, web3_utils_1.keccak256)((0, web3_utils_1.hexToBytes)(encodedSignedTransaction))), type: (0, detect_transaction_type_js_1.detectRawTransactionType)((0, web3_utils_1.hexToBytes)(encodedSignedTransaction)) }), returnFormat, { | ||
fillInputAndData: options.fillInputAndData, | ||
transactionSchema: options.transactionSchema, | ||
}), | ||
}; | ||
@@ -21,0 +26,0 @@ } |
@@ -70,3 +70,3 @@ "use strict"; | ||
}; | ||
const defaultTransactionTypeParser = (transaction) => { | ||
const defaultTransactionTypeParser = transaction => { | ||
var _a, _b; | ||
@@ -73,0 +73,0 @@ const tx = transaction; |
import { Transaction, DataFormat, DEFAULT_RETURN_FORMAT, FormatType } from 'web3-types'; | ||
import { ValidationSchemaInput } from 'web3-validator'; | ||
import { transactionSchema } from '../schemas.js'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
export declare function formatTransaction<ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT, TransactionType extends Transaction = Transaction>(transaction: TransactionType, returnFormat?: ReturnFormat, options?: { | ||
transactionSchema?: ValidationSchemaInput | typeof transactionSchema; | ||
transactionSchema?: ValidationSchemaInput | CustomTransactionSchema | undefined; | ||
fillInputAndData?: boolean; | ||
}): FormatType<TransactionType, ReturnFormat>; |
@@ -106,4 +106,8 @@ "use strict"; | ||
})); | ||
const formattedTransaction = (0, format_transaction_js_1.formatTransaction)(populatedTransaction, web3_types_1.ETH_DATA_FORMAT); | ||
(0, validation_js_1.validateTransactionForSigning)(formattedTransaction); | ||
const formattedTransaction = (0, format_transaction_js_1.formatTransaction)(populatedTransaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
(0, validation_js_1.validateTransactionForSigning)(formattedTransaction, undefined, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
return web3_eth_accounts_1.TransactionFactory.fromTxData(getEthereumjsTxDataFromTransaction(formattedTransaction), getEthereumjsTransactionOptions(formattedTransaction, web3Context)); | ||
@@ -110,0 +114,0 @@ }); |
@@ -73,3 +73,4 @@ "use strict"; | ||
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 | ||
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 }); | ||
@@ -76,0 +77,0 @@ } |
import { AccessList, AccessListEntry, BaseTransactionAPI, Transaction1559UnsignedAPI, Transaction2930UnsignedAPI, TransactionCall, TransactionLegacyUnsignedAPI, TransactionWithSenderAPI } from 'web3-types'; | ||
import { InternalTransaction } from './types.js'; | ||
import { CustomTransactionSchema, InternalTransaction } from './types.js'; | ||
export declare function isBaseTransaction(value: BaseTransactionAPI): boolean; | ||
@@ -24,2 +24,4 @@ export declare function isAccessListEntry(value: AccessListEntry): boolean; | ||
export declare const validateGas: (transaction: InternalTransaction) => void; | ||
export declare const validateTransactionForSigning: (transaction: InternalTransaction, overrideMethod?: ((transaction: InternalTransaction) => void) | undefined) => void; | ||
export declare const validateTransactionForSigning: (transaction: InternalTransaction, overrideMethod?: ((transaction: InternalTransaction) => void) | undefined, options?: { | ||
transactionSchema?: CustomTransactionSchema; | ||
}) => void; |
@@ -256,3 +256,3 @@ "use strict"; | ||
exports.validateGas = validateGas; | ||
const validateTransactionForSigning = (transaction, overrideMethod) => { | ||
const validateTransactionForSigning = (transaction, overrideMethod, options = { transactionSchema: undefined }) => { | ||
if (!(0, web3_validator_1.isNullish)(overrideMethod)) { | ||
@@ -268,3 +268,5 @@ overrideMethod(transaction); | ||
(0, exports.validateHardfork)(transaction); | ||
const formattedTransaction = (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT); | ||
const formattedTransaction = (0, format_transaction_js_1.formatTransaction)(transaction, web3_types_1.ETH_DATA_FORMAT, { | ||
transactionSchema: options.transactionSchema, | ||
}); | ||
(0, exports.validateGas)(formattedTransaction); | ||
@@ -271,0 +273,0 @@ if ((0, web3_validator_1.isNullish)(formattedTransaction.nonce) || |
@@ -258,2 +258,3 @@ /* | ||
: formatTransaction(response, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -271,2 +272,3 @@ }); | ||
return response.map(transaction => formatTransaction(transaction, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -297,2 +299,3 @@ })); | ||
: formatTransaction(response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -315,3 +318,6 @@ }); | ||
// geth indexing error, we poll until transactions stopped indexing | ||
if (typeof error === 'object' && !isNullish(error) && 'message' in error && error.message === 'transaction indexing is in progress') { | ||
if (typeof error === 'object' && | ||
!isNullish(error) && | ||
'message' in error && | ||
error.message === 'transaction indexing is in progress') { | ||
console.warn('Transaction indexing is in progress.'); | ||
@@ -325,3 +331,3 @@ } | ||
? response | ||
: (format(transactionReceiptSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat)); | ||
: format(transactionReceiptSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat); | ||
}); | ||
@@ -360,3 +366,5 @@ } | ||
} | ||
let transactionFormatted = formatTransaction(Object.assign(Object.assign({}, transaction), { from: getTransactionFromOrToAttr('from', web3Context, transaction), to: getTransactionFromOrToAttr('to', web3Context, transaction) }), ETH_DATA_FORMAT); | ||
let transactionFormatted = formatTransaction(Object.assign(Object.assign({}, transaction), { from: getTransactionFromOrToAttr('from', web3Context, transaction), to: getTransactionFromOrToAttr('to', web3Context, transaction) }), ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
try { | ||
@@ -488,3 +496,5 @@ transactionFormatted = yield sendTxHelper.populateGasPrice({ | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield ethRpcMethods.signTransaction(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT)); | ||
const response = yield ethRpcMethods.signTransaction(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
})); | ||
// Some clients only return the encoded signed transaction (e.g. Ganache) | ||
@@ -499,2 +509,3 @@ // while clients such as Geth return the desired SignedTransactionInfoAPI object | ||
tx: formatTransaction(response.tx, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -516,3 +527,5 @@ }), | ||
: format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT); | ||
const response = yield ethRpcMethods.call(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT), blockNumberFormatted); | ||
const response = yield ethRpcMethods.call(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), blockNumberFormatted); | ||
return format({ format: 'bytes' }, response, returnFormat); | ||
@@ -528,3 +541,5 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const transactionFormatted = formatTransaction(transaction, ETH_DATA_FORMAT); | ||
const transactionFormatted = formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
const blockNumberFormatted = isBlockTag(blockNumber) | ||
@@ -624,3 +639,5 @@ ? blockNumber | ||
: format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT); | ||
const response = (yield ethRpcMethods.createAccessList(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT), blockNumberFormatted)); | ||
const response = (yield ethRpcMethods.createAccessList(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), blockNumberFormatted)); | ||
return format(accessListResultSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat); | ||
@@ -627,0 +644,0 @@ }); |
@@ -12,8 +12,13 @@ import { bytesToHex, format, hexToBytes, keccak256 } from 'web3-utils'; | ||
*/ | ||
export function decodeSignedTransaction(encodedSignedTransaction, returnFormat, options = { fillInputAndData: false }) { | ||
export function decodeSignedTransaction(encodedSignedTransaction, returnFormat, options = { | ||
fillInputAndData: false, | ||
}) { | ||
return { | ||
raw: format({ format: 'bytes' }, encodedSignedTransaction, returnFormat), | ||
tx: formatTransaction(Object.assign(Object.assign({}, TransactionFactory.fromSerializedData(hexToBytes(encodedSignedTransaction)).toJSON()), { hash: bytesToHex(keccak256(hexToBytes(encodedSignedTransaction))), type: detectRawTransactionType(hexToBytes(encodedSignedTransaction)) }), returnFormat, { fillInputAndData: options.fillInputAndData }), | ||
tx: formatTransaction(Object.assign(Object.assign({}, TransactionFactory.fromSerializedData(hexToBytes(encodedSignedTransaction)).toJSON()), { hash: bytesToHex(keccak256(hexToBytes(encodedSignedTransaction))), type: detectRawTransactionType(hexToBytes(encodedSignedTransaction)) }), returnFormat, { | ||
fillInputAndData: options.fillInputAndData, | ||
transactionSchema: options.transactionSchema, | ||
}), | ||
}; | ||
} | ||
//# sourceMappingURL=decode_signed_transaction.js.map |
@@ -67,3 +67,3 @@ /* | ||
}; | ||
export const defaultTransactionTypeParser = (transaction) => { | ||
export const defaultTransactionTypeParser = transaction => { | ||
var _a, _b; | ||
@@ -70,0 +70,0 @@ const tx = transaction; |
@@ -103,6 +103,10 @@ /* | ||
})); | ||
const formattedTransaction = formatTransaction(populatedTransaction, ETH_DATA_FORMAT); | ||
validateTransactionForSigning(formattedTransaction); | ||
const formattedTransaction = formatTransaction(populatedTransaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
validateTransactionForSigning(formattedTransaction, undefined, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
return TransactionFactory.fromTxData(getEthereumjsTxDataFromTransaction(formattedTransaction), getEthereumjsTransactionOptions(formattedTransaction, web3Context)); | ||
}); | ||
//# sourceMappingURL=prepare_transaction_for_signing.js.map |
@@ -70,3 +70,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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 | ||
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 }); | ||
@@ -73,0 +74,0 @@ } |
@@ -18,3 +18,3 @@ /* | ||
import { ETH_DATA_FORMAT, } from 'web3-types'; | ||
import { isAddress, isHexStrict, isHexString32Bytes, isNullish, isUInt } from 'web3-validator'; | ||
import { isAddress, isHexStrict, isHexString32Bytes, isNullish, isUInt, } from 'web3-validator'; | ||
import { ChainMismatchError, HardforkMismatchError, ChainIdMismatchError, CommonOrChainAndHardforkError, Eip1559GasPriceError, InvalidGasOrGasPrice, InvalidMaxPriorityFeePerGasOrMaxFeePerGas, InvalidNonceOrChainIdError, InvalidTransactionCall, InvalidTransactionObjectError, InvalidTransactionWithSender, MissingChainOrHardforkError, MissingCustomChainError, MissingCustomChainIdError, MissingGasError, TransactionGasMismatchError, UnsupportedFeeMarketError, } from 'web3-errors'; | ||
@@ -237,3 +237,3 @@ import { formatTransaction } from './utils/format_transaction.js'; | ||
}; | ||
export const validateTransactionForSigning = (transaction, overrideMethod) => { | ||
export const validateTransactionForSigning = (transaction, overrideMethod, options = { transactionSchema: undefined }) => { | ||
if (!isNullish(overrideMethod)) { | ||
@@ -249,3 +249,5 @@ overrideMethod(transaction); | ||
validateHardfork(transaction); | ||
const formattedTransaction = formatTransaction(transaction, ETH_DATA_FORMAT); | ||
const formattedTransaction = formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: options.transactionSchema, | ||
}); | ||
validateGas(formattedTransaction); | ||
@@ -252,0 +254,0 @@ if (isNullish(formattedTransaction.nonce) || |
import { ContractExecutionError, TransactionRevertedWithoutReasonError, TransactionRevertInstructionError, TransactionRevertWithCustomError, InvalidResponseError, TransactionPollingTimeoutError } from 'web3-errors'; | ||
import { FormatType, ETH_DATA_FORMAT, DataFormat, Bytes, ContractAbi, HexString, Numbers, Transaction, TransactionReceipt, TransactionWithFromAndToLocalWalletIndex, TransactionWithFromLocalWalletIndex, TransactionWithToLocalWalletIndex } from 'web3-types'; | ||
import { Schema } from 'web3-validator'; | ||
export declare type InternalTransaction = FormatType<Transaction, typeof ETH_DATA_FORMAT>; | ||
@@ -46,2 +47,6 @@ export declare type SendTransactionEventsBase<ReturnFormat extends DataFormat, TxType> = { | ||
} | ||
export declare type CustomTransactionSchema = { | ||
type: string; | ||
properties: Record<string, Schema>; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
import { DataFormat, HexStringBytes, SignedTransactionInfoAPI } from 'web3-types'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
/** | ||
@@ -11,3 +12,4 @@ * Decodes an [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/#top) encoded transaction. | ||
fillInputAndData?: boolean; | ||
transactionSchema?: CustomTransactionSchema; | ||
}): SignedTransactionInfoAPI; | ||
//# sourceMappingURL=decode_signed_transaction.d.ts.map |
import { Transaction, DataFormat, DEFAULT_RETURN_FORMAT, FormatType } from 'web3-types'; | ||
import { ValidationSchemaInput } from 'web3-validator'; | ||
import { transactionSchema } from '../schemas.js'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
export declare function formatTransaction<ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT, TransactionType extends Transaction = Transaction>(transaction: TransactionType, returnFormat?: ReturnFormat, options?: { | ||
transactionSchema?: ValidationSchemaInput | typeof transactionSchema; | ||
transactionSchema?: ValidationSchemaInput | CustomTransactionSchema | undefined; | ||
fillInputAndData?: boolean; | ||
}): FormatType<TransactionType, ReturnFormat>; | ||
//# sourceMappingURL=format_transaction.d.ts.map |
import { AccessList, AccessListEntry, BaseTransactionAPI, Transaction1559UnsignedAPI, Transaction2930UnsignedAPI, TransactionCall, TransactionLegacyUnsignedAPI, TransactionWithSenderAPI } from 'web3-types'; | ||
import { InternalTransaction } from './types.js'; | ||
import { CustomTransactionSchema, InternalTransaction } from './types.js'; | ||
export declare function isBaseTransaction(value: BaseTransactionAPI): boolean; | ||
@@ -24,3 +24,5 @@ export declare function isAccessListEntry(value: AccessListEntry): boolean; | ||
export declare const validateGas: (transaction: InternalTransaction) => void; | ||
export declare const validateTransactionForSigning: (transaction: InternalTransaction, overrideMethod?: ((transaction: InternalTransaction) => void) | undefined) => void; | ||
export declare const validateTransactionForSigning: (transaction: InternalTransaction, overrideMethod?: ((transaction: InternalTransaction) => void) | undefined, options?: { | ||
transactionSchema?: CustomTransactionSchema; | ||
}) => void; | ||
//# sourceMappingURL=validation.d.ts.map |
{ | ||
"name": "web3-eth", | ||
"version": "4.8.3-dev.9b32205.0+9b32205", | ||
"version": "4.8.3-dev.a21078b.0+a21078b", | ||
"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.2.1-dev.9b32205.0+9b32205" | ||
"web3-providers-http": "4.2.1-dev.a21078b.0+a21078b" | ||
}, | ||
"dependencies": { | ||
"setimmediate": "^1.0.5", | ||
"web3-core": "4.5.2-dev.9b32205.0+9b32205", | ||
"web3-errors": "1.3.1-dev.9b32205.0+9b32205", | ||
"web3-eth-abi": "4.2.4-dev.9b32205.0+9b32205", | ||
"web3-eth-accounts": "4.2.2-dev.9b32205.0+9b32205", | ||
"web3-net": "4.1.1-dev.9b32205.0+9b32205", | ||
"web3-providers-ws": "4.0.9-dev.9b32205.0+9b32205", | ||
"web3-rpc-methods": "1.3.1-dev.9b32205.0+9b32205", | ||
"web3-types": "1.7.1-dev.9b32205.0+9b32205", | ||
"web3-utils": "4.3.2-dev.9b32205.0+9b32205", | ||
"web3-validator": "2.0.7-dev.9b32205.0+9b32205" | ||
"web3-core": "4.5.2-dev.a21078b.0+a21078b", | ||
"web3-errors": "1.3.1-dev.a21078b.0+a21078b", | ||
"web3-eth-abi": "4.2.4-dev.a21078b.0+a21078b", | ||
"web3-eth-accounts": "4.2.2-dev.a21078b.0+a21078b", | ||
"web3-net": "4.1.1-dev.a21078b.0+a21078b", | ||
"web3-providers-ws": "4.0.9-dev.a21078b.0+a21078b", | ||
"web3-rpc-methods": "1.3.1-dev.a21078b.0+a21078b", | ||
"web3-types": "1.7.1-dev.a21078b.0+a21078b", | ||
"web3-utils": "4.3.2-dev.a21078b.0+a21078b", | ||
"web3-validator": "2.0.7-dev.a21078b.0+a21078b" | ||
}, | ||
"gitHead": "9b322052ef266cc57b29080b20053991e0c9a0a9" | ||
"gitHead": "a21078b9c5bec437340296f519133b0ddbbc83ce" | ||
} |
@@ -299,6 +299,6 @@ /* | ||
transactions: res.transactions ?? [], | ||
} | ||
}; | ||
return result; | ||
} | ||
return res; | ||
@@ -433,2 +433,3 @@ } | ||
: formatTransaction(response, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -453,2 +454,3 @@ }); | ||
{ | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -494,2 +496,3 @@ }, | ||
: formatTransaction(response, returnFormat ?? web3Context.defaultReturnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -515,3 +518,3 @@ }); | ||
try { | ||
response = await ethRpcMethods.getTransactionReceipt( | ||
response = await ethRpcMethods.getTransactionReceipt( | ||
web3Context.requestManager, | ||
@@ -522,16 +525,20 @@ transactionHashFormatted, | ||
// geth indexing error, we poll until transactions stopped indexing | ||
if (typeof error === 'object' && !isNullish(error) && 'message' in error && (error as { message: string }).message === 'transaction indexing is in progress') { | ||
console.warn('Transaction indexing is in progress.') | ||
if ( | ||
typeof error === 'object' && | ||
!isNullish(error) && | ||
'message' in error && | ||
(error as { message: string }).message === 'transaction indexing is in progress' | ||
) { | ||
console.warn('Transaction indexing is in progress.'); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
return isNullish(response) | ||
? response | ||
: (format( | ||
: format( | ||
transactionReceiptSchema, | ||
response as unknown as TransactionReceipt, | ||
returnFormat ?? web3Context.defaultReturnFormat, | ||
)); | ||
); | ||
} | ||
@@ -581,3 +588,3 @@ | ||
options: SendTransactionOptions<ResolveType> = { checkRevertBeforeSending: true }, | ||
transactionMiddleware?: TransactionMiddleware | ||
transactionMiddleware?: TransactionMiddleware, | ||
): Web3PromiEvent<ResolveType, SendTransactionEvents<ReturnFormat>> { | ||
@@ -595,5 +602,5 @@ const promiEvent = new Web3PromiEvent<ResolveType, SendTransactionEvents<ReturnFormat>>( | ||
let transaction = {...transactionObj}; | ||
if(!isNullish(transactionMiddleware)){ | ||
let transaction = { ...transactionObj }; | ||
if (!isNullish(transactionMiddleware)) { | ||
transaction = await transactionMiddleware.processTransaction(transaction); | ||
@@ -613,2 +620,5 @@ } | ||
ETH_DATA_FORMAT, | ||
{ | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}, | ||
); | ||
@@ -855,3 +865,5 @@ | ||
web3Context.requestManager, | ||
formatTransaction(transaction, ETH_DATA_FORMAT), | ||
formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), | ||
); | ||
@@ -871,2 +883,3 @@ // Some clients only return the encoded signed transaction (e.g. Ganache) | ||
tx: formatTransaction((response as SignedTransactionInfoAPI).tx, returnFormat, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
fillInputAndData: true, | ||
@@ -895,3 +908,5 @@ }), | ||
web3Context.requestManager, | ||
formatTransaction(transaction, ETH_DATA_FORMAT), | ||
formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), | ||
blockNumberFormatted, | ||
@@ -914,3 +929,5 @@ ); | ||
) { | ||
const transactionFormatted = formatTransaction(transaction, ETH_DATA_FORMAT); | ||
const transactionFormatted = formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}); | ||
const blockNumberFormatted = isBlockTag(blockNumber as string) | ||
@@ -1086,3 +1103,5 @@ ? (blockNumber as BlockTag) | ||
web3Context.requestManager, | ||
formatTransaction(transaction, ETH_DATA_FORMAT), | ||
formatTransaction(transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}), | ||
blockNumberFormatted, | ||
@@ -1089,0 +1108,0 @@ )) as unknown as AccessListResult; |
@@ -260,6 +260,6 @@ /* | ||
properties: { | ||
baseFeePerGas: { | ||
baseFeePerGas: { | ||
format: 'uint', | ||
}, | ||
blobGasUsed: { | ||
blobGasUsed: { | ||
format: 'uint', | ||
@@ -349,3 +349,3 @@ }, | ||
}, | ||
withdrawals: { | ||
withdrawals: { | ||
type: 'array', | ||
@@ -356,3 +356,3 @@ items: { | ||
}, | ||
withdrawalsRoot: { | ||
withdrawalsRoot: { | ||
format: 'bytes32', | ||
@@ -366,12 +366,12 @@ }, | ||
properties: { | ||
author: { | ||
author: { | ||
format: 'bytes32', | ||
}, | ||
excessDataGas: { | ||
excessDataGas: { | ||
format: 'uint', | ||
}, | ||
baseFeePerGas: { | ||
baseFeePerGas: { | ||
format: 'uint', | ||
}, | ||
blobGasUsed: { | ||
blobGasUsed: { | ||
format: 'uint', | ||
@@ -451,3 +451,3 @@ }, | ||
}, | ||
withdrawals: { | ||
withdrawals: { | ||
type: 'array', | ||
@@ -458,3 +458,3 @@ items: { | ||
}, | ||
withdrawalsRoot: { | ||
withdrawalsRoot: { | ||
format: 'bytes32', | ||
@@ -461,0 +461,0 @@ }, |
@@ -40,2 +40,3 @@ /* | ||
} from 'web3-types'; | ||
import { Schema } from 'web3-validator'; | ||
@@ -96,14 +97,19 @@ export type InternalTransaction = FormatType<Transaction, typeof ETH_DATA_FORMAT>; | ||
export type TransactionMiddlewareData = Transaction | ||
| TransactionWithFromLocalWalletIndex | ||
| TransactionWithToLocalWalletIndex | ||
| TransactionWithFromAndToLocalWalletIndex; | ||
export type TransactionMiddlewareData = | ||
| Transaction | ||
| TransactionWithFromLocalWalletIndex | ||
| TransactionWithToLocalWalletIndex | ||
| TransactionWithFromAndToLocalWalletIndex; | ||
export interface TransactionMiddleware{ | ||
export interface TransactionMiddleware { | ||
// for transaction processing before signing | ||
processTransaction( | ||
transaction: TransactionMiddlewareData, | ||
transaction: TransactionMiddlewareData, | ||
options?: { [key: string]: unknown }, | ||
): Promise<TransactionMiddlewareData>; | ||
} | ||
} | ||
export type CustomTransactionSchema = { | ||
type: string; | ||
properties: Record<string, Schema>; | ||
}; |
@@ -27,2 +27,3 @@ /* | ||
import { formatTransaction } from './format_transaction.js'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
@@ -39,3 +40,5 @@ /** | ||
returnFormat: ReturnFormat, | ||
options: { fillInputAndData?: boolean } = { fillInputAndData: false }, | ||
options: { fillInputAndData?: boolean; transactionSchema?: CustomTransactionSchema } = { | ||
fillInputAndData: false, | ||
}, | ||
): SignedTransactionInfoAPI { | ||
@@ -53,5 +56,8 @@ return { | ||
returnFormat, | ||
{ fillInputAndData: options.fillInputAndData }, | ||
{ | ||
fillInputAndData: options.fillInputAndData, | ||
transactionSchema: options.transactionSchema, | ||
}, | ||
), | ||
}; | ||
} |
@@ -78,5 +78,3 @@ /* | ||
export const defaultTransactionTypeParser: TransactionTypeParser = ( | ||
transaction | ||
) => { | ||
export const defaultTransactionTypeParser: TransactionTypeParser = transaction => { | ||
const tx = transaction as unknown as Transaction; | ||
@@ -143,3 +141,3 @@ if (!isNullish(tx.type)) { | ||
(web3Context?.transactionTypeParser ?? defaultTransactionTypeParser)( | ||
transaction as unknown as Record<string, unknown> | ||
transaction as unknown as Record<string, unknown>, | ||
); | ||
@@ -146,0 +144,0 @@ |
@@ -23,3 +23,4 @@ /* | ||
import { transactionInfoSchema, transactionSchema } from '../schemas.js'; | ||
import { transactionInfoSchema } from '../schemas.js'; | ||
import { type CustomTransactionSchema } from '../types.js'; | ||
@@ -33,3 +34,3 @@ export function formatTransaction< | ||
options: { | ||
transactionSchema?: ValidationSchemaInput | typeof transactionSchema; | ||
transactionSchema?: ValidationSchemaInput | CustomTransactionSchema | undefined; | ||
fillInputAndData?: boolean; | ||
@@ -36,0 +37,0 @@ } = { |
@@ -137,10 +137,14 @@ /* | ||
})) as unknown as PopulatedUnsignedTransaction; | ||
const formattedTransaction = formatTransaction( | ||
populatedTransaction, | ||
ETH_DATA_FORMAT, | ||
) as unknown as FormatType<PopulatedUnsignedTransaction, typeof ETH_DATA_FORMAT>; | ||
const formattedTransaction = formatTransaction(populatedTransaction, ETH_DATA_FORMAT, { | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}) as unknown as FormatType<PopulatedUnsignedTransaction, typeof ETH_DATA_FORMAT>; | ||
validateTransactionForSigning( | ||
formattedTransaction as unknown as FormatType<Transaction, typeof ETH_DATA_FORMAT>, | ||
undefined, | ||
{ | ||
transactionSchema: web3Context.config.customTransactionSchema, | ||
}, | ||
); | ||
return TransactionFactory.fromTxData( | ||
@@ -147,0 +151,0 @@ getEthereumjsTxDataFromTransaction(formattedTransaction), |
@@ -37,21 +37,20 @@ /* | ||
const pollingInterval = web3Context.transactionPollingInterval; | ||
const [intervalId, promiseToError] = | ||
rejectIfConditionAtInterval(async () => { | ||
let lastBlockNumber; | ||
try { | ||
lastBlockNumber = await getBlockNumber(web3Context, NUMBER_DATA_FORMAT); | ||
} catch (error) { | ||
console.warn('An error happen while trying to get the block number', error); | ||
return undefined; | ||
} | ||
const numberOfBlocks = lastBlockNumber - starterBlockNumber; | ||
if (numberOfBlocks >= web3Context.transactionBlockTimeout) { | ||
return new TransactionBlockTimeoutError({ | ||
starterBlockNumber, | ||
numberOfBlocks, | ||
transactionHash, | ||
}); | ||
} | ||
const [intervalId, promiseToError] = rejectIfConditionAtInterval(async () => { | ||
let lastBlockNumber; | ||
try { | ||
lastBlockNumber = await getBlockNumber(web3Context, NUMBER_DATA_FORMAT); | ||
} catch (error) { | ||
console.warn('An error happen while trying to get the block number', error); | ||
return undefined; | ||
}, pollingInterval); | ||
} | ||
const numberOfBlocks = lastBlockNumber - starterBlockNumber; | ||
if (numberOfBlocks >= web3Context.transactionBlockTimeout) { | ||
return new TransactionBlockTimeoutError({ | ||
starterBlockNumber, | ||
numberOfBlocks, | ||
transactionHash, | ||
}); | ||
} | ||
return undefined; | ||
}, pollingInterval); | ||
@@ -58,0 +57,0 @@ const clean = () => { |
@@ -126,9 +126,14 @@ /* | ||
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 | ||
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 | ||
} | ||
gas: 21000, | ||
}; | ||
} | ||
const reason = await getRevertReason(this.web3Context, formatTx, this.options.contractAbi); | ||
const reason = await getRevertReason( | ||
this.web3Context, | ||
formatTx, | ||
this.options.contractAbi, | ||
); | ||
if (reason !== undefined) { | ||
@@ -135,0 +140,0 @@ throw await getTransactionError<ReturnFormat>( |
@@ -59,3 +59,3 @@ /* | ||
(async () => { | ||
if (confirmations >= web3Context.transactionConfirmationBlocks){ | ||
if (confirmations >= web3Context.transactionConfirmationBlocks) { | ||
clearInterval(intervalId); | ||
@@ -62,0 +62,0 @@ return; |
@@ -30,4 +30,10 @@ /* | ||
} from 'web3-types'; | ||
import { isAddress, isHexStrict, isHexString32Bytes, isNullish, isUInt } from 'web3-validator'; | ||
import { | ||
isAddress, | ||
isHexStrict, | ||
isHexString32Bytes, | ||
isNullish, | ||
isUInt, | ||
} from 'web3-validator'; | ||
import { | ||
ChainMismatchError, | ||
@@ -52,3 +58,3 @@ HardforkMismatchError, | ||
import { formatTransaction } from './utils/format_transaction.js'; | ||
import { InternalTransaction } from './types.js'; | ||
import { CustomTransactionSchema, InternalTransaction } from './types.js'; | ||
@@ -287,2 +293,5 @@ export function isBaseTransaction(value: BaseTransactionAPI): boolean { | ||
overrideMethod?: (transaction: InternalTransaction) => void, | ||
options: { | ||
transactionSchema?: CustomTransactionSchema; | ||
} = { transactionSchema: undefined }, | ||
) => { | ||
@@ -302,3 +311,5 @@ if (!isNullish(overrideMethod)) { | ||
const formattedTransaction = formatTransaction(transaction as Transaction, ETH_DATA_FORMAT); | ||
const formattedTransaction = formatTransaction(transaction as Transaction, ETH_DATA_FORMAT, { | ||
transactionSchema: options.transactionSchema, | ||
}); | ||
validateGas(formattedTransaction); | ||
@@ -305,0 +316,0 @@ |
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
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
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
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
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
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 too big to display
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
1338919
23745
24
46
3