Socket
Socket
Sign inDemoInstall

web3-eth-contract

Package Overview
Dependencies
Maintainers
4
Versions
452
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.3.0 to 4.3.1-dev.526c6f5.0

37

lib/commonjs/contract.js

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

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());
}

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

const contractMethod = this._createContractMethod(abiFragment, errorsAbi);
const exactContractMethod = this._createContractMethod(abiFragment, errorsAbi, true);
this._functions[methodName] = {

@@ -573,6 +573,7 @@ signature: methodSignature,

// We don't know a particular type of the Abi method so can't type check
this._methods[methodName] = this._functions[methodName].method;
this._methods[methodName] =
exactContractMethod;
// We don't know a particular type of the Abi method so can't type check
this._methods[methodSignature] = this
._functions[methodName].method;
this._methods[methodSignature] =
exactContractMethod;
}

@@ -609,8 +610,11 @@ else if ((0, web3_eth_abi_1.isAbiEventFragment)(abi)) {

}
_createContractMethod(abiArr, errorsAbis) {
_createContractMethod(abiArr, errorsAbis, exact = false) {
const abi = abiArr[abiArr.length - 1];
return (...params) => {
var _a, _b;
var _a, _b, _c;
let abiParams;
const abis = (_a = this._overloadedMethodAbis.get(abi.name)) !== null && _a !== void 0 ? _a : [];
const abis = (_b = (exact
? (_a = this._overloadedMethodAbis
.get(abi.name)) === null || _a === void 0 ? void 0 : _a.filter(_abi => _abi.signature === abi.signature)
: this._overloadedMethodAbis.get(abi.name))) !== null && _b !== void 0 ? _b : [];
let methodAbi = abis[0];

@@ -621,6 +625,8 @@ const internalErrorsAbis = errorsAbis;

abiParams = this._getAbiParams(methodAbi, params);
web3_validator_1.validator.validate((_b = abi.inputs) !== null && _b !== void 0 ? _b : [], abiParams);
web3_validator_1.validator.validate((_c = abi.inputs) !== null && _c !== void 0 ? _c : [], abiParams);
}
else {
const errors = [];
// all the methods that have is valid for the given inputs
const applicableMethodAbi = [];
for (const _abi of arrayOfAbis) {

@@ -630,4 +636,3 @@ try {

web3_validator_1.validator.validate(_abi.inputs, abiParams);
methodAbi = _abi;
break;
applicableMethodAbi.push(_abi);
}

@@ -638,2 +643,12 @@ catch (e) {

}
if (applicableMethodAbi.length === 1) {
[methodAbi] = applicableMethodAbi; // take the first item that is the only item in the array
}
else {
[methodAbi] = applicableMethodAbi; // take the first item in the array
// TODO: Should throw a new error with the list of methods found.
// This is in order to provide an error message when there is more than one method found that fits the inputs.
// To do that, replace the pervious line of code with something like the following line:
// throw new Web3ValidatorError({ message: 'Multiple methods found', ... list of applicable methods }));
}
if (errors.length === arrayOfAbis.length) {

@@ -640,0 +655,0 @@ throw new web3_validator_1.Web3ValidatorError(errors);

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

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());
}

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

const contractMethod = this._createContractMethod(abiFragment, errorsAbi);
const exactContractMethod = this._createContractMethod(abiFragment, errorsAbi, true);
this._functions[methodName] = {

@@ -570,6 +570,7 @@ signature: methodSignature,

// We don't know a particular type of the Abi method so can't type check
this._methods[methodName] = this._functions[methodName].method;
this._methods[methodName] =
exactContractMethod;
// We don't know a particular type of the Abi method so can't type check
this._methods[methodSignature] = this
._functions[methodName].method;
this._methods[methodSignature] =
exactContractMethod;
}

@@ -606,8 +607,11 @@ else if (isAbiEventFragment(abi)) {

}
_createContractMethod(abiArr, errorsAbis) {
_createContractMethod(abiArr, errorsAbis, exact = false) {
const abi = abiArr[abiArr.length - 1];
return (...params) => {
var _a, _b;
var _a, _b, _c;
let abiParams;
const abis = (_a = this._overloadedMethodAbis.get(abi.name)) !== null && _a !== void 0 ? _a : [];
const abis = (_b = (exact
? (_a = this._overloadedMethodAbis
.get(abi.name)) === null || _a === void 0 ? void 0 : _a.filter(_abi => _abi.signature === abi.signature)
: this._overloadedMethodAbis.get(abi.name))) !== null && _b !== void 0 ? _b : [];
let methodAbi = abis[0];

@@ -618,6 +622,8 @@ const internalErrorsAbis = errorsAbis;

abiParams = this._getAbiParams(methodAbi, params);
validator.validate((_b = abi.inputs) !== null && _b !== void 0 ? _b : [], abiParams);
validator.validate((_c = abi.inputs) !== null && _c !== void 0 ? _c : [], abiParams);
}
else {
const errors = [];
// all the methods that have is valid for the given inputs
const applicableMethodAbi = [];
for (const _abi of arrayOfAbis) {

@@ -627,4 +633,3 @@ try {

validator.validate(_abi.inputs, abiParams);
methodAbi = _abi;
break;
applicableMethodAbi.push(_abi);
}

@@ -635,2 +640,12 @@ catch (e) {

}
if (applicableMethodAbi.length === 1) {
[methodAbi] = applicableMethodAbi; // take the first item that is the only item in the array
}
else {
[methodAbi] = applicableMethodAbi; // take the first item in the array
// TODO: Should throw a new error with the list of methods found.
// This is in order to provide an error message when there is more than one method found that fits the inputs.
// To do that, replace the pervious line of code with something like the following line:
// throw new Web3ValidatorError({ message: 'Multiple methods found', ... list of applicable methods }));
}
if (errors.length === arrayOfAbis.length) {

@@ -637,0 +652,0 @@ throw new Web3ValidatorError(errors);

{
"name": "web3-eth-contract",
"version": "4.3.0",
"version": "4.3.1-dev.526c6f5.0+526c6f5",
"description": "Web3 module to interact with Ethereum smart contracts.",

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

"dependencies": {
"web3-core": "^4.3.2",
"web3-errors": "^1.1.4",
"web3-eth": "^4.5.0",
"web3-eth-abi": "^4.2.0",
"web3-types": "^1.5.0",
"web3-utils": "^4.2.2",
"web3-validator": "^2.0.5"
"web3-core": "4.3.3-dev.526c6f5.0+526c6f5",
"web3-errors": "1.1.5-dev.526c6f5.0+526c6f5",
"web3-eth": "4.5.1-dev.526c6f5.0+526c6f5",
"web3-eth-abi": "4.2.1-dev.526c6f5.0+526c6f5",
"web3-types": "1.5.1-dev.526c6f5.0+526c6f5",
"web3-utils": "4.2.3-dev.526c6f5.0+526c6f5",
"web3-validator": "2.0.6-dev.526c6f5.0+526c6f5"
},

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

"typescript": "^4.7.4",
"web3-eth-accounts": "^4.1.1",
"web3-providers-ws": "^4.0.7"
"web3-eth-accounts": "4.1.2-dev.526c6f5.0+526c6f5",
"web3-providers-ws": "4.0.8-dev.526c6f5.0+526c6f5"
},
"gitHead": "7379a3bb3c274eff76c64b2447e95c34282e04fd"
"gitHead": "526c6f518f6a23438907b119aadbc868b06fbcd6"
}

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

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

@@ -1007,6 +1006,11 @@ }

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

@@ -1024,9 +1028,8 @@ this._functions[methodName] = {

// We don't know a particular type of the Abi method so can't type check
this._methods[methodName as keyof ContractMethodsInterface<Abi>] = this._functions[
methodName
].method as never;
this._methods[methodName as keyof ContractMethodsInterface<Abi>] =
exactContractMethod as never;
// We don't know a particular type of the Abi method so can't type check
this._methods[methodSignature as keyof ContractMethodsInterface<Abi>] = this
._functions[methodName].method as never;
this._methods[methodSignature as keyof ContractMethodsInterface<Abi>] =
exactContractMethod as never;
} else if (isAbiEventFragment(abi)) {

@@ -1070,2 +1073,3 @@ const eventName = jsonInterfaceMethodToString(abi);

errorsAbis: E[],
exact = false, // when true, it will only match the exact method signature
): ContractBoundMethod<T[0]> {

@@ -1075,3 +1079,8 @@ const abi = abiArr[abiArr.length - 1];

let abiParams!: Array<unknown>;
const abis = this._overloadedMethodAbis.get(abi.name) ?? [];
const abis =
(exact
? this._overloadedMethodAbis
.get(abi.name)
?.filter(_abi => _abi.signature === abi.signature)
: this._overloadedMethodAbis.get(abi.name)) ?? [];
let methodAbi: AbiFunctionFragment = abis[0];

@@ -1090,11 +1099,9 @@ const internalErrorsAbis = errorsAbis;

// all the methods that have is valid for the given inputs
const applicableMethodAbi: AbiFunctionFragment[] = [];
for (const _abi of arrayOfAbis) {
try {
abiParams = this._getAbiParams(_abi, params);
validator.validate(
_abi.inputs as unknown as ValidationSchemaInput,
abiParams,
);
methodAbi = _abi;
break;
validator.validate(_abi.inputs as unknown as ValidationSchemaInput, abiParams);
applicableMethodAbi.push(_abi);
} catch (e) {

@@ -1104,2 +1111,11 @@ errors.push(e as Web3ValidationErrorObject);

}
if (applicableMethodAbi.length === 1) {
[methodAbi] = applicableMethodAbi; // take the first item that is the only item in the array
} else {
[methodAbi] = applicableMethodAbi; // take the first item in the array
// TODO: Should throw a new error with the list of methods found.
// This is in order to provide an error message when there is more than one method found that fits the inputs.
// To do that, replace the pervious line of code with something like the following line:
// throw new Web3ValidatorError({ message: 'Multiple methods found', ... list of applicable methods }));
}
if (errors.length === arrayOfAbis.length) {

@@ -1106,0 +1122,0 @@ throw new Web3ValidatorError(errors);

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