You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pragma solidity ^0.8.0;
mapping(bytes32 => CredentialSchema) private schemas; // mapping to store schema ID to schema details mapping
function getSchema(bytes32 _guid) public view returns (CredentialSchema memory) {
require(isSchemaIdExists(_guid) == true, "Schema with this GUID does not exist");
return schemas[_guid];
}
// Function to check if a schema ID already exists
function isSchemaIdExists(bytes32 _guid) private view returns (bool) {
return schemas[_guid].guid != bytes32(0);
}
When any existing guid is being passed it returns the correct schema. Following are the tests for above function which works fine while testing through hardhat. i.e It is reverting with the correct message.
it("Should prevent fetching non-existent schema", async function () {
await expect(
schemaRegistry.getSchema(schema.guid.replace("a", "b").replace("c", "d"))
).to.be.revertedWith("Schema with this GUID does not exist");
});
Actual behavior
But when being called from web3js it throws AbiError: Parameter decoding error: decoded value is less then minimum for given type
async function getSchemaByGuid(guid) {
try {
console.debug("Getting schema by guid: ", guid);
const result = await schemaRegistryContract.methods.getSchema(guid).call();
return result;
} catch (error) {
throw error;
}
}
Logs
following is the error log:
AbiError: Parameter decoding error: decoded value is less then minimum for given type
at decodeParametersWith (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:103:15)
at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:213:75)
at decodeMethodReturn (.../node_modules/web3-eth-contract/lib/commonjs/encoding.js:136:56)
at ContractBuilder.<anonymous> (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:773:61)
at Generator.next (<anonymous>)
at fulfilled (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:21:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
innerError: undefined,
code: 205,
props: {
internalErr: AbiError: decoded value is less then minimum for given type
at decodeNumber (.../node_modules/web3-eth-abi/lib/commonjs/coders/base/number.js:94:15)
at decodeTuple (.../node_modules/web3-eth-abi/lib/commonjs/coders/base/tuple.js:99:63)
at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/coders/decode.js:26:39)
at decodeParametersWith (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:100:49)
at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:213:75)
at decodeMethodReturn (.../node_modules/web3-eth-contract/lib/commonjs/encoding.js:136:56)
at ContractBuilder.<anonymous> (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:773:61)
at Generator.next (<anonymous>)
at fulfilled (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:21:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
innerError: undefined,
code: 205,
props: [Object]
}
}
}
Expected behavior
for the following code:
When any existing guid is being passed it returns the correct schema. Following are the tests for above function which works fine while testing through hardhat. i.e It is reverting with the correct message.
Actual behavior
But when being called from web3js it throws
AbiError: Parameter decoding error: decoded value is less then minimum for given type
Logs
following is the error log:
Environment
The text was updated successfully, but these errors were encountered: