-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add recipient address to streams when nonexistent #1890
Conversation
WalkthroughThe changes involve modifications to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
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 and nitpick comments (2)
src/resolvers/anchorContractAddressResolver.ts (2)
64-64
: Remove unnecessary non-null assertion.The non-null assertion (
!
) is redundant sincerecipientAddress
is already known to be defined within this if block.- address: recipientAddress!, + address: recipientAddress,
77-82
: Enhance error message specificity.The error message could be more helpful by including the network ID in the message to help users understand which network is missing the recipient address.
throw new Error( i18n.__( - translationErrorMessagesKeys.PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_THIS_NETWORK, + translationErrorMessagesKeys.PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_NETWORK, + { networkId } ), );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/resolvers/anchorContractAddressResolver.ts
(3 hunks)
🔇 Additional comments (3)
src/resolvers/anchorContractAddressResolver.ts (3)
17-19
: LGTM! Imports are well-organized and relevant.
The new imports appropriately support the added recipient address functionality.
30-30
: LGTM! Parameter addition follows GraphQL best practices.
The optional recipientAddress parameter is properly typed and decorated.
60-82
: Verify error message key and mutation usage.
Let's ensure the error message key exists and check how this mutation is used in the codebase.
✅ Verification successful
Error message key exists and implementation looks correct
The verification shows that:
- The error message key
PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_THIS_NETWORK
is properly defined insrc/utils/errorMessages.ts
- The error message is appropriately used in both the resolver and its test file
- The mutation appears to be self-contained within the resolver and its test file, suggesting it's a new feature or an internal implementation
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if the error message key exists
rg "PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_THIS_NETWORK" -A 1 -B 1
# Check for mutation usage in the codebase
rg "addAnchorContractAddress.*recipientAddress.*" -g "*.{ts,tsx,graphql}"
Length of output: 1238
Script:
#!/bin/bash
# Let's check for GraphQL mutations and their usage
rg "mutation.*addAnchorContractAddress" -g "*.{graphql,ts,tsx}" -A 5
# Check for any tests related to this mutation
rg "addAnchorContractAddress.*test" -g "*.test.{ts,tsx}"
# Check for frontend components or pages using this mutation
rg "useAddAnchorContractAddress|ADD_ANCHOR_CONTRACT_ADDRESS" -g "*.{ts,tsx}"
Length of output: 301
if (recipientAddress) { | ||
const recipientAddressInput = { | ||
project, | ||
user: creatorUser, | ||
address: recipientAddress!, | ||
chainType: ChainType.EVM, | ||
networkId: networkId, | ||
isRecipient: true, | ||
}; | ||
|
||
await validateProjectRelatedAddresses( | ||
[recipientAddressInput], | ||
projectId, | ||
); | ||
|
||
await addBulkNewProjectAddress([recipientAddressInput]); | ||
} else { |
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.
🛠️ Refactor suggestion
Add address format validation before processing.
The recipient address should be validated for proper format before attempting to create and validate the input object.
if (recipientAddress) {
+ if (!ethers.utils.isAddress(recipientAddress)) {
+ throw new Error(
+ i18n.__(translationErrorMessagesKeys.INVALID_ADDRESS_FORMAT)
+ );
+ }
+
const recipientAddressInput = {
project,
user: creatorUser,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (recipientAddress) { | |
const recipientAddressInput = { | |
project, | |
user: creatorUser, | |
address: recipientAddress!, | |
chainType: ChainType.EVM, | |
networkId: networkId, | |
isRecipient: true, | |
}; | |
await validateProjectRelatedAddresses( | |
[recipientAddressInput], | |
projectId, | |
); | |
await addBulkNewProjectAddress([recipientAddressInput]); | |
} else { | |
if (recipientAddress) { | |
if (!ethers.utils.isAddress(recipientAddress)) { | |
throw new Error( | |
i18n.__(translationErrorMessagesKeys.INVALID_ADDRESS_FORMAT) | |
); | |
} | |
const recipientAddressInput = { | |
project, | |
user: creatorUser, | |
address: recipientAddress!, | |
chainType: ChainType.EVM, | |
networkId: networkId, | |
isRecipient: true, | |
}; | |
await validateProjectRelatedAddresses( | |
[recipientAddressInput], | |
projectId, | |
); | |
await addBulkNewProjectAddress([recipientAddressInput]); | |
} else { |
* add includeUnlisted to FilterProjectQueryInputParams * return proper projects * add recipient address to streams when nonexistent (#1890) --------- Co-authored-by: Cherik <[email protected]>
Related to: https://github.com/orgs/Giveth/projects/9/views/3?pane=issue&itemId=88761136&issue=Giveth%7Cimpact-graph%7C1878
Summary by CodeRabbit
recipientAddress
argument in theaddAnchorContractAddress
mutation method.recipientAddress
is not provided, ensuring appropriate error messaging.