Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-eth-contract

Package Overview
Dependencies
Maintainers
4
Versions
481
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-contract - npm Package Compare versions

Comparing version 4.7.1-dev.9edb183.0 to 4.7.1-dev.9fa32c9.0

lib/commonjs/contract_log_subscription.d.ts

3

lib/commonjs/contract-deployer-method-class.js

@@ -31,2 +31,3 @@ "use strict";

const web3_eth_1 = require("web3-eth");
const web3_eth_abi_1 = require("web3-eth-abi");
const web3_types_1 = require("web3-types");

@@ -129,3 +130,3 @@ const web3_utils_1 = require("web3-utils");

decodeData(data) {
return Object.assign(Object.assign({}, (0, encoding_js_1.decodeMethodParams)(this.constructorAbi, data.replace(this.deployData, ''), false)), { __method__: this.constructorAbi.type });
return Object.assign(Object.assign({}, (0, web3_eth_abi_1.decodeFunctionCall)(this.constructorAbi, data.replace(this.deployData, ''), false)), { __method__: this.constructorAbi.type });
}

@@ -132,0 +133,0 @@ }

import { Web3Context, Web3EventEmitter, Web3PromiEvent } from 'web3-core';
import { NewHeadsSubscription, SendTransactionEvents, TransactionMiddleware } from 'web3-eth';
import { AbiFunctionFragment, ContractAbi, ContractConstructorArgs, ContractEvent, ContractEvents, ContractMethod, ContractMethodInputParameters, ContractMethodOutputParameters, Address, EthExecutionAPI, Filter, FilterAbis, HexString, ContractInitOptions, NonPayableCallOptions, PayableCallOptions, DataFormat, DEFAULT_RETURN_FORMAT, EventLog, ContractOptions, TransactionReceipt, FormatType, DecodedParams } from 'web3-types';
import { LogsSubscription } from './log_subscription.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
import { ContractEventOptions, NonPayableMethodObject, PayableMethodObject, Web3ContractContext } from './types.js';
import { DeployerMethodClass } from './contract-deployer-method-class.js';
declare type ContractBoundMethod<Abi extends AbiFunctionFragment, Method extends ContractMethod<Abi> = ContractMethod<Abi>> = (...args: Method['Inputs'] extends undefined | unknown ? any[] : Method['Inputs']) => Method['Abi']['stateMutability'] extends 'payable' | 'pure' ? PayableMethodObject<Method['Inputs'], Method['Outputs']> : NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
import { ContractSubscriptionManager } from './contract-subscription-manager.js';
declare type ContractBoundMethod<Abi extends AbiFunctionFragment, Method extends ContractMethod<Abi> = ContractMethod<Abi>> = (...args: Abi extends undefined ? any[] : Method['Inputs'] extends never ? any[] : Method['Inputs']) => Method['Abi']['stateMutability'] extends 'payable' | 'pure' ? PayableMethodObject<Method['Inputs'], Method['Outputs']> : NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
export declare type ContractOverloadedMethodInputs<AbiArr extends ReadonlyArray<unknown>> = NonNullable<AbiArr extends readonly [] ? undefined : AbiArr extends readonly [infer A, ...infer R] ? A extends AbiFunctionFragment ? ContractMethodInputParameters<A['inputs']> | ContractOverloadedMethodInputs<R> : undefined : undefined>;

@@ -29,5 +30,5 @@ export declare type ContractOverloadedMethodOutputs<AbiArr extends ReadonlyArray<unknown>> = NonNullable<AbiArr extends readonly [] ? undefined : AbiArr extends readonly [infer A, ...infer R] ? A extends AbiFunctionFragment ? ContractMethodOutputParameters<A['outputs']> | ContractOverloadedMethodOutputs<R> : undefined : undefined>;

