-
Notifications
You must be signed in to change notification settings - Fork 7
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
chore: Bump Xmtp #1323
chore: Bump Xmtp #1323
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,11 @@ | |
|
||
import Foundation | ||
import Alamofire | ||
import web3 | ||
|
||
func getProfile(account: String, address: String) async -> Profile? { | ||
var profileState = getProfilesStore(account: account)?.state | ||
let lowercasedAddress = address.lowercased() | ||
let formattedAddress = EthereumAddress(lowercasedAddress).toChecksumAddress() | ||
if let profile = profileState?.profiles?[address] ?? profileState?.profiles?[formattedAddress] ?? profileState?.profiles?[lowercasedAddress] { | ||
let formattedAddress = address.lowercased() | ||
if let profile = profileState?.profiles?[address] ?? profileState?.profiles?[formattedAddress] { | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add address format validation While removing the web3 dependency simplifies the code, we should still validate the Ethereum address format to prevent invalid addresses from being processed. Consider adding a simple regex validation: +func isValidEthereumAddress(_ address: String) -> Bool {
+ let pattern = "^0x[0-9a-fA-F]{40}$"
+ return address.range(of: pattern, options: .regularExpression) != nil
+}
func getProfile(account: String, address: String) async -> Profile? {
var profileState = getProfilesStore(account: account)?.state
+ guard isValidEthereumAddress(address) else { return nil }
let formattedAddress = address.lowercased()
|
||
return profile | ||
} | ||
|
||
|
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
Consider handling undefined messages more gracefully
While the null check for
group.lastMessage
improves safety, there's still a non-null assertion (!
) being used when passing the message toPinnedMessagePreview
. This could be problematic if the message becomes null between the check and render.Consider this safer approach: