From 0227f519f2e70668f381f56eca8a4ee2cfed6c31 Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Wed, 24 Jul 2024 12:06:47 -0700 Subject: [PATCH] lint fixes --- .../project.pbxproj | 10 +- .../ios/xmtpreactnativesdkexample/Info.plist | 158 +++++++++--------- example/src/tests/groupPermissionsTests.ts | 62 +++++-- example/src/tests/groupTests.ts | 2 +- example/src/tests/tests.ts | 7 +- src/lib/Conversations.ts | 6 +- 6 files changed, 137 insertions(+), 108 deletions(-) diff --git a/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj b/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj index 3388e7aa2..614829088 100644 --- a/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj +++ b/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj @@ -221,7 +221,7 @@ LastUpgradeCheck = 1130; TargetAttributes = { 13B07F861A680F5B00A75B9A = { - DevelopmentTeam = FY4NZR34Z3; + DevelopmentTeam = 65GVVS9K6W; LastSwiftMigration = 1250; }; A6A5DB842A00551E001DF8C2 = { @@ -408,7 +408,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = xmtpreactnativesdkexample/xmtpreactnativesdkexample.entitlements; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = FY4NZR34Z3; + DEVELOPMENT_TEAM = 65GVVS9K6W; ENABLE_BITCODE = NO; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -424,7 +424,7 @@ "-lc++", ); OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; - PRODUCT_BUNDLE_IDENTIFIER = expo.modules.xmtpreactnativesdk.example; + PRODUCT_BUNDLE_IDENTIFIER = cvoell.modules.xmtpreactnativesdk.example; PRODUCT_NAME = xmtpreactnativesdkexample; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -441,7 +441,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = xmtpreactnativesdkexample/xmtpreactnativesdkexample.entitlements; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = FY4NZR34Z3; + DEVELOPMENT_TEAM = 65GVVS9K6W; INFOPLIST_FILE = xmtpreactnativesdkexample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -452,7 +452,7 @@ "-lc++", ); OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; - PRODUCT_BUNDLE_IDENTIFIER = expo.modules.xmtpreactnativesdk.example; + PRODUCT_BUNDLE_IDENTIFIER = cvoell.modules.xmtpreactnativesdk.example; PRODUCT_NAME = xmtpreactnativesdkexample; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/example/ios/xmtpreactnativesdkexample/Info.plist b/example/ios/xmtpreactnativesdkexample/Info.plist index ce646d17c..bd85f227a 100644 --- a/example/ios/xmtpreactnativesdkexample/Info.plist +++ b/example/ios/xmtpreactnativesdkexample/Info.plist @@ -1,82 +1,82 @@ - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - xmtp-react-native-sdk-example - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0.0 - CFBundleSignature - ???? - CFBundleURLTypes - - - CFBundleURLSchemes - - expo.modules.xmtpreactnativesdk.example - - - - CFBundleVersion - 1 - LSRequiresIPhoneOS - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSExceptionDomains - - localhost - - NSExceptionAllowsInsecureHTTPLoads - - - - - NSCameraUsageDescription - The app accesses your camera to let you attach photos as messages. - NSMicrophoneUsageDescription - Allow $(PRODUCT_NAME) to access your microphone - NSPhotoLibraryUsageDescription - The app accesses your photos to let you attach them as messages. - UILaunchStoryboardName - SplashScreen - UIRequiredDeviceCapabilities - - armv7 - - UIRequiresFullScreen - - UIStatusBarStyle - UIStatusBarStyleDefault - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIUserInterfaceStyle - Light - UIViewControllerBasedStatusBarAppearance - - - \ No newline at end of file + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + xmtp-react-native-sdk-example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleURLSchemes + + expo.modules.xmtpreactnativesdk.example + + + + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSExceptionDomains + + localhost + + NSExceptionAllowsInsecureHTTPLoads + + + + + NSCameraUsageDescription + The app accesses your camera to let you attach photos as messages. + NSMicrophoneUsageDescription + Allow $(PRODUCT_NAME) to access your microphone + NSPhotoLibraryUsageDescription + The app accesses your photos to let you attach them as messages. + UILaunchStoryboardName + SplashScreen + UIRequiredDeviceCapabilities + + armv7 + + UIRequiresFullScreen + + UIStatusBarStyle + UIStatusBarStyleDefault + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIUserInterfaceStyle + Light + UIViewControllerBasedStatusBarAppearance + + + diff --git a/example/src/tests/groupPermissionsTests.ts b/example/src/tests/groupPermissionsTests.ts index cbff2c77c..22463a9f7 100644 --- a/example/src/tests/groupPermissionsTests.ts +++ b/example/src/tests/groupPermissionsTests.ts @@ -1,7 +1,7 @@ -import { permissionPolicySet } from 'xmtp-react-native-sdk' -import { Test, assert, createClients } from './test-utils' import { PermissionPolicySet } from 'xmtp-react-native-sdk/lib/types/PermissionPolicySet' +import { Test, assert, createClients } from './test-utils' + export const groupPermissionsTests: Test[] = [] let counter = 1 function test(name: string, perform: () => Promise) { @@ -540,14 +540,44 @@ test('can create a group with custom permissions', async () => { await alix.conversations.syncGroups() const alixGroup = (await alix.conversations.listGroups())[0] const permissions = await alixGroup.permissionPolicySet() - assert(permissions.addMemberPolicy === customPermissionsPolicySet.addMemberPolicy, `permissions.addMemberPolicy should be ${customPermissionsPolicySet.addMemberPolicy} but was ${permissions.addMemberPolicy}`) - assert(permissions.removeMemberPolicy === customPermissionsPolicySet.removeMemberPolicy, `permissions.removeMemberPolicy should be ${customPermissionsPolicySet.removeMemberPolicy} but was ${permissions.removeMemberPolicy}`) - assert(permissions.addAdminPolicy === customPermissionsPolicySet.addAdminPolicy, `permissions.addAdminPolicy should be ${customPermissionsPolicySet.addAdminPolicy} but was ${permissions.addAdminPolicy}`) - assert(permissions.removeAdminPolicy === customPermissionsPolicySet.removeAdminPolicy, `permissions.removeAdminPolicy should be ${customPermissionsPolicySet.removeAdminPolicy} but was ${permissions.removeAdminPolicy}`) - assert(permissions.updateGroupNamePolicy === customPermissionsPolicySet.updateGroupNamePolicy, `permissions.updateGroupNamePolicy should be ${customPermissionsPolicySet.updateGroupNamePolicy} but was ${permissions.updateGroupNamePolicy}`) - assert(permissions.updateGroupDescriptionPolicy === customPermissionsPolicySet.updateGroupDescriptionPolicy, `permissions.updateGroupDescriptionPolicy should be ${customPermissionsPolicySet.updateGroupDescriptionPolicy} but was ${permissions.updateGroupDescriptionPolicy}`) - assert(permissions.updateGroupImagePolicy === customPermissionsPolicySet.updateGroupImagePolicy, `permissions.updateGroupImagePolicy should be ${customPermissionsPolicySet.updateGroupImagePolicy} but was ${permissions.updateGroupImagePolicy}`) - assert(permissions.updateGroupPinnedFrameUrlPolicy === customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy, `permissions.updateGroupPinnedFrameUrlPolicy should be ${customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy} but was ${permissions.updateGroupPinnedFrameUrlPolicy}`) + assert( + permissions.addMemberPolicy === customPermissionsPolicySet.addMemberPolicy, + `permissions.addMemberPolicy should be ${customPermissionsPolicySet.addMemberPolicy} but was ${permissions.addMemberPolicy}` + ) + assert( + permissions.removeMemberPolicy === + customPermissionsPolicySet.removeMemberPolicy, + `permissions.removeMemberPolicy should be ${customPermissionsPolicySet.removeMemberPolicy} but was ${permissions.removeMemberPolicy}` + ) + assert( + permissions.addAdminPolicy === customPermissionsPolicySet.addAdminPolicy, + `permissions.addAdminPolicy should be ${customPermissionsPolicySet.addAdminPolicy} but was ${permissions.addAdminPolicy}` + ) + assert( + permissions.removeAdminPolicy === + customPermissionsPolicySet.removeAdminPolicy, + `permissions.removeAdminPolicy should be ${customPermissionsPolicySet.removeAdminPolicy} but was ${permissions.removeAdminPolicy}` + ) + assert( + permissions.updateGroupNamePolicy === + customPermissionsPolicySet.updateGroupNamePolicy, + `permissions.updateGroupNamePolicy should be ${customPermissionsPolicySet.updateGroupNamePolicy} but was ${permissions.updateGroupNamePolicy}` + ) + assert( + permissions.updateGroupDescriptionPolicy === + customPermissionsPolicySet.updateGroupDescriptionPolicy, + `permissions.updateGroupDescriptionPolicy should be ${customPermissionsPolicySet.updateGroupDescriptionPolicy} but was ${permissions.updateGroupDescriptionPolicy}` + ) + assert( + permissions.updateGroupImagePolicy === + customPermissionsPolicySet.updateGroupImagePolicy, + `permissions.updateGroupImagePolicy should be ${customPermissionsPolicySet.updateGroupImagePolicy} but was ${permissions.updateGroupImagePolicy}` + ) + assert( + permissions.updateGroupPinnedFrameUrlPolicy === + customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy, + `permissions.updateGroupPinnedFrameUrlPolicy should be ${customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy} but was ${permissions.updateGroupPinnedFrameUrlPolicy}` + ) // Verify that bo can not update the pinned frame even though they are a super admin try { @@ -556,7 +586,7 @@ test('can create a group with custom permissions', async () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (error) { // expected - } + } // Verify that alix can update the group description await alixGroup.updateGroupDescription('new description') @@ -596,14 +626,14 @@ test('creating a group with invalid permissions should fail', async () => { // Bo creates a group with Alix and Caro try { - const boGroup = await bo.conversations.newGroupCustomPermissions( + await bo.conversations.newGroupCustomPermissions( [alix.address, caro.address], - customPermissionsPolicySet - ) - assert(false, 'Group creation should fail') + customPermissionsPolicySet + ) + assert(false, 'Group creation should fail') + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (error) { // expected } return true }) - diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 756595a3e..e171c9e08 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -31,7 +31,7 @@ test('can make a MLS V3 client', async () => { 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, ]) - const client = await Client.createRandom({ + await Client.createRandom({ env: 'local', appVersion: 'Testing/0.0.0', enableV3: true, diff --git a/example/src/tests/tests.ts b/example/src/tests/tests.ts index b1250276d..ad1b6c6c6 100644 --- a/example/src/tests/tests.ts +++ b/example/src/tests/tests.ts @@ -1,15 +1,14 @@ -import { sha256 } from '@noble/hashes/sha256' import { FramesClient } from '@xmtp/frames-client' -import { content, invitation, signature as signatureProto } from '@xmtp/proto' +import { content, invitation } from '@xmtp/proto' import { createHmac } from 'crypto' import ReactNativeBlobUtil from 'react-native-blob-util' import Config from 'react-native-config' import { TextEncoder, TextDecoder } from 'text-encoding' -import { createWalletClient, custom, PrivateKeyAccount, toHex } from 'viem' +import { PrivateKeyAccount } from 'viem' import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' import { DecodedMessage } from 'xmtp-react-native-sdk/lib/DecodedMessage' -import { Test, assert, createClients, delayToPropogate } from './test-utils' +import { Test, assert, delayToPropogate } from './test-utils' import { Query, JSContentCodec, diff --git a/src/lib/Conversations.ts b/src/lib/Conversations.ts index 7821d1900..c274fdf86 100644 --- a/src/lib/Conversations.ts +++ b/src/lib/Conversations.ts @@ -10,11 +10,11 @@ import { DecodedMessage } from './DecodedMessage' import { Group } from './Group' import { CreateGroupOptions } from './types/CreateGroupOptions' import { EventTypes } from './types/EventTypes' +import { PermissionPolicySet } from './types/PermissionPolicySet' import { ConversationContext } from '../XMTP.types' import * as XMTPModule from '../index' import { ContentCodec } from '../index' import { getAddress } from '../utils/address' -import { PermissionPolicySet } from './types/PermissionPolicySet' export default class Conversations< ContentTypes extends ContentCodec[] = [], @@ -189,7 +189,7 @@ export default class Conversations< ) } - /** + /** * Creates a new group with custom permissions. * * This method creates a new group with the specified peer addresses and options. @@ -199,7 +199,7 @@ export default class Conversations< * @param {CreateGroupOptions} opts - The options to use for the group. * @returns {Promise>} A Promise that resolves to a Group object. */ - async newGroupCustomPermissions( + async newGroupCustomPermissions( peerAddresses: string[], permissionPolicySet: PermissionPolicySet, opts?: CreateGroupOptions | undefined