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
I added a Test interface with int256 indexed topic as follow:
function encodeTopics(name, value) {
var iface = new ethers.Interface([
"event Test(int256 indexed test)"
]);
var filter = iface.encodeFilterTopics("Test", [ value ]);
return filter[1];
}
and run it with encodeTopics("-1"), I got this:
RangeError: unsigned value cannot be negative (fault="overflow", operation="getUint", value="-1", code=NUMERIC_FAULT, version=6.8.1)
This should be able to take negative integers, but toBeHex and getUint function does not allow negative values here. I was expecting -1 to be encoded successfully to (ffffffffff...ffff)
Code Snippet
functionencodeTopics(value) {
var iface = new utils.Interface([
"event Test(int256 indexed test)"
]);
var filter = iface.encodeFilterTopics("Test", [ value ]);return filter[1];
}
encodeTopics("-1")
### Contract ABI
_No response_
### Errors
```shell
RangeError: unsigned value cannot be negative (fault="overflow", operation="getUint", value="-1", code=NUMERIC_FAULT, version=6.8.1)
Environment
No response
Environment (Other)
No response
The text was updated successfully, but these errors were encountered:
Ethers Version
6.8.1
Search Terms
abi, topics, int256
Describe the Problem
I added a Test interface with
int256
indexed topic as follow:and run it with
encodeTopics("-1")
, I got this:This should be able to take negative integers, but
toBeHex
andgetUint
function does not allow negative values here. I was expecting-1
to be encoded successfully to (ffffffffff...ffff
)Code Snippet
Environment
No response
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: