web3-eth-contract
Advanced tools
Comparing version 4.3.0 to 4.3.1-dev.526c6f5.0
@@ -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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
372835
6785
2
1
- Removed@ethereumjs/rlp@4.0.1(transitive)
- Removed@noble/curves@1.4.2(transitive)
- Removed@noble/hashes@1.4.0(transitive)
- Removed@scure/base@1.1.9(transitive)
- Removed@scure/bip32@1.4.0(transitive)
- Removed@scure/bip39@1.3.0(transitive)
- Removed@types/node@22.7.4(transitive)
- Removed@types/ws@8.5.3(transitive)
- Removedabitype@0.7.1(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcrc-32@1.2.2(transitive)
- Removedcross-fetch@4.0.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedethereum-cryptography@2.2.1(transitive)
- Removedeventemitter3@5.0.1(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedisomorphic-ws@5.0.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedtr46@0.0.3(transitive)
- Removedtypescript@5.6.2(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedutil@0.12.5(transitive)
- Removedweb3-core@4.6.0(transitive)
- Removedweb3-errors@1.3.0(transitive)
- Removedweb3-eth@4.9.0(transitive)
- Removedweb3-eth-abi@4.2.4(transitive)
- Removedweb3-eth-accounts@4.2.1(transitive)
- Removedweb3-eth-iban@4.0.7(transitive)
- Removedweb3-net@4.1.0(transitive)
- Removedweb3-providers-http@4.2.0(transitive)
- Removedweb3-providers-ipc@4.0.7(transitive)
- Removedweb3-providers-ws@4.0.8(transitive)
- Removedweb3-rpc-methods@1.3.0(transitive)
- Removedweb3-types@1.8.0(transitive)
- Removedweb3-utils@4.3.1(transitive)
- Removedweb3-validator@2.0.6(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
- Removedws@8.18.0(transitive)
- Removedzod@3.23.8(transitive)