Skip to content

Commit

Permalink
feat: fix up small code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 2, 2023
1 parent 51ee636 commit 6798b64
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 51 deletions.
62 changes: 18 additions & 44 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ PODS:
- ExpoModulesCore
- EXFont (11.1.1):
- ExpoModulesCore
- EXImageLoader (4.4.0):
- EXImageLoader (4.3.0):
- ExpoModulesCore
- React-Core
- Expo (48.0.21):
- Expo (48.0.20):
- ExpoModulesCore
- ExpoDocumentPicker (11.7.0):
- ExpoDocumentPicker (11.5.4):
- ExpoModulesCore
- ExpoImagePicker (14.5.0):
- ExpoImagePicker (14.3.2):
- ExpoModulesCore
- ExpoKeepAwake (12.0.1):
- ExpoModulesCore
Expand Down Expand Up @@ -302,11 +302,11 @@ PODS:
- React-jsinspector (0.71.8)
- React-logger (0.71.8):
- glog
- react-native-blob-util (0.19.4):
- react-native-blob-util (0.19.0):
- React-Core
- react-native-encrypted-storage (4.0.3):
- React-Core
- react-native-mmkv (2.11.0):
- react-native-mmkv (2.8.0):
- MMKV (>= 1.2.13)
- React-Core
- react-native-safe-area-context (4.5.0):
Expand Down Expand Up @@ -402,7 +402,7 @@ PODS:
- RNScreens (3.20.0):
- React-Core
- React-RCTImage
- RNSVG (13.14.0):
- RNSVG (13.9.0):
- React-Core
- secp256k1.swift (0.1.4)
- SwiftProtobuf (1.20.3)
Expand All @@ -411,27 +411,15 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
<<<<<<< HEAD
- XMTP (0.6.13-alpha0):
||||||| 22b79fa
- XMTP (0.6.9-alpha0):
=======
- XMTP (0.6.12-alpha0):
>>>>>>> 123a9aac9c3b5da7d4cd71489a173fcea05442f4
- XMTP (0.6.14-alpha0):
- Connect-Swift (= 0.3.0)
- GzipSwift
- web3.swift
- XMTPRust (= 0.3.6-beta0)
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
<<<<<<< HEAD
- XMTP (= 0.6.13-alpha0)
||||||| 22b79fa
- XMTP (= 0.6.9-alpha0)
=======
- XMTP (= 0.6.12-alpha0)
>>>>>>> 123a9aac9c3b5da7d4cd71489a173fcea05442f4
- XMTP (= 0.6.14-alpha0)
- XMTPRust (0.3.6-beta0)
- Yoga (1.14.0)

Expand Down Expand Up @@ -625,10 +613,10 @@ SPEC CHECKSUMS:
EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9
EXFileSystem: 844e86ca9b5375486ecc4ef06d3838d5597d895d
EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272
EXImageLoader: 03063370bc06ea1825713d3f55fe0455f7c88d04
Expo: 0d9f112757acc6bf32103eabccf91267780bd580
ExpoDocumentPicker: d3b6b0ed2dbbc2f05158e0294dd3f4673f386e5f
ExpoImagePicker: 9e5c745cb3e56ee00e1cfe5d6af59caab66ecf1a
EXImageLoader: 34b214f9387e98f3c73989f15d8d5b399c9ab3f7
Expo: b7d2843b0a0027d0ce76121a63085764355a16ed
ExpoDocumentPicker: 5cb7389ff935b4addefdd466a606de51a512e922
ExpoImagePicker: c58fdf28be551681a8edc550bcec76c397a8dfcd
ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a
ExpoModulesCore: 653958063a301098b541ae4dfed1ac0b98db607b
EXSplashScreen: 0e0a9ba0cf7553094e93213099bd7b42e6e237e9
Expand Down Expand Up @@ -658,9 +646,9 @@ SPEC CHECKSUMS:
React-jsiexecutor: 747911ab5921641b4ed7e4900065896597142125
React-jsinspector: c712f9e3bb9ba4122d6b82b4f906448b8a281580
React-logger: 342f358b8decfbf8f272367f4eacf4b6154061be
react-native-blob-util: 30a6c9fd067aadf9177e61a998f2c7efb670598d
react-native-blob-util: 2b6627b288e3bd9874704ea9a153f0a179e4f3f5
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43
react-native-mmkv: 7da5e18e55c04a9af9a7e0ab9792a1e8d33765a1
react-native-safe-area-context: 39c2d8be3328df5d437ac1700f4f3a4f75716acc
React-perflogger: d21f182895de9d1b077f8a3cd00011095c8c9100
React-RCTActionSheet: 0151f83ef92d2a7139bba7dfdbc8066632a6d47b
Expand All @@ -676,29 +664,15 @@ SPEC CHECKSUMS:
React-runtimeexecutor: 7c51ae9d4b3e9608a2366e39ccaa606aa551b9ed
ReactCommon: 85c98ab0a509e70bf5ee5d9715cf68dbf495b84c
RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f
RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396
RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
<<<<<<< HEAD
XMTP: 7ef0bd61b7f32209e175b6089e71bf82f0238530
XMTPReactNative: 778f5b7ee88c2d80926e989f4c8c1963da749a50
||||||| 22b79fa
XMTP: 245855791631fa66f022d0d3ce9d9aebd7ca3146
XMTPReactNative: 2ef288363bc42f97014ea4744264a1679774f36d
=======
XMTP: a1c4aaae8e0b05c95223a75c055dc120962760fb
XMTPReactNative: c1cb2c303284405b3a09c0fd9b21972d03762b22
>>>>>>> 123a9aac9c3b5da7d4cd71489a173fcea05442f4
XMTP: 5314a5151dbfad2e24bb5910e679052916a9faff
XMTPReactNative: 5e393ab43d402bae404f675245cfc66a078a33ff
XMTPRust: 3c958736a4f4ee798e425b5644551f1c948da4b0
Yoga: 065f0b74dba4832d6e328238de46eb72c5de9556

