Socket
Socket
Sign inDemoInstall

web3-eth-contract

Package Overview
Dependencies
Maintainers
4
Versions
442
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.9b32205.0 to 4.7.1-dev.b86d8ca.0

1

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

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

exports.DeployerMethodClass = DeployerMethodClass;
;
//# sourceMappingURL=contract-deployer-method-class.js.map

22

lib/commonjs/contract.js

@@ -262,3 +262,4 @@ "use strict";

let provider;
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) {
if (typeof addressOrOptionsOrContext === 'object' &&
'provider' in addressOrOptionsOrContext) {
provider = addressOrOptionsOrContext.provider;

@@ -270,3 +271,4 @@ }

}
else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) {
else if (typeof contextOrReturnFormat === 'object' &&
'provider' in contextOrReturnFormat) {
provider = contextOrReturnFormat.provider;

@@ -572,3 +574,4 @@ }

if (Array.isArray(filter[key])) {
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase());
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() ===
String(v).toUpperCase());
}

@@ -581,3 +584,4 @@ const inputAbi = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.filter(input => input.name === key)[0];

}
return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase();
return (String(log.returnValues[key]).toUpperCase() ===
String(filter[key]).toUpperCase());
});

@@ -634,3 +638,4 @@ });

// We don't know a particular type of the Abi method so can't type check
this._methods[abi.name] = contractMethod;
this._methods[abi.name] =
contractMethod;
// We don't know a particular type of the Abi method so can't type check

@@ -721,3 +726,5 @@ this._methods[methodName] =

arguments: abiParams,
call: (options, block) => __awaiter(this, void 0, void 0, function* () { return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); }),
call: (options, block) => __awaiter(this, void 0, void 0, function* () {
return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block);
}),
send: (options) => this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options),

