Skip to content
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

Fix displaying of custom solidity errors #638

Merged
merged 10 commits into from Dec 7, 2023

Conversation

technophile-04
Copy link
Collaborator

Description

This problem occurs when you have custom solidity errors and you try to read/write from Debug page :

Test YourContract.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

// Useful for debugging. Remove when deploying to a live network.
import "hardhat/console.sol";

error NOT_OWNER();

error MY_CUSTOM_ERROR(string message, uint value);

contract YourContract {
	// State Variables
	address public immutable owner;
	string public greeting = "Building Unstoppable Apps!!!";
	uint256 public totalCounter = 0;

	constructor(address _owner) {
		owner = _owner;
	}

	modifier isOwner() {
		if (msg.sender != owner) {
			revert NOT_OWNER();
		}
		_;
	}

	function revertWithCustomErrror(bool _shouldRevert) public view {
		if (_shouldRevert) {
			revert MY_CUSTOM_ERROR(
				"Error with my custom message",
				totalCounter
			);
		}
	}

	function revertWithRequire(bool _shouldRevert) public pure {
		require(!_shouldRevert, "Error with require message");
	}

	function setGreeting(string memory _newGreeting) public payable {
		// Change state variables
		greeting = _newGreeting;
		totalCounter += 1;
	}

	function withdraw() public isOwner {
		(bool success, ) = owner.call{ value: address(this).balance }("");
		require(success, "Failed to send Ether");
	}

	receive() external payable {}
}

Before (main branch) :

Screen.Recording.2023-12-03.at.12.13.17.AM.mov

After :

Screen.Recording.2023-12-03.at.12.05.25.AM.mov

Cause :

When passing abi to wagmi's native hooks we were just passing that function abi eg: abi: [functionABI] because of which wagmi was not able to parse the errors.

@carletex
Copy link
Member

carletex commented Dec 4, 2023

Works for me! Great job @technophile-04

Copy link
Collaborator

@damianmarti damianmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement @technophile-04 !!

Everything looks great to me!

One small comment that is related to this change, but it really affects all the notifications. The text is cut in an unfriendly way at the end of each line, like for example on the second video:

github com_scaffold-eth_scaffold-eth-2_pull_638

"reas" -> "on" and "cu" -> "stom". Maybe changing the text-wrap CSS style is enough to fix it. Maybe we can create a new issue for this...

@technophile-04
Copy link
Collaborator Author

The text is cut in an unfriendly way at the end of each line, like for example on the second video:

Ohh yes ! lol it has been bugging me too for a while, just removed word break break-all className at fb2d440 :

Before After
Screenshot 2023-12-07 at 9 37 36 AM Screenshot 2023-12-07 at 9 34 34 AM

Like the Before one looks a bit better and smaller but I think it makes more sense to have After due to its nice readability.

I tried playing with some basic styles like adding positioning absolute to the "X" icon but still it didn't look that great maybe I think its better if we tackle it in another issue and tinker more with styles 🙌

Copy link
Collaborator

@sverps sverps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Added 1 small comment about removing the as any. Besides that, it looks good to go 👍

@carletex
Copy link
Member

carletex commented Dec 7, 2023

Ohh yes ! lol it has been bugging me too for a while, just removed word break break-all className at fb2d440 :

The problem with this is that big strings without spaces go over the edge

image

break-words should work, but it translates into overflow-wrap: break-word which for some reason, doesn't work.

If I apply word-break: break-word it works.

Maybe we need to tweak something about the container?

@carletex
Copy link
Member

carletex commented Dec 7, 2023

break-words should work, but it translates into overflow-wrap: break-word which for some reason, doesn't work.

It seems that overflow-x-hidden break-words make it work

@technophile-04
Copy link
Collaborator Author

The problem with this is that big strings without spaces go over the edge
It seems that overflow-x-hidden break-words make it work

Ohh yes! Tysm for the solution it works great !!, updated at f7e960a

Screenshot 2023-12-07 at 7 48 23 PM

@technophile-04
Copy link
Collaborator Author

Tysm all !! Merging this 🙌

@technophile-04 technophile-04 merged commit fe7024a into main Dec 7, 2023
1 check passed
@technophile-04 technophile-04 deleted the fix/solidity-custom-errors branch December 7, 2023 14:37
@github-actions github-actions bot mentioned this pull request Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants