thirdweb-dev/js

Override "from" on useReadContract

Closed this issue · 6 comments

Ran into an edge case today where I have a public viewable method that uses msg.sender to determine the return value and it seems not possible to send an override of the "from" address on useReadContract.

Please let me know.

Thanks

thanks for the report @larron - this would be very easy to add. mind telling us what contract you're using that has this behavior? helps me test it

@joaquim-verges thanks for the swift response.

Something like this (extending openzeppelin ownable) is a good example:

contract TestOwner is Ownable {
    function test() public {
        if (owner() == msg.sender) {
            return true;
        }
        
        return false;
    }
}

Using the owner account get the test method to return true from the useReadContract

Fixed in #3735 - will be released in the next version shortly

merged!

Excellent, thank you @joaquim-verges

I'll give it a try shortly.

This does look to be working. Thanks again @joaquim-verges