@@ -741,3 +748,4 @@ populateTransaction: (options, contractOptions) => {

},
estimateGas: (options, returnFormat = this.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () {
estimateGas: (options, returnFormat = this
.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () {
return this.contractMethodEstimateGas({

@@ -744,0 +752,0 @@ abi: methodAbi,

@@ -128,6 +128,6 @@ "use strict";

let nonceValue = nonce;
if (typeof nonce === "string" && (0, web3_validator_1.isHexString)(nonce))
if (typeof nonce === 'string' && (0, web3_validator_1.isHexString)(nonce))
nonceValue = (0, web3_utils_1.hexToNumber)(nonce);
else if (typeof nonce === "string" && !(0, web3_validator_1.isHexString)(nonce))
throw new web3_errors_1.InvalidNumberError("Invalid nonce value format");
else if (typeof nonce === 'string' && !(0, web3_validator_1.isHexString)(nonce))
throw new web3_errors_1.InvalidNumberError('Invalid nonce value format');
const rlpEncoded = rlp_1.RLP.encode([from, nonceValue]);

@@ -134,0 +134,0 @@ const result = (0, web3_utils_1.keccak256)(rlpEncoded);

@@ -26,9 +26,9 @@ /*

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

@@ -129,3 +129,2 @@ * This class is only supposed to be used for the return of `new Contract(...).deploy(...)` method.

}
;
//# sourceMappingURL=contract-deployer-method-class.js.map

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

let provider;
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) {
if (typeof addressOrOptionsOrContext === 'object' &&
'provider' in addressOrOptionsOrContext) {
provider = addressOrOptionsOrContext.provider;

@@ -267,3 +268,4 @@ }

}
else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) {
else if (typeof contextOrReturnFormat === 'object' &&
'provider' in contextOrReturnFormat) {
provider = contextOrReturnFormat.provider;

@@ -569,3 +571,4 @@ }

if (Array.isArray(filter[key])) {
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase());
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() ===
String(v).toUpperCase());
}

@@ -578,3 +581,4 @@ const inputAbi = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.filter(input => input.name === key)[0];

}
return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase();
return (String(log.returnValues[key]).toUpperCase() ===
String(filter[key]).toUpperCase());
});

@@ -631,3 +635,4 @@ });

// We don't know a particular type of the Abi method so can't type check
this._methods[abi.name] = contractMethod;
this._methods[abi.name] =
contractMethod;
// We don't know a particular type of the Abi method so can't type check

@@ -718,3 +723,5 @@ this._methods[methodName] =

arguments: abiParams,
call: (options, block) => __awaiter(this, void 0, void 0, function* () { return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); }),
call: (options, block) => __awaiter(this, void 0, void 0, function* () {
return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block);
}),
send: (options) => this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options),

@@ -738,3 +745,4 @@ populateTransaction: (options, contractOptions) => {

},
estimateGas: (options, returnFormat = this.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () {
estimateGas: (options, returnFormat = this
.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () {
return this.contractMethodEstimateGas({

@@ -741,0 +749,0 @@ abi: methodAbi,

@@ -18,4 +18,4 @@ /*

import { RLP } from '@ethereumjs/rlp';
import { InvalidAddressError, InvalidMethodParamsError, InvalidNumberError, Web3ContractError } from 'web3-errors';
import { isNullish, mergeDeep, isContractInitOptions, keccak256, toChecksumAddress, hexToNumber } from 'web3-utils';
import { InvalidAddressError, InvalidMethodParamsError, InvalidNumberError, Web3ContractError, } from 'web3-errors';
import { isNullish, mergeDeep, isContractInitOptions, keccak256, toChecksumAddress, hexToNumber, } from 'web3-utils';
import { isAddress, isHexString } from 'web3-validator';

@@ -121,6 +121,6 @@ import { encodeMethodABI } from './encoding.js';

let nonceValue = nonce;
if (typeof nonce === "string" && isHexString(nonce))
if (typeof nonce === 'string' && isHexString(nonce))
nonceValue = hexToNumber(nonce);
else if (typeof nonce === "string" && !isHexString(nonce))
throw new InvalidNumberError("Invalid nonce value format");
else if (typeof nonce === 'string' && !isHexString(nonce))
throw new InvalidNumberError('Invalid nonce value format');
const rlpEncoded = RLP.encode([from, nonceValue]);

@@ -127,0 +127,0 @@ const result = keccak256(rlpEncoded);

{
"name": "web3-eth-contract",
"version": "4.7.1-dev.9b32205.0+9b32205",
"version": "4.7.1-dev.b86d8ca.0+b86d8ca",
"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.5.2-dev.9b32205.0+9b32205",
"web3-errors": "1.3.1-dev.9b32205.0+9b32205",
"web3-eth": "4.8.3-dev.9b32205.0+9b32205",
"web3-eth-abi": "4.2.4-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.b86d8ca.0+b86d8ca",
"web3-errors": "1.3.1-dev.b86d8ca.0+b86d8ca",
"web3-eth": "4.8.3-dev.b86d8ca.0+b86d8ca",
"web3-eth-abi": "4.2.4-dev.b86d8ca.0+b86d8ca",
"web3-types": "1.7.1-dev.b86d8ca.0+b86d8ca",
"web3-utils": "4.3.2-dev.b86d8ca.0+b86d8ca",
"web3-validator": "2.0.7-dev.b86d8ca.0+b86d8ca"
},

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

"typescript": "^4.7.4",
"web3-eth-accounts": "4.2.2-dev.9b32205.0+9b32205",
"web3-providers-ws": "4.0.9-dev.9b32205.0+9b32205"
"web3-eth-accounts": "4.2.2-dev.b86d8ca.0+b86d8ca",
"web3-providers-ws": "4.0.9-dev.b86d8ca.0+b86d8ca"
},
"gitHead": "9b322052ef266cc57b29080b20053991e0c9a0a9"
"gitHead": "b86d8cae50d60e56e96bde9d1b836ca01ecd0fbc"
}

@@ -18,11 +18,5 @@ /*

import { Web3ContractError } from 'web3-errors';
import { sendTransaction, SendTransactionEvents, SendTransactionOptions } from 'web3-eth';
import {
Web3ContractError,
} from 'web3-errors';
import {
sendTransaction,
SendTransactionEvents,
SendTransactionOptions,
} from 'web3-eth';
import {
AbiConstructorFragment,

@@ -41,20 +35,8 @@ AbiFunctionFragment,

} from 'web3-types';
import {
format,
} from 'web3-utils';
import {
isNullish,
} from 'web3-validator';
import { format } from 'web3-utils';
import { isNullish } from 'web3-validator';
import { Web3PromiEvent } from 'web3-core';
import {
decodeMethodParams,
encodeMethodABI,
} from './encoding.js';
import {
NonPayableTxOptions,
PayableTxOptions,
} from './types.js';
import {
getSendTxParams,
} from './utils.js';
import { decodeMethodParams, encodeMethodABI } from './encoding.js';
import { NonPayableTxOptions, PayableTxOptions } from './types.js';
import { getSendTxParams } from './utils.js';
// eslint-disable-next-line import/no-cycle

@@ -73,3 +55,2 @@ import { Contract } from './contract.js';

export class DeployerMethodClass<FullContractAbi extends ContractAbi> {
protected readonly args: never[] | ContractConstructorArgs<FullContractAbi>;

@@ -80,5 +61,3 @@ protected readonly constructorAbi: AbiConstructorFragment;

protected _contractMethodDeploySend(
tx: TransactionCall,
) {
protected _contractMethodDeploySend(tx: TransactionCall) {
// eslint-disable-next-line no-use-before-define

@@ -97,3 +76,3 @@ const returnTxOptions: SendTransactionOptions<Contract<FullContractAbi>> = {

},
contractAbi: this.parent.options.jsonInterface,

@@ -132,4 +111,3 @@ // TODO Should make this configurable by the user

) {
const { args, abi, contractOptions, deployData} = this.calculateDeployParams();
const { args, abi, contractOptions, deployData } = this.calculateDeployParams();

@@ -150,5 +128,3 @@ this.args = args;

public populateTransaction(
txOptions?: PayableTxOptions | NonPayableTxOptions,
) {
public populateTransaction(txOptions?: PayableTxOptions | NonPayableTxOptions) {
const modifiedContractOptions = {

@@ -212,3 +188,3 @@ ...this.contractOptions,

return { args, abi, contractOptions, deployData}
return { args, abi, contractOptions, deployData };
}

@@ -244,6 +220,10 @@

return {
...decodeMethodParams(this.constructorAbi, data.replace(this.deployData as string, ''), false),
...decodeMethodParams(
this.constructorAbi,
data.replace(this.deployData as string, ''),
false,
),
__method__: this.constructorAbi.type,
};
}
};
}

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

/**

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

jsonInterface: Abi,
addressOrOptionsOrContext?: Address | ContractInitOptions | Web3ContractContext | Web3Context,
addressOrOptionsOrContext?:
| Address
| ContractInitOptions
| Web3ContractContext
| Web3Context,
optionsOrContextOrReturnFormat?:

@@ -542,3 +544,6 @@ | ContractInitOptions

let provider;
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) {
if (
typeof addressOrOptionsOrContext === 'object' &&
'provider' in addressOrOptionsOrContext
) {
provider = addressOrOptionsOrContext.provider;

@@ -550,3 +555,6 @@ } else if (

provider = optionsOrContextOrReturnFormat.provider;
} else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) {
} else if (
typeof contextOrReturnFormat === 'object' &&
'provider' in contextOrReturnFormat
) {
provider = contextOrReturnFormat.provider;

@@ -967,3 +975,4 @@ } else {

(v: Numbers) =>
String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase(),
String(log.returnValues[key]).toUpperCase() ===
String(v).toUpperCase(),
);

@@ -978,3 +987,6 @@ }

return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase();
return (
String(log.returnValues[key]).toUpperCase() ===
String(filter[key]).toUpperCase()
);
});

@@ -1022,3 +1034,5 @@ });

const functionsAbi = abis.filter(abi => abi.type !== 'error');
const errorsAbi = abis.filter(abi => isAbiErrorFragment(abi)) as unknown as AbiErrorFragment[];
const errorsAbi = abis.filter(abi =>
isAbiErrorFragment(abi),
) as unknown as AbiErrorFragment[];

@@ -1039,3 +1053,5 @@ for (const a of functionsAbi) {

abi.constant =
abi.stateMutability === 'view' ?? abi.stateMutability === 'pure' ?? abi.constant;
abi.stateMutability === 'view' ??
abi.stateMutability === 'pure' ??
abi.constant;

@@ -1048,6 +1064,6 @@ abi.payable = abi.stateMutability === 'payable' ?? abi.payable;

const abiFragment = this._overloadedMethodAbis.get(abi.name) ?? [];
const contractMethod = this._createContractMethod<typeof abiFragment, AbiErrorFragment>(
abiFragment,
errorsAbi,
);
const contractMethod = this._createContractMethod<
typeof abiFragment,
AbiErrorFragment
>(abiFragment, errorsAbi);

@@ -1065,3 +1081,4 @@ const exactContractMethod = this._createContractMethod<

// We don't know a particular type of the Abi method so can't type check
this._methods[abi.name as keyof ContractMethodsInterface<Abi>] = contractMethod as never;
this._methods[abi.name as keyof ContractMethodsInterface<Abi>] =
contractMethod as never;

@@ -1142,3 +1159,6 @@ // We don't know a particular type of the Abi method so can't type check

abiParams = this._getAbiParams(_abi, params);
validator.validate(_abi.inputs as unknown as ValidationSchemaInput, abiParams);
validator.validate(
_abi.inputs as unknown as ValidationSchemaInput,
abiParams,
);
applicableMethodAbi.push(_abi);

@@ -1159,5 +1179,5 @@ } catch (e) {

m =>
`${(m as { methodNameWithInputs: string }).methodNameWithInputs} (signature: ${
(m as { signature: string }).signature
})`,
`${
(m as { methodNameWithInputs: string }).methodNameWithInputs
} (signature: ${(m as { signature: string }).signature})`,
),

@@ -1184,3 +1204,10 @@ )} \n\tThe first one will be used: ${

block?: BlockNumberOrTag,
) => this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block),
) =>
this._contractMethodCall(
methodAbi,
abiParams,
internalErrorsAbis,
options,
block,
),

@@ -1214,3 +1241,4 @@ send: (options?: PayableTxOptions | NonPayableTxOptions): ContractMethodSend =>

options?: PayableCallOptions | NonPayableCallOptions,
returnFormat: ReturnFormat = this.defaultReturnFormat as unknown as ReturnFormat,
returnFormat: ReturnFormat = this
.defaultReturnFormat as unknown as ReturnFormat,
) =>

@@ -1398,3 +1426,7 @@ this.contractMethodEstimateGas({

return (...params: unknown[]) => {
const { topics, fromBlock } = encodeEventABI(this.options, abi, params[0] as EventParameters);
const { topics, fromBlock } = encodeEventABI(
this.options,
abi,
params[0] as EventParameters,
);
const sub = new LogsSubscription(

@@ -1409,3 +1441,6 @@ {

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
subscriptionManager: this.subscriptionManager as Web3SubscriptionManager<unknown, any>,
subscriptionManager: this.subscriptionManager as Web3SubscriptionManager<
unknown,
any
>,
returnFormat,

@@ -1423,3 +1458,6 @@ },

.catch((error: Error) => {
sub.emit('error', new SubscriptionError('Failed to get past events.', error));
sub.emit(
'error',
new SubscriptionError('Failed to get past events.', error),
);
});

@@ -1426,0 +1464,0 @@ }

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

if (isAbiConstructorFragment(abi)) {

@@ -143,0 +142,0 @@ if (!deployData)

@@ -19,4 +19,9 @@ /*

import { RLP } from '@ethereumjs/rlp';
import { InvalidAddressError, InvalidMethodParamsError, InvalidNumberError, Web3ContractError } from 'web3-errors';
import {
InvalidAddressError,
InvalidMethodParamsError,
InvalidNumberError,
Web3ContractError,
} from 'web3-errors';
import {
TransactionForAccessList,

@@ -34,3 +39,10 @@ AbiFunctionFragment,

} from 'web3-types';
import { isNullish, mergeDeep, isContractInitOptions, keccak256, toChecksumAddress, hexToNumber } from 'web3-utils';
import {
isNullish,
mergeDeep,
isContractInitOptions,
keccak256,
toChecksumAddress,
hexToNumber,
} from 'web3-utils';
import { isAddress, isHexString } from 'web3-validator';

@@ -220,32 +232,29 @@ import { encodeMethodABI } from './encoding.js';

export const createContractAddress = (from: Address, nonce: Numbers): Address => {
if(!isAddress(from))
throw new InvalidAddressError(`Invalid address given ${from}`);
if (!isAddress(from)) throw new InvalidAddressError(`Invalid address given ${from}`);
let nonceValue = nonce;
if(typeof nonce === "string" && isHexString(nonce))
nonceValue = hexToNumber(nonce);
else if(typeof nonce === "string" && !isHexString(nonce))
throw new InvalidNumberError("Invalid nonce value format");
if (typeof nonce === 'string' && isHexString(nonce)) nonceValue = hexToNumber(nonce);
else if (typeof nonce === 'string' && !isHexString(nonce))
throw new InvalidNumberError('Invalid nonce value format');
const rlpEncoded = RLP.encode(
[from, nonceValue]
);
const result = keccak256(rlpEncoded);
const rlpEncoded = RLP.encode([from, nonceValue]);
const result = keccak256(rlpEncoded);
const contractAddress = '0x'.concat(result.substring(26));
const contractAddress = '0x'.concat(result.substring(26));
return toChecksumAddress(contractAddress);
}
return toChecksumAddress(contractAddress);
};
export const create2ContractAddress = (from: Address, salt: HexString, initCode: HexString): Address => {
if(!isAddress(from))
throw new InvalidAddressError(`Invalid address given ${from}`);
export const create2ContractAddress = (
from: Address,
salt: HexString,
initCode: HexString,
): Address => {
if (!isAddress(from)) throw new InvalidAddressError(`Invalid address given ${from}`);
if(!isHexString(salt))
throw new InvalidMethodParamsError(`Invalid salt value ${salt}`);
if (!isHexString(salt)) throw new InvalidMethodParamsError(`Invalid salt value ${salt}`);
if(!isHexString(initCode))
throw new InvalidMethodParamsError(`Invalid initCode value ${initCode}`);
if (!isHexString(initCode))
throw new InvalidMethodParamsError(`Invalid initCode value ${initCode}`);

@@ -255,5 +264,5 @@ const initCodeHash = keccak256(initCode);

const create2Params = ['0xff', from, salt, initCodeHashPadded].map(x => x.replace(/0x/, ''));
const create2Address = `0x${ create2Params.join('')}`;
const create2Address = `0x${create2Params.join('')}`;
return toChecksumAddress(`0x${ keccak256(create2Address).slice(26)}`); // Slice to get the last 20 bytes (40 hex characters) & checksum
}
return toChecksumAddress(`0x${keccak256(create2Address).slice(26)}`); // Slice to get the last 20 bytes (40 hex characters) & checksum
};

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