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: sequential nano contract register fails on second one #656

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

andreabadesso
Copy link
Contributor

@andreabadesso andreabadesso commented Feb 20, 2025

After a send nano contract success, if you stay in the success screen and attempt to register a new nano contract, the register will fail until the app is restarted.

Acceptance Criteria

  • We should be able to register nano contracts after a success

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@andreabadesso andreabadesso self-assigned this Feb 20, 2025
@andreabadesso andreabadesso added the bug Something isn't working label Feb 20, 2025
@@ -91,10 +91,10 @@ export const NewNanoContractTransactionRequest = ({ ncTxRequest }) => {
* transaction.
*/
const [ncAddress, setNcAddress] = useState(registeredNc?.address || firstAddress.address);
const ncToAccept = useMemo(() => ({
const ncToAccept = {
Copy link

@raul-oliveira raul-oliveira Feb 21, 2025

Choose a reason for hiding this comment

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

Since ncToAccept is nested, removing useMemo could indeed negatively affect performance due to unnecessary re-renders and object re-creations, especially if passed as a prop or dependency to components or hooks.

Below is a suggestion, have you tried it?
const ncToAccept = useMemo(() => ({ ...nc, caller: ncAddress, }), [nc, ncAddress]);

Did you face any specific issue with useMemo that led you to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored it to still use useMemo and passed ncAddress as a dependency, thanks!

ca7d6e6

@andreabadesso andreabadesso merged commit 2953066 into master Feb 24, 2025
1 check passed
@andreabadesso andreabadesso deleted the fix/register-nc branch February 24, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Waiting to be deployed
Development

Successfully merging this pull request may close these issues.

3 participants