PODFILE CHECKSUM: 522d88edc2d5fac4825e60a121c24abc18983367

<<<<<<< HEAD
COCOAPODS: 1.11.3
||||||| 22b79fa
COCOAPODS: 1.13.0
=======
COCOAPODS: 1.14.2
>>>>>>> 123a9aac9c3b5da7d4cd71489a173fcea05442f4
6 changes: 3 additions & 3 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,11 @@ test('canManagePreferences', async () => {
})

test("is address in the XMTP network", async () => {

Check warning on line 678 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"is·address·in·the·XMTP·network"` with `'is·address·in·the·XMTP·network'`
const alix = await XMTP.Client.createRandom({ env: "local" });
const alix = await Client.createRandom({ env: "local" });

Check warning on line 679 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"local"·});` with `'local'·})`
const notOnNetwork = "0x0000000000000000000000000000000000000000"

Check warning on line 680 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"0x0000000000000000000000000000000000000000"` with `'0x0000000000000000000000000000000000000000'`

Check warning on line 681 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
const isAlixAddressAvailable = await XMTP.staticCanMessage(alix.address, 'local');
const isAddressAvailable = await XMTP.Client.canMessage(notOnNetwork, { env: "local" });
const isAlixAddressAvailable = await Client.canMessage(alix.address, 'local');

Check warning on line 682 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
const isAddressAvailable = await Client.canMessage(notOnNetwork, { env: "local" });

Check warning on line 683 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·env:·"local"·});` with `⏎····env:·'local',⏎··})`

if (!isAlixAddressAvailable) {
throw new Error('alix address should be available');

Check warning on line 686 in example/src/tests.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
Expand Down
7 changes: 3 additions & 4 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,10 @@ public class XMTPModule: Module {

AsyncFunction("staticCanMessage") { (peerAddress: String, environment: String, appVersion: String?) -> Bool in
do {
let options = createClientConfig(env: environment, appVersion: appVersion)
return try await XMTP.Client.canMessage(peerAddress, options: options)
let options = createClientConfig(env: environment, appVersion: appVersion)
return try await XMTP.Client.canMessage(peerAddress, options: options)
} catch {
print("ERRO! canMessage method: \(error)")
throw error
throw Error.noClient
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ export class Client<ContentTypes> {
return await XMTPModule.canMessage(this.address, peerAddress)
}

/**
* Static method to determine if the address is currently in our network.
*
* This method checks if the specified peer has signed up for XMTP.
*
* @param {string} peerAddress - The address of the peer to check for messaging eligibility.
* @param {Partial<ClientOptions>} opts - Optional configuration options for the Client.
* @returns {Promise<boolean>}
*/

static async canMessage(peerAddress: string, opts?: Partial<ClientOptions>): Promise<boolean> {
const options = defaultOptions(opts);
return await XMTPModule.staticCanMessage(peerAddress, options.env, options.appVersion);
}

constructor(
address: string,
codecs: XMTPModule.ContentCodec<ContentTypes>[] = []
Expand Down

0 comments on commit 6798b64

Please sign in to comment.