* @param options - The options used to subscribe for the event
* @returns - A Promise resolved with {@link LogsSubscription} object
* @returns - A Promise resolved with {@link ContractLogsSubscription} object
*/
export declare type ContractBoundEvent = (options?: ContractEventOptions) => LogsSubscription;
export declare type ContractBoundEvent = (options?: ContractEventOptions) => ContractLogsSubscription;
export declare type ContractEventsInterface<Abi extends ContractAbi, Events extends ContractEvents<Abi> = ContractEvents<Abi>> = {

@@ -44,6 +45,7 @@ [Name in keyof Events | 'allEvents']: ContractBoundEvent;

declare const contractSubscriptions: {
logs: typeof LogsSubscription;
logs: typeof ContractLogsSubscription;
newHeads: typeof NewHeadsSubscription;
newBlockHeaders: typeof NewHeadsSubscription;
};
declare type ContractSubscriptions = typeof contractSubscriptions;
/**

@@ -245,3 +247,5 @@ * The `web3.eth.Contract` makes it easy to interact with smart contracts on the ethereum blockchain.

*/
export declare class Contract<Abi extends ContractAbi> extends Web3Context<EthExecutionAPI, typeof contractSubscriptions> implements Web3EventEmitter<ContractEventEmitterInterface<Abi>> {
export declare class Contract<Abi extends ContractAbi> extends Web3Context<EthExecutionAPI, ContractSubscriptions> implements Web3EventEmitter<ContractEventEmitterInterface<Abi>> {
protected _subscriptionManager: ContractSubscriptionManager<EthExecutionAPI>;
get subscriptionManager(): ContractSubscriptionManager<EthExecutionAPI>;
/**

@@ -248,0 +252,0 @@ * The options `object` for the contract instance. `from`, `gas` and `gasPrice` are used as fallback values when sending transactions.

@@ -37,8 +37,10 @@ "use strict";

const encoding_js_1 = require("./encoding.js");
const log_subscription_js_1 = require("./log_subscription.js");
const contract_log_subscription_js_1 = require("./contract_log_subscription.js");
const utils_js_1 = require("./utils.js");
// eslint-disable-next-line import/no-cycle
const contract_deployer_method_class_js_1 = require("./contract-deployer-method-class.js");
// eslint-disable-next-line import/no-cycle
const contract_subscription_manager_js_1 = require("./contract-subscription-manager.js");
const contractSubscriptions = {
logs: log_subscription_js_1.LogsSubscription,
logs: contract_log_subscription_js_1.ContractLogsSubscription,
newHeads: web3_eth_1.NewHeadsSubscription,

@@ -284,2 +286,3 @@ newBlockHeaders: web3_eth_1.NewHeadsSubscription,

this._functions = {};
this._subscriptionManager = new contract_subscription_manager_js_1.ContractSubscriptionManager(super.subscriptionManager, this);
// Init protected properties

@@ -345,2 +348,5 @@ if (contractContext === null || contractContext === void 0 ? void 0 : contractContext.wallet) {

}
get subscriptionManager() {
return this._subscriptionManager;
}
setTransactionMiddleware(transactionMiddleware) {

@@ -604,3 +610,3 @@ this.transactionMiddleware = transactionMiddleware;

}
return Object.assign(Object.assign({}, (0, encoding_js_1.decodeMethodParams)(abi, data)), { __method__: (0, web3_eth_abi_1.jsonInterfaceMethodToString)(abi) });
return (0, web3_eth_abi_1.decodeFunctionCall)(abi, data);
}

@@ -756,3 +762,3 @@ _parseAndSetJsonInterface(abis, returnFormat = this.defaultReturnFormat) {

encodeABI: () => (0, encoding_js_1.encodeMethodABI)(methodAbi, abiParams),
decodeData: (data) => (0, encoding_js_1.decodeMethodParams)(methodAbi, data),
decodeData: (data) => (0, web3_eth_abi_1.decodeFunctionCall)(methodAbi, data),
createAccessList: (options, block) => __awaiter(this, void 0, void 0, function* () {

@@ -779,3 +785,3 @@ return this._contractMethodCreateAccessList(methodAbi, abiParams, internalErrorsAbis, options, block);

const result = yield (0, web3_eth_1.call)(this, tx, block, this.defaultReturnFormat);
return (0, encoding_js_1.decodeMethodReturn)(abi, result);
return (0, web3_eth_abi_1.decodeFunctionReturn)(abi, result);
}

@@ -858,3 +864,3 @@ catch (error) {

const { topics, fromBlock } = (0, encoding_js_1.encodeEventABI)(this.options, abi, params[0]);
const sub = new log_subscription_js_1.LogsSubscription({
const sub = new contract_log_subscription_js_1.ContractLogsSubscription({
address: this.options.address,

@@ -861,0 +867,0 @@ topics,

@@ -10,6 +10,7 @@ import { AbiConstructorFragment, AbiEventFragment, AbiFunctionFragment, Filter, HexString, ContractOptions } from 'web3-types';

export declare const encodeMethodABI: (abi: AbiFunctionFragment | AbiConstructorFragment, args: unknown[], deployData?: HexString) => string;
export declare const decodeMethodParams: (abi: AbiFunctionFragment | AbiConstructorFragment, data: HexString, methodSignatureProvided?: boolean) => {
[key: string]: unknown;
__length__: number;
/** @deprecated import `decodeFunctionCall` from ''web3-eth-abi' instead. */
export declare const decodeMethodParams: (functionsAbi: AbiFunctionFragment | AbiConstructorFragment, data: string, methodSignatureProvided?: boolean | undefined) => import("web3-types").DecodedParams & {
__method__: string;
};
export declare const decodeMethodReturn: (abi: AbiFunctionFragment, returnValues?: HexString) => unknown;
/** @deprecated import `decodeFunctionReturn` from ''web3-eth-abi' instead. */
export declare const decodeMethodReturn: (functionsAbi: AbiFunctionFragment, returnValues?: string | undefined) => unknown;

@@ -110,35 +110,6 @@ "use strict";

exports.encodeMethodABI = encodeMethodABI;
const decodeMethodParams = (abi, data, methodSignatureProvided = true) => {
const value = methodSignatureProvided && data && data.length >= 10 && data.startsWith('0x')
? data.slice(10)
: data;
if (!abi.inputs) {
throw new web3_errors_1.Web3ContractError('No inputs found in the ABI');
}
const result = (0, web3_eth_abi_1.decodeParameters)([...abi.inputs], value);
return result;
};
exports.decodeMethodParams = decodeMethodParams;
const decodeMethodReturn = (abi, returnValues) => {
// If it was constructor then we need to return contract address
if (abi.type === 'constructor') {
return returnValues;
}
if (!returnValues) {
// Using "null" value intentionally to match legacy behavior
// eslint-disable-next-line no-null/no-null
return null;
}
const value = returnValues.length >= 2 ? returnValues.slice(2) : returnValues;
if (!abi.outputs) {
// eslint-disable-next-line no-null/no-null
return null;
}
const result = (0, web3_eth_abi_1.decodeParameters)([...abi.outputs], value);
if (result.__length__ === 1) {
return result[0];
}
return result;
};
exports.decodeMethodReturn = decodeMethodReturn;
/** @deprecated import `decodeFunctionCall` from ''web3-eth-abi' instead. */
exports.decodeMethodParams = web3_eth_abi_1.decodeFunctionCall;
/** @deprecated import `decodeFunctionReturn` from ''web3-eth-abi' instead. */
exports.decodeMethodReturn = web3_eth_abi_1.decodeFunctionReturn;
//# sourceMappingURL=encoding.js.map

@@ -27,8 +27,11 @@ /**

import { Contract } from './contract.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
/** @deprecated Use `ContractLogsSubscription` instead. */
export declare type LogsSubscription = ContractLogsSubscription;
export * from './encoding.js';
export * from './contract.js';
export * from './contract-deployer-method-class.js';
export * from './log_subscription.js';
export * from './contract_log_subscription.js';
export * from './types.js';
export * from './utils.js';
export default Contract;

@@ -62,3 +62,3 @@ "use strict";

__exportStar(require("./contract-deployer-method-class.js"), exports);
__exportStar(require("./log_subscription.js"), exports);
__exportStar(require("./contract_log_subscription.js"), exports);
__exportStar(require("./types.js"), exports);

@@ -65,0 +65,0 @@ __exportStar(require("./utils.js"), exports);

@@ -5,3 +5,3 @@ import { Web3ContextInitOptions, Web3PromiEvent } from 'web3-core';

import type { ContractOptions } from 'web3-types';
import { LogsSubscription } from './log_subscription.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
export declare type NonPayableTxOptions = NonPayableCallOptions;

@@ -386,5 +386,5 @@ export declare type PayableTxOptions = PayableCallOptions;

export declare type Web3ContractContext = Partial<Web3ContextInitOptions<EthExecutionAPI, {
logs: typeof LogsSubscription;
logs: typeof ContractLogsSubscription;
newHeads: typeof NewHeadsSubscription;
newBlockHeaders: typeof NewHeadsSubscription;
}>>;

@@ -31,3 +31,3 @@ import { TransactionForAccessList, AbiFunctionFragment, TransactionWithSenderAPI, TransactionCall, HexString, Address, NonPayableCallOptions, PayableCallOptions, ContractOptions, Numbers, AbiConstructorFragment } from 'web3-types';

export declare const isWeb3ContractContext: (options: unknown) => options is Partial<import("web3-core").Web3ContextInitOptions<import("web3-types").EthExecutionAPI, {
logs: typeof import("./log_subscription.js").LogsSubscription;
logs: typeof import("./contract_log_subscription.js").ContractLogsSubscription;
newHeads: typeof import("web3-eth").NewHeadsSubscription;

@@ -34,0 +34,0 @@ newBlockHeaders: typeof import("web3-eth").NewHeadsSubscription;

@@ -28,6 +28,7 @@ /*

import { sendTransaction } from 'web3-eth';
import { decodeFunctionCall } from 'web3-eth-abi';
import { DEFAULT_RETURN_FORMAT, } from 'web3-types';
import { format } from 'web3-utils';
import { isNullish } from 'web3-validator';
import { decodeMethodParams, encodeMethodABI } from './encoding.js';
import { encodeMethodABI } from './encoding.js';
import { getSendTxParams } from './utils.js';

@@ -126,5 +127,5 @@ /*

decodeData(data) {
return Object.assign(Object.assign({}, decodeMethodParams(this.constructorAbi, data.replace(this.deployData, ''), false)), { __method__: this.constructorAbi.type });
return Object.assign(Object.assign({}, decodeFunctionCall(this.constructorAbi, data.replace(this.deployData, ''), false)), { __method__: this.constructorAbi.type });
}
}
//# sourceMappingURL=contract-deployer-method-class.js.map

@@ -29,13 +29,15 @@ /*

import { createAccessList, call, estimateGas, getLogs, sendTransaction, decodeEventABI, NewHeadsSubscription, ALL_EVENTS, ALL_EVENTS_ABI, } from 'web3-eth';
import { encodeEventSignature, encodeFunctionSignature, decodeContractErrorData, isAbiErrorFragment, isAbiEventFragment, isAbiFunctionFragment, jsonInterfaceMethodToString, } from 'web3-eth-abi';
import { decodeFunctionCall, decodeFunctionReturn, encodeEventSignature, encodeFunctionSignature, decodeContractErrorData, isAbiErrorFragment, isAbiEventFragment, isAbiFunctionFragment, jsonInterfaceMethodToString, } from 'web3-eth-abi';
import { BlockTags, } from 'web3-types';
import { format, isDataFormat, keccak256, toChecksumAddress, isContractInitOptions, } from 'web3-utils';
import { isNullish, validator, utils as validatorUtils, Web3ValidatorError, } from 'web3-validator';
import { decodeMethodReturn, decodeMethodParams, encodeEventABI, encodeMethodABI, } from './encoding.js';
import { LogsSubscription } from './log_subscription.js';
import { encodeEventABI, encodeMethodABI } from './encoding.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
import { getCreateAccessListParams, getEstimateGasParams, getEthTxCallParams, getSendTxParams, isWeb3ContractContext, } from './utils.js';
// eslint-disable-next-line import/no-cycle
import { DeployerMethodClass } from './contract-deployer-method-class.js';
// eslint-disable-next-line import/no-cycle
import { ContractSubscriptionManager } from './contract-subscription-manager.js';
const contractSubscriptions = {
logs: LogsSubscription,
logs: ContractLogsSubscription,
newHeads: NewHeadsSubscription,

@@ -281,2 +283,3 @@ newBlockHeaders: NewHeadsSubscription,

this._functions = {};
this._subscriptionManager = new ContractSubscriptionManager(super.subscriptionManager, this);
// Init protected properties

@@ -342,2 +345,5 @@ if (contractContext === null || contractContext === void 0 ? void 0 : contractContext.wallet) {

}
get subscriptionManager() {
return this._subscriptionManager;
}
setTransactionMiddleware(transactionMiddleware) {

@@ -601,3 +607,3 @@ this.transactionMiddleware = transactionMiddleware;

}
return Object.assign(Object.assign({}, decodeMethodParams(abi, data)), { __method__: jsonInterfaceMethodToString(abi) });
return decodeFunctionCall(abi, data);
}

@@ -753,3 +759,3 @@ _parseAndSetJsonInterface(abis, returnFormat = this.defaultReturnFormat) {

encodeABI: () => encodeMethodABI(methodAbi, abiParams),
decodeData: (data) => decodeMethodParams(methodAbi, data),
decodeData: (data) => decodeFunctionCall(methodAbi, data),
createAccessList: (options, block) => __awaiter(this, void 0, void 0, function* () {

@@ -776,3 +782,3 @@ return this._contractMethodCreateAccessList(methodAbi, abiParams, internalErrorsAbis, options, block);

const result = yield call(this, tx, block, this.defaultReturnFormat);
return decodeMethodReturn(abi, result);
return decodeFunctionReturn(abi, result);
}

@@ -855,3 +861,3 @@ catch (error) {

const { topics, fromBlock } = encodeEventABI(this.options, abi, params[0]);
const sub = new LogsSubscription({
const sub = new ContractLogsSubscription({
address: this.options.address,

@@ -858,0 +864,0 @@ topics,

@@ -19,3 +19,3 @@ /*

import { FMT_NUMBER, FMT_BYTES, } from 'web3-types';
import { decodeParameters, encodeEventSignature, encodeFunctionSignature, encodeParameter, encodeParameters, inferTypesAndEncodeParameters, isAbiConstructorFragment, jsonInterfaceMethodToString, } from 'web3-eth-abi';
import { decodeFunctionCall, decodeFunctionReturn, encodeEventSignature, encodeFunctionSignature, encodeParameter, encodeParameters, inferTypesAndEncodeParameters, isAbiConstructorFragment, jsonInterfaceMethodToString, } from 'web3-eth-abi';
import { blockSchema, ALL_EVENTS } from 'web3-eth';

@@ -105,33 +105,6 @@ import { Web3ContractError } from 'web3-errors';

};
export const decodeMethodParams = (abi, data, methodSignatureProvided = true) => {
const value = methodSignatureProvided && data && data.length >= 10 && data.startsWith('0x')
? data.slice(10)
: data;
if (!abi.inputs) {
throw new Web3ContractError('No inputs found in the ABI');
}
const result = decodeParameters([...abi.inputs], value);
return result;
};
export const decodeMethodReturn = (abi, returnValues) => {
// If it was constructor then we need to return contract address
if (abi.type === 'constructor') {
return returnValues;
}
if (!returnValues) {
// Using "null" value intentionally to match legacy behavior
// eslint-disable-next-line no-null/no-null
return null;
}
const value = returnValues.length >= 2 ? returnValues.slice(2) : returnValues;
if (!abi.outputs) {
// eslint-disable-next-line no-null/no-null
return null;
}
const result = decodeParameters([...abi.outputs], value);
if (result.__length__ === 1) {
return result[0];
}
return result;
};
/** @deprecated import `decodeFunctionCall` from ''web3-eth-abi' instead. */
export const decodeMethodParams = decodeFunctionCall;
/** @deprecated import `decodeFunctionReturn` from ''web3-eth-abi' instead. */
export const decodeMethodReturn = decodeFunctionReturn;
//# sourceMappingURL=encoding.js.map

@@ -46,3 +46,3 @@ /*

export * from './contract-deployer-method-class.js';
export * from './log_subscription.js';
export * from './contract_log_subscription.js';
export * from './types.js';

@@ -49,0 +49,0 @@ export * from './utils.js';

import { Web3Context, Web3EventEmitter, Web3PromiEvent } from 'web3-core';
import { NewHeadsSubscription, SendTransactionEvents, TransactionMiddleware } from 'web3-eth';
import { AbiFunctionFragment, ContractAbi, ContractConstructorArgs, ContractEvent, ContractEvents, ContractMethod, ContractMethodInputParameters, ContractMethodOutputParameters, Address, EthExecutionAPI, Filter, FilterAbis, HexString, ContractInitOptions, NonPayableCallOptions, PayableCallOptions, DataFormat, DEFAULT_RETURN_FORMAT, EventLog, ContractOptions, TransactionReceipt, FormatType, DecodedParams } from 'web3-types';
import { LogsSubscription } from './log_subscription.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
import { ContractEventOptions, NonPayableMethodObject, PayableMethodObject, Web3ContractContext } from './types.js';
import { DeployerMethodClass } from './contract-deployer-method-class.js';
declare type ContractBoundMethod<Abi extends AbiFunctionFragment, Method extends ContractMethod<Abi> = ContractMethod<Abi>> = (...args: Method['Inputs'] extends undefined | unknown ? any[] : Method['Inputs']) => Method['Abi']['stateMutability'] extends 'payable' | 'pure' ? PayableMethodObject<Method['Inputs'], Method['Outputs']> : NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
import { ContractSubscriptionManager } from './contract-subscription-manager.js';
declare type ContractBoundMethod<Abi extends AbiFunctionFragment, Method extends ContractMethod<Abi> = ContractMethod<Abi>> = (...args: Abi extends undefined ? any[] : Method['Inputs'] extends never ? any[] : Method['Inputs']) => Method['Abi']['stateMutability'] extends 'payable' | 'pure' ? PayableMethodObject<Method['Inputs'], Method['Outputs']> : NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
export declare type ContractOverloadedMethodInputs<AbiArr extends ReadonlyArray<unknown>> = NonNullable<AbiArr extends readonly [] ? undefined : AbiArr extends readonly [infer A, ...infer R] ? A extends AbiFunctionFragment ? ContractMethodInputParameters<A['inputs']> | ContractOverloadedMethodInputs<R> : undefined : undefined>;

@@ -29,5 +30,5 @@ export declare type ContractOverloadedMethodOutputs<AbiArr extends ReadonlyArray<unknown>> = NonNullable<AbiArr extends readonly [] ? undefined : AbiArr extends readonly [infer A, ...infer R] ? A extends AbiFunctionFragment ? ContractMethodOutputParameters<A['outputs']> | ContractOverloadedMethodOutputs<R> : undefined : undefined>;

* @param options - The options used to subscribe for the event
* @returns - A Promise resolved with {@link LogsSubscription} object
* @returns - A Promise resolved with {@link ContractLogsSubscription} object
*/
export declare type ContractBoundEvent = (options?: ContractEventOptions) => LogsSubscription;
export declare type ContractBoundEvent = (options?: ContractEventOptions) => ContractLogsSubscription;
export declare type ContractEventsInterface<Abi extends ContractAbi, Events extends ContractEvents<Abi> = ContractEvents<Abi>> = {

@@ -44,6 +45,7 @@ [Name in keyof Events | 'allEvents']: ContractBoundEvent;

declare const contractSubscriptions: {
logs: typeof LogsSubscription;
logs: typeof ContractLogsSubscription;
newHeads: typeof NewHeadsSubscription;
newBlockHeaders: typeof NewHeadsSubscription;
};
declare type ContractSubscriptions = typeof contractSubscriptions;
/**

@@ -245,3 +247,5 @@ * The `web3.eth.Contract` makes it easy to interact with smart contracts on the ethereum blockchain.

*/
export declare class Contract<Abi extends ContractAbi> extends Web3Context<EthExecutionAPI, typeof contractSubscriptions> implements Web3EventEmitter<ContractEventEmitterInterface<Abi>> {
export declare class Contract<Abi extends ContractAbi> extends Web3Context<EthExecutionAPI, ContractSubscriptions> implements Web3EventEmitter<ContractEventEmitterInterface<Abi>> {
protected _subscriptionManager: ContractSubscriptionManager<EthExecutionAPI>;
get subscriptionManager(): ContractSubscriptionManager<EthExecutionAPI>;
/**

@@ -248,0 +252,0 @@ * The options `object` for the contract instance. `from`, `gas` and `gasPrice` are used as fallback values when sending transactions.

@@ -10,7 +10,8 @@ import { AbiConstructorFragment, AbiEventFragment, AbiFunctionFragment, Filter, HexString, ContractOptions } from 'web3-types';

export declare const encodeMethodABI: (abi: AbiFunctionFragment | AbiConstructorFragment, args: unknown[], deployData?: HexString) => string;
export declare const decodeMethodParams: (abi: AbiFunctionFragment | AbiConstructorFragment, data: HexString, methodSignatureProvided?: boolean) => {
[key: string]: unknown;
__length__: number;
/** @deprecated import `decodeFunctionCall` from ''web3-eth-abi' instead. */
export declare const decodeMethodParams: (functionsAbi: AbiFunctionFragment | AbiConstructorFragment, data: string, methodSignatureProvided?: boolean | undefined) => import("web3-types").DecodedParams & {
__method__: string;
};
export declare const decodeMethodReturn: (abi: AbiFunctionFragment, returnValues?: HexString) => unknown;
/** @deprecated import `decodeFunctionReturn` from ''web3-eth-abi' instead. */
export declare const decodeMethodReturn: (functionsAbi: AbiFunctionFragment, returnValues?: string | undefined) => unknown;
//# sourceMappingURL=encoding.d.ts.map

@@ -27,6 +27,9 @@ /**

import { Contract } from './contract.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
/** @deprecated Use `ContractLogsSubscription` instead. */
export declare type LogsSubscription = ContractLogsSubscription;
export * from './encoding.js';
export * from './contract.js';
export * from './contract-deployer-method-class.js';
export * from './log_subscription.js';
export * from './contract_log_subscription.js';
export * from './types.js';

@@ -33,0 +36,0 @@ export * from './utils.js';

@@ -5,3 +5,3 @@ import { Web3ContextInitOptions, Web3PromiEvent } from 'web3-core';

import type { ContractOptions } from 'web3-types';
import { LogsSubscription } from './log_subscription.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
export declare type NonPayableTxOptions = NonPayableCallOptions;

@@ -386,3 +386,3 @@ export declare type PayableTxOptions = PayableCallOptions;

export declare type Web3ContractContext = Partial<Web3ContextInitOptions<EthExecutionAPI, {
logs: typeof LogsSubscription;
logs: typeof ContractLogsSubscription;
newHeads: typeof NewHeadsSubscription;

@@ -389,0 +389,0 @@ newBlockHeaders: typeof NewHeadsSubscription;

@@ -31,3 +31,3 @@ import { TransactionForAccessList, AbiFunctionFragment, TransactionWithSenderAPI, TransactionCall, HexString, Address, NonPayableCallOptions, PayableCallOptions, ContractOptions, Numbers, AbiConstructorFragment } from 'web3-types';

export declare const isWeb3ContractContext: (options: unknown) => options is Partial<import("web3-core").Web3ContextInitOptions<import("web3-types").EthExecutionAPI, {
logs: typeof import("./log_subscription.js").LogsSubscription;
logs: typeof import("./contract_log_subscription.js").ContractLogsSubscription;
newHeads: typeof import("web3-eth").NewHeadsSubscription;

@@ -34,0 +34,0 @@ newBlockHeaders: typeof import("web3-eth").NewHeadsSubscription;

{
"name": "web3-eth-contract",
"version": "4.7.1-dev.9edb183.0+9edb183",
"version": "4.7.1-dev.9fa32c9.0+9fa32c9",
"description": "Web3 module to interact with Ethereum smart contracts.",

@@ -49,9 +49,9 @@ "main": "./lib/commonjs/index.js",

"@ethereumjs/rlp": "^5.0.2",
"web3-core": "4.6.1-dev.9edb183.0+9edb183",
"web3-errors": "1.3.1-dev.9edb183.0+9edb183",
"web3-eth": "4.9.1-dev.9edb183.0+9edb183",
"web3-eth-abi": "4.2.5-dev.9edb183.0+9edb183",
"web3-types": "1.8.1-dev.9edb183.0+9edb183",
"web3-utils": "4.3.2-dev.9edb183.0+9edb183",
"web3-validator": "2.0.7-dev.9edb183.0+9edb183"
"web3-core": "4.7.1-dev.9fa32c9.0+9fa32c9",
"web3-errors": "1.3.1-dev.9fa32c9.0+9fa32c9",
"web3-eth": "4.10.1-dev.9fa32c9.0+9fa32c9",
"web3-eth-abi": "4.3.1-dev.9fa32c9.0+9fa32c9",
"web3-types": "1.8.2-dev.9fa32c9.0+9fa32c9",
"web3-utils": "4.3.3-dev.9fa32c9.0+9fa32c9",
"web3-validator": "2.0.7-dev.9fa32c9.0+9fa32c9"
},

@@ -73,6 +73,6 @@ "devDependencies": {

"typescript": "^4.7.4",
"web3-eth-accounts": "4.2.2-dev.9edb183.0+9edb183",
"web3-providers-ws": "4.0.9-dev.9edb183.0+9edb183"
"web3-eth-accounts": "4.2.2-dev.9fa32c9.0+9fa32c9",
"web3-providers-ws": "4.0.9-dev.9fa32c9.0+9fa32c9"
},
"gitHead": "9edb183c97fba937e3ea7bde9874b043ba6f17ae"
"gitHead": "9fa32c92bc2f74d50e663fd9a42c2ea45e1a8ea0"
}

@@ -20,2 +20,3 @@ /*

import { sendTransaction, SendTransactionEvents, SendTransactionOptions } from 'web3-eth';
import { decodeFunctionCall } from 'web3-eth-abi';
import {

@@ -38,3 +39,3 @@ AbiConstructorFragment,

import { Web3PromiEvent } from 'web3-core';
import { decodeMethodParams, encodeMethodABI } from './encoding.js';
import { encodeMethodABI } from './encoding.js';
import { NonPayableTxOptions, PayableTxOptions } from './types.js';

@@ -214,3 +215,3 @@ import { getSendTxParams } from './utils.js';

return {
...decodeMethodParams(
...decodeFunctionCall(
this.constructorAbi,

@@ -217,0 +218,0 @@ data.replace(this.deployData as string, ''),

@@ -45,2 +45,4 @@ /*

import {
decodeFunctionCall,
decodeFunctionReturn,
encodeEventSignature,

@@ -103,10 +105,5 @@ encodeFunctionSignature,

} from 'web3-validator';
import { encodeEventABI, encodeMethodABI } from './encoding.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';
import {
decodeMethodReturn,
decodeMethodParams,
encodeEventABI,
encodeMethodABI,
} from './encoding.js';
import { LogsSubscription } from './log_subscription.js';
import {
ContractEventOptions,

@@ -128,2 +125,4 @@ NonPayableMethodObject,

import { DeployerMethodClass } from './contract-deployer-method-class.js';
// eslint-disable-next-line import/no-cycle
import { ContractSubscriptionManager } from './contract-subscription-manager.js';

@@ -134,3 +133,7 @@ type ContractBoundMethod<

> = (
...args: Method['Inputs'] extends undefined | unknown ? any[] : Method['Inputs']
...args: Abi extends undefined
? any[]
: Method['Inputs'] extends never
? any[]
: Method['Inputs']
) => Method['Abi']['stateMutability'] extends 'payable' | 'pure'

@@ -186,5 +189,5 @@ ? PayableMethodObject<Method['Inputs'], Method['Outputs']>

* @param options - The options used to subscribe for the event
* @returns - A Promise resolved with {@link LogsSubscription} object
* @returns - A Promise resolved with {@link ContractLogsSubscription} object
*/
export type ContractBoundEvent = (options?: ContractEventOptions) => LogsSubscription;
export type ContractBoundEvent = (options?: ContractEventOptions) => ContractLogsSubscription;

@@ -212,3 +215,3 @@ // To avoid circular dependency between types and encoding, declared these types here.

const contractSubscriptions = {
logs: LogsSubscription,
logs: ContractLogsSubscription,
newHeads: NewHeadsSubscription,

@@ -218,2 +221,4 @@ newBlockHeaders: NewHeadsSubscription,

type ContractSubscriptions = typeof contractSubscriptions;
/**

@@ -416,5 +421,11 @@ * The `web3.eth.Contract` makes it easy to interact with smart contracts on the ethereum blockchain.

export class Contract<Abi extends ContractAbi>
extends Web3Context<EthExecutionAPI, typeof contractSubscriptions>
extends Web3Context<EthExecutionAPI, ContractSubscriptions>
implements Web3EventEmitter<ContractEventEmitterInterface<Abi>>
{
protected override _subscriptionManager: ContractSubscriptionManager<EthExecutionAPI>;
public override get subscriptionManager(): ContractSubscriptionManager<EthExecutionAPI> {
return this._subscriptionManager;
}
/**

@@ -575,2 +586,7 @@ * The options `object` for the contract instance. `from`, `gas` and `gasPrice` are used as fallback values when sending transactions.

this._subscriptionManager = new ContractSubscriptionManager<
EthExecutionAPI,
ContractSubscriptions
>(super.subscriptionManager, this);
// Init protected properties

@@ -1023,3 +1039,3 @@ if ((contractContext as Web3Context)?.wallet) {

}
return { ...decodeMethodParams(abi, data), __method__: jsonInterfaceMethodToString(abi) };
return decodeFunctionCall(abi, data);
}

@@ -1249,3 +1265,3 @@

encodeABI: () => encodeMethodABI(methodAbi, abiParams),
decodeData: (data: HexString) => decodeMethodParams(methodAbi, data),
decodeData: (data: HexString) => decodeFunctionCall(methodAbi, data),

@@ -1304,3 +1320,3 @@ createAccessList: async (

);
return decodeMethodReturn(abi, result);
return decodeFunctionReturn(abi, result);
} catch (error: unknown) {

@@ -1429,3 +1445,3 @@ if (error instanceof ContractExecutionError) {

);
const sub = new LogsSubscription(
const sub = new ContractLogsSubscription(
{

@@ -1432,0 +1448,0 @@ address: this.options.address,

@@ -33,3 +33,4 @@ /*

import {
decodeParameters,
decodeFunctionCall,
decodeFunctionReturn,
encodeEventSignature,

@@ -157,42 +158,5 @@ encodeFunctionSignature,

export const decodeMethodParams = (
abi: AbiFunctionFragment | AbiConstructorFragment,
data: HexString,
methodSignatureProvided = true,
) => {
const value =
methodSignatureProvided && data && data.length >= 10 && data.startsWith('0x')
? data.slice(10)
: data;
if (!abi.inputs) {
throw new Web3ContractError('No inputs found in the ABI');
}
const result = decodeParameters([...abi.inputs], value);
return result;
};
export const decodeMethodReturn = (abi: AbiFunctionFragment, returnValues?: HexString) => {
// If it was constructor then we need to return contract address
if (abi.type === 'constructor') {
return returnValues;
}
if (!returnValues) {
// Using "null" value intentionally to match legacy behavior
// eslint-disable-next-line no-null/no-null
return null;
}
const value = returnValues.length >= 2 ? returnValues.slice(2) : returnValues;
if (!abi.outputs) {
// eslint-disable-next-line no-null/no-null
return null;
}
const result = decodeParameters([...abi.outputs], value);
if (result.__length__ === 1) {
return result[0];
}
return result;
};
/** @deprecated import `decodeFunctionCall` from ''web3-eth-abi' instead. */
export const decodeMethodParams = decodeFunctionCall;
/** @deprecated import `decodeFunctionReturn` from ''web3-eth-abi' instead. */
export const decodeMethodReturn = decodeFunctionReturn;

@@ -45,2 +45,6 @@ /*

import { ContractLogsSubscription } from './contract_log_subscription.js';
/** @deprecated Use `ContractLogsSubscription` instead. */
export type LogsSubscription = ContractLogsSubscription;
export * from './encoding.js';

@@ -50,3 +54,3 @@

export * from './contract-deployer-method-class.js';
export * from './log_subscription.js';
export * from './contract_log_subscription.js';
export * from './types.js';

@@ -53,0 +57,0 @@ export * from './utils.js';

@@ -35,3 +35,3 @@ /*

import type { ContractOptions } from 'web3-types';
import { LogsSubscription } from './log_subscription.js';
import { ContractLogsSubscription } from './contract_log_subscription.js';

@@ -466,3 +466,3 @@ export type NonPayableTxOptions = NonPayableCallOptions;

{
logs: typeof LogsSubscription;
logs: typeof ContractLogsSubscription;
newHeads: typeof NewHeadsSubscription;

@@ -469,0 +469,0 @@ newBlockHeaders: typeof NewHeadsSubscription;

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc