-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web3ValidatorError validates wrong type #6965
Comments
Hey @AlbertFiat24 ! moving this from discord to here for better visibility, i actually just tried to interact with that code and it returns a const { Web3 } = require("web3");
const abi = require("./arbitrum-abi.json"); //ABI from here
const web3 = new Web3("https://arbitrum.llamarpc.com");
async function main() {
const contract = new web3.eth.Contract(abi, "0x88d936bba8360a560f1eae770dc7eea4a901c169");
const response = await contract.methods.userLockedAmount("0x2c5d06f591D0d8cd43Ac232c2B654475a142c7DA", 909).call();
console.log(response);
}
main(); |
Hello @SantiagoDevRel this issue happens with the web3 tree-shaking when using the "web3-eth-contract": "4.3.0". |
I believe I have found the cause behind this issue. The mapping(address => mapping(
string => mapping(
address => uint256
)
)
) public delegations; [
{
"type": "function",
"name": "delegations",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "string",
"internalType": "string"
},
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
}
] This results in these items not getting an web3.js/packages/web3-validator/src/utils.ts Lines 142 to 145 in 578ebb6
Since they do not get an ID, the following check fails (the set has just one blank id and the number of items is more than 1).
Consequently, only the first element of the array is considered within the schema. In your case that is
The fix is simple and I will send it in a pull request. |
In the case of public mappings, the ABI generated has a blank name set. This results in blank ids for such inputs within the JSON schema. Post 1f81ff0, the number of unique ids is used to convert the JSON scheme into Zod, and hence the presence of blank ids is a concern. This commit generates the `abiName` if one is not provided to a value equal to the `${level}/${index}`. Fixes web3#6965.
@MaxMustermann2 many thanks for the quick fixing! |
* fix(validator): generate abi name if not provided In the case of public mappings, the ABI generated has a blank name set. This results in blank ids for such inputs within the JSON schema. Post 1f81ff0, the number of unique ids is used to convert the JSON scheme into Zod, and hence the presence of blank ids is a concern. This commit generates the `abiName` if one is not provided to a value equal to the `${level}/${index}`. Fixes #6965. * fix: add validator changes to root CHANGELOG --------- Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
In Arbitrum Mainnet, somehow when trying to use a smart contract method of params method(address, uint)
Web3 validator always says to me that the /1 param needs to be of type address.
The contract is: 0x88d936bba8360a560f1eae770dc7eea4a901c169 and the Read method is userLockedAmount
It used to work until 2-3 weeks ago on "web3-eth-contract": "4.2.0", when I refreshed the dependencies it began giving the error or updating to 4.3.0
In Arbiscan it works correctly.
https://arbiscan.io/address/0x88d936bba8360a560f1eae770dc7eea4a901c169#readProxyContract#F12
Steps to reproduce the behavior
where FIAT24LOCK_ABI = [{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"Fiat24Lock__NotLocker","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"Fiat24Lock__NotOperator","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"currency","type":"address"}],"name":"Fiat24Lock__NotSufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"currency","type":"address"}],"name":"Fiat24Lock__NotValidToken","type":"error"},{"inputs":[],"name":"Fiat24Lock__Suspended","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Fiat24Lock__TokenIdNotLive","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CASHDESK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOCKER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUNDRY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"currency_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"currencyTotalLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiat24AccountAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fiat24AccountAddress_","type":"address"},{"internalType":"address","name":"usd24_","type":"address"},{"internalType":"address","name":"eur24_","type":"address"},{"internalType":"address","name":"chf24_","type":"address"},{"internalType":"address","name":"gbp24_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"address","name":"currency_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"address","name":"currency_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"setLockedAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"validXXX24Tokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Logs
Web3ValidatorError: Web3 validator found 1 error[s]: value "909" at "/1" must pass "address" validation
Environment
Arbitrum Mainnet / Sepolia
"web3-eth-contract": "4.3.0",
The text was updated successfully, but these errors were encountered: