-
Notifications
You must be signed in to change notification settings - Fork 2
chore(web): show-creator-address-on-list-preview #79
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
Conversation
WalkthroughThe update modifies the internal logic of the Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for curate-v2 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
web/src/utils/submitListUtils.ts (1)
76-92: 🛠️ Refactor suggestionConsider making the utility function pure for better testing.
The function now depends on an external state (the connected account), making it less predictable and harder to test.
Refactor to maintain function purity:
-export const constructItemWithMockValues = (data: IListMetadata): ItemDetailsFragment => { - const { address } = useAccount(); +export const constructItemWithMockValues = (data: IListMetadata, userAddress?: string): ItemDetailsFragment => { const props: ListField & { value: ReturnType<typeof getMockValueForType> }[] = []; for (const column of data.columns) { props.push({ ...column, value: getMockValueForType(column.type) }); } return { id: "1", status: Status.RegistrationRequested, disputed: false, registerer: { - id: address ?? (getMockValueForType("address") as string), + id: userAddress ?? (getMockValueForType("address") as string), }, props, }; };Then in your component:
const MyComponent = () => { const { address } = useAccount(); // Now you can safely pass the address to the utility function const itemWithMockValues = constructItemWithMockValues(listMetadata, address); // Rest of the component }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/src/utils/submitListUtils.ts(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - curate-v2
- GitHub Check: Header rules - curate-v2
- GitHub Check: Pages changed - curate-v2
🔇 Additional comments (2)
web/src/utils/submitListUtils.ts (2)
9-9: Add the useAccount hook import.The import of
useAccountfrom wagmi is correctly added to access the user's Ethereum address.
88-89: Good implementation of fallback mechanism.The use of the nullish coalescing operator (
??) to fallback to a mock address when no user address is available is a good practice.However, this needs to be updated based on the recommended change to pass the address as a parameter:
- id: address ?? (getMockValueForType("address") as string), + id: userAddress ?? (getMockValueForType("address") as string),
PR-Codex overview
This PR introduces the use of the
useAccounthook fromwagmito retrieve the user's account address, which enhances the functionality of theconstructItemWithMockValuesfunction by ensuring that theregisterer.idcan utilize the current user's address.Detailed summary
useAccountimport fromwagmi.constructItemWithMockValuesto retrieveaddressfromuseAccount.registerer.idto use the current user'saddress, falling back to a mock value if not available.Summary by CodeRabbit