diff --git a/components/DebugButton.tsx b/components/DebugButton.tsx index 103714d2a..b1db13b18 100644 --- a/components/DebugButton.tsx +++ b/components/DebugButton.tsx @@ -111,11 +111,11 @@ const DebugButton = forwardRef((props, ref) => { const client = (await getXmtpClient(currentAccount())) as Client; const state = await client.inboxState(true); Alert.alert( - `${state.installationIds.length} installations`, + `${state.installations.length} installations`, `InboxId: ${client.inboxId}\n\nCurrent installation: ${ client.installationId - }\n\nAll installations:\n\n${state.installationIds - .map((i) => `${i}`) + }\n\nAll installations:\n\n${state.installations + .map((i) => `${i.id}`) .join("\n\n")}` ); }, diff --git a/ios/ConverseNotificationExtension/Spam.swift b/ios/ConverseNotificationExtension/Spam.swift index 81b249c3f..b5ec5cd4b 100644 --- a/ios/ConverseNotificationExtension/Spam.swift +++ b/ios/ConverseNotificationExtension/Spam.swift @@ -92,28 +92,28 @@ func computeSpamScoreGroupWelcome(client: XMTP.Client, group: XMTP.Group, apiURI do { let consentList = try await client.contacts.refreshConsentList() // Probably an unlikely case until consent proofs for groups exist - let groupAllowed = await client.contacts.isGroupAllowed(groupId: group.id) + let groupAllowed = try await client.contacts.isGroupAllowed(groupId: group.id) if groupAllowed { return -1 } let inviterInboxId = try group.addedByInboxId() - let inviterAllowed = await client.contacts.isInboxAllowed(inboxId: inviterInboxId) + let inviterAllowed = try await client.contacts.isInboxAllowed(inboxId: inviterInboxId) if inviterAllowed { return -1 } - let inviterDenied = await client.contacts.isInboxDenied(inboxId: inviterInboxId) + let inviterDenied = try await client.contacts.isInboxDenied(inboxId: inviterInboxId) if inviterDenied { return 1 } - let members = try group.members + let members = try await group.members if let inviterAddresses = members.first(where: {$0.inboxId == inviterInboxId})?.addresses { for address in inviterAddresses { - if await client.contacts.isDenied(EthereumAddress(address).toChecksumAddress()) { + if try await client.contacts.isDenied(EthereumAddress(address).toChecksumAddress()) { return 1 } } for address in inviterAddresses { - if await client.contacts.isAllowed(EthereumAddress(address).toChecksumAddress()) { + if try await client.contacts.isAllowed(EthereumAddress(address).toChecksumAddress()) { return -1 } } @@ -135,39 +135,39 @@ func computeSpamScoreGroupMessage(client: XMTP.Client, group: XMTP.Group, decode do { try await client.contacts.refreshConsentList() - let groupDenied = await client.contacts.isGroupDenied(groupId: group.id) + let groupDenied = try await client.contacts.isGroupDenied(groupId: group.id) if groupDenied { // Network consent will override other checks return 1 } let senderInboxId = decodedMessage.senderAddress - let senderDenied = await client.contacts.isInboxDenied(inboxId: senderInboxId) + let senderDenied = try await client.contacts.isInboxDenied(inboxId: senderInboxId) if senderDenied { // Network consent will override other checks return 1 } - let senderAllowed = await client.contacts.isInboxAllowed(inboxId: senderInboxId) + let senderAllowed = try await client.contacts.isInboxAllowed(inboxId: senderInboxId) if senderAllowed { // Network consent will override other checks return -1 } - let groupAllowed = await client.contacts.isGroupAllowed(groupId: group.id) + let groupAllowed = try await client.contacts.isGroupAllowed(groupId: group.id) if groupAllowed { // Network consent will override other checks return -1 } - if let senderAddresses = try group.members.first(where: {$0.inboxId == senderInboxId})?.addresses { + if let senderAddresses = try await group.members.first(where: {$0.inboxId == senderInboxId})?.addresses { for address in senderAddresses { - if await client.contacts.isDenied(EthereumAddress(address).toChecksumAddress()) { + if try await client.contacts.isDenied(EthereumAddress(address).toChecksumAddress()) { return 1 } } for address in senderAddresses { - if await client.contacts.isAllowed(EthereumAddress(address).toChecksumAddress()) { + if try await client.contacts.isAllowed(EthereumAddress(address).toChecksumAddress()) { return -1 } } diff --git a/ios/ConverseNotificationExtension/Xmtp/Messages.swift b/ios/ConverseNotificationExtension/Xmtp/Messages.swift index 7b65736c2..038206001 100644 --- a/ios/ConverseNotificationExtension/Xmtp/Messages.swift +++ b/ios/ConverseNotificationExtension/Xmtp/Messages.swift @@ -118,8 +118,8 @@ func handleGroupWelcome(xmtpClient: XMTP.Client, apiURI: String?, pushToken: Str let spamScore = await computeSpamScoreGroupWelcome(client: xmtpClient, group: group, apiURI: apiURI) if spamScore < 0 { // Message is going to main inbox // Consent list is loaded in computeSpamScoreGroupWelcome - let groupAllowed = await xmtpClient.contacts.isGroupAllowed(groupId: group.id) - let groupDenied = await xmtpClient.contacts.isGroupDenied(groupId: group.id) + let groupAllowed = try await xmtpClient.contacts.isGroupAllowed(groupId: group.id) + let groupDenied = try await xmtpClient.contacts.isGroupDenied(groupId: group.id) // If group is already consented (either way) then don't show a notification for welcome as this will likely be a second+ installation if !groupAllowed && !groupDenied { shouldShowNotification = true @@ -157,7 +157,7 @@ func handleGroupMessage(xmtpClient: XMTP.Client, envelope: XMTP.Envelope, apiURI // For now, use the group member linked address as "senderAddress" // @todo => make inboxId a first class citizen - if let senderAddresses = try group.members.first(where: {$0.inboxId == decodedMessage.senderAddress})?.addresses { + if let senderAddresses = try await group.members.first(where: {$0.inboxId == decodedMessage.senderAddress})?.addresses { decodedMessage.senderAddress = senderAddresses[0] } diff --git a/ios/Podfile b/ios/Podfile index 419f04d64..04c8a39d6 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -17,8 +17,8 @@ install! 'cocoapods', # Version must match version from XMTP Podspec (matching @xmtp/react-native-sdk from package.json) -# https://github.com/xmtp/xmtp-react-native/blob/v2.5.4/ios/XMTPReactNative.podspec#L29 -$xmtpVersion = '0.14.13' +# https://github.com/xmtp/xmtp-react-native/blob/v2.6.2/ios/XMTPReactNative.podspec#L29 +$xmtpVersion = '0.14.18' # Pinning MMKV to 1.3.3 that has included that fix https://github.com/Tencent/MMKV/pull/1222#issuecomment-1905164314 $mmkvVersion = '1.3.3' diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 099a59268..d0073ca88 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -389,7 +389,7 @@ PODS: - libwebp/sharpyuv (1.3.2) - libwebp/webp (1.3.2): - libwebp/sharpyuv - - LibXMTP (0.5.8-beta5) + - LibXMTP (0.5.8-beta7) - Logging (1.0.0) - MessagePacker (0.4.7) - MMKV (1.3.3): @@ -1815,16 +1815,16 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.14.13): + - XMTP (0.14.18): - Connect-Swift (= 0.12.0) - GzipSwift - - LibXMTP (= 0.5.8-beta5) + - LibXMTP (= 0.5.8-beta7) - web3.swift - - XMTPReactNative (2.5.4): + - XMTPReactNative (2.6.2): - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.14.13) + - XMTP (= 0.14.18) - Yoga (0.0.0) DEPENDENCIES: @@ -1962,7 +1962,7 @@ DEPENDENCIES: - Sentry/HybridSDK (= 8.36.0) - SQLite.swift - UMAppLoader (from `../node_modules/unimodules-app-loader/ios`) - - XMTP (= 0.14.13) + - XMTP (= 0.14.18) - "XMTPReactNative (from `../node_modules/@xmtp/react-native-sdk/ios`)" - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) @@ -2316,7 +2316,7 @@ SPEC CHECKSUMS: libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7 libdav1d: 23581a4d8ec811ff171ed5e2e05cd27bad64c39f libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009 - LibXMTP: ee1591fdb51bc6cc690c1a9ba10792ccc2104328 + LibXMTP: 693447f2c1242dd2f5b2146828c52dbb2bd92d6f Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 MMKV: f902fb6719da13c2ab0965233d8963a59416f911 @@ -2416,10 +2416,10 @@ SPEC CHECKSUMS: SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 UMAppLoader: f17a5ee8e85b536ace0fc254b447a37ed198d57e web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: a9e7382ec5b57eeda3df7b177f034d061e3c9b61 - XMTPReactNative: 63c46d6ba9b8dc5831ea49e8716f4b60cc012651 + XMTP: ad01d17d7b513704b00033ee72ed544e48d38fcf + XMTPReactNative: fbdd0dfd7737bf2b27bd9265e140e1677f8f5a30 Yoga: 1ab23c1835475da69cf14e211a560e73aab24cb0 -PODFILE CHECKSUM: beb6a8b55061fc0f811288dc66c75239474eba01 +PODFILE CHECKSUM: bf2c4dd4d3291947d3f8f49dc3dfbee65c4c4e6c COCOAPODS: 1.15.2 diff --git a/package.json b/package.json index eb85899ba..c78dfce17 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@xmtp/content-type-transaction-reference": "^1.0.3", "@xmtp/frames-client": "^0.5.0", "@xmtp/proto": "^3.60.0", - "@xmtp/react-native-sdk": "^2.5.4", + "@xmtp/react-native-sdk": "^2.6.2", "@xmtp/xmtp-js": "11.5.0", "amazon-cognito-identity-js": "^6.3.12", "axios": "^1.2.1", diff --git a/utils/xmtpRN/client.ts b/utils/xmtpRN/client.ts index 04e0e7362..f7574e14e 100644 --- a/utils/xmtpRN/client.ts +++ b/utils/xmtpRN/client.ts @@ -99,10 +99,11 @@ export const reconnectXmtpClientsDbConnections = async () => { export const isClientInstallationValid = async (client: Client) => { const inboxState = await client.inboxState(true); + const installationsIds = inboxState.installations.map((i) => i.id); logger.debug( - `Current installation id : ${client.installationId} - All installation ids : ${inboxState.installationIds}` + `Current installation id : ${client.installationId} - All installation ids : ${installationsIds}` ); - if (!inboxState.installationIds.includes(client.installationId)) { + if (!installationsIds.includes(client.installationId)) { logger.warn(`Installation ${client.installationId} has been revoked`); return false; } else { diff --git a/utils/xmtpRN/signIn.ts b/utils/xmtpRN/signIn.ts index 20a5023d8..30170e275 100644 --- a/utils/xmtpRN/signIn.ts +++ b/utils/xmtpRN/signIn.ts @@ -1,6 +1,3 @@ -import { debugEnabled } from "@components/DebugButton"; -import { translate } from "@i18n"; -import { awaitableAlert } from "@utils/alert"; import { copyDatabasesToTemporaryDirectory, createTemporaryDirectory, @@ -78,43 +75,3 @@ export const getXmtpBase64KeyFromSigner = async ( logger.debug("Exported key bundle"); return base64Key; }; - -/* -Temporary method for XMTP team to revoke other installations -when logging in to remove weird, broken installation -*/ -const revokeOtherInstallations = async (signer: Signer, client: Client) => { - if (!debugEnabled(client.address)) { - return; - } - const state = await client.inboxState(true); - logger.debug( - `Current installation id : ${client.installationId} - All installation ids : ${state.installationIds}` - ); - const otherInstallations = state.installationIds.filter( - (installationId) => installationId !== client.installationId - ); - if (otherInstallations.length > 0) { - logger.warn( - `Inbox ${client.inboxId} has ${otherInstallations.length} installations to revoke` - ); - // We're on a mobile wallet so we need to ask the user first - const doRevoke = await awaitableAlert( - translate("other_installations_count", { - count: otherInstallations.length, - }), - translate("temporary_revoke_description"), - "Yes", - "No" - ); - if (!doRevoke) { - logger.debug(`[Onboarding] User decided not to revoke`); - return; - } - logger.debug( - `[Onboarding] User decided to revoke ${otherInstallations.length} installation` - ); - await client.revokeAllOtherInstallations(signer); - logger.debug(`[Onboarding] Installations revoked.`); - } -}; diff --git a/yarn.lock b/yarn.lock index 97c5e153e..23856869f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9588,10 +9588,10 @@ rxjs "^7.8.0" undici "^5.8.1" -"@xmtp/react-native-sdk@^2.5.4": - version "2.5.4" - resolved "https://registry.yarnpkg.com/@xmtp/react-native-sdk/-/react-native-sdk-2.5.4.tgz#6869eeaa0f479971b923ca67ee54784d6e15d748" - integrity sha512-oujHd59zJpbMtT1IzL7K2YlhcYEU7u9hcH2fRw5xAgttqecYxTWZmzqHCKLD7t6RxuCBr/4adXSFqhmaJPpAJA== +"@xmtp/react-native-sdk@^2.6.2": + version "2.6.2" + resolved "https://registry.yarnpkg.com/@xmtp/react-native-sdk/-/react-native-sdk-2.6.2.tgz#1e39a24822147fdc16cd795ca3b4aae1d6aa2f53" + integrity sha512-KB5sWM+sxjjTzIoHuhQhu8szOeYj5gU/Ba0MX/gOiQYpeVhVwO88KJKEp2JzJz3p+6AeT0nCrLn1dLVB9BrueQ== dependencies: "@ethersproject/bytes" "^5.7.0" "@msgpack/msgpack" "^3.0.0-beta2"