-
Notifications
You must be signed in to change notification settings - Fork 31
adds the ability to run example app tests against d14n testnet staging #774
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package expo.modules.xmtpreactnativesdk.wrappers | ||
|
|
||
| import android.util.Base64 | ||
| import com.google.gson.GsonBuilder | ||
| import org.xmtp.android.library.libxmtp.AvailableArchive | ||
|
|
||
| class AvailableArchiveWrapper { | ||
| companion object { | ||
| private val gson = GsonBuilder().create() | ||
|
|
||
| fun encodeToObj(archive: AvailableArchive): Map<String, Any?> = mapOf( | ||
| "pin" to archive.pin, | ||
| "metadata" to ArchiveMetadataWrapper.encodeToMap(archive.metadata), | ||
| "sentByInstallation" to Base64.encodeToString(archive.sentByInstallation, Base64.NO_WRAP), | ||
| ) | ||
|
|
||
| fun encodeList(archives: List<AvailableArchive>): String { | ||
| val list = archives.map { encodeToObj(it) } | ||
| return gson.toJson(list) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| TEST_PRIVATE_KEY=INSERT_TEST_PRIVATE_KEY_HERE | ||
| THIRD_WEB_CLIENT_ID=INSERT_CLIENT_ID_HERE | ||
| GATEWAY_HOST=D14N_GATEWAY_PAYER_HOST_URL_HERE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * Expo config plugin: injects react-native-config's dotenv.gradle into the Android app build | ||
| * so that .env is loaded into BuildConfig and Config.* works on Android (same as iOS). | ||
| * Without this, env vars work on iOS but not Android after prebuild. | ||
| * | ||
| * @see https://github.com/luggit/react-native-config#android | ||
| */ | ||
| const { withAppBuildGradle } = require('expo/config-plugins') | ||
|
|
||
| const DOTENV_LINE = | ||
| 'apply from: project.file("../../node_modules/react-native-config/android/dotenv.gradle")' | ||
| const COMMENT = | ||
| '// Load .env into BuildConfig so react-native-config Config.* works on Android (required for env vars in JS)' | ||
|
|
||
| function withReactNativeConfigEnv(config) { | ||
| return withAppBuildGradle(config, (config) => { | ||
| const contents = config.modResults.contents | ||
| if (contents.includes('react-native-config/android/dotenv.gradle')) { | ||
| return config | ||
| } | ||
| const afterPlugins = contents.indexOf('apply plugin: "com.facebook.react"') | ||
| if (afterPlugins === -1) { | ||
| return config | ||
| } | ||
| const insertAt = contents.indexOf('\n', afterPlugins) + 1 | ||
|
Comment on lines
+21
to
+25
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. 🟢 Low If - const insertAt = contents.indexOf('\n', afterPlugins) + 1
+ const nextNewline = contents.indexOf('\n', afterPlugins)
+ const insertAt = nextNewline === -1 ? contents.length : nextNewline + 1🚀 Reply "fix it for me" or copy this AI Prompt for your agent: |
||
| const before = contents.slice(0, insertAt) | ||
| const after = contents.slice(insertAt) | ||
| config.modResults.contents = | ||
| before + '\n' + COMMENT + '\n' + DOTENV_LINE + '\n\n' + after | ||
| return config | ||
| }) | ||
| } | ||
|
|
||
| module.exports = withReactNativeConfigEnv | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /** | ||
| * Test environment selection for createClients() when no env is passed. | ||
| * Set from LaunchScreen; read from test-utils. Default is 'local'. | ||
| * - local: XMTP local network | ||
| * - dev: XMTP dev network | ||
| * - d14n: dev network with custom gateway (uses GATEWAY_HOST from .env) | ||
| */ | ||
| export type TestEnvOption = 'local' | 'dev' | 'd14n' | ||
|
|
||
| let testEnv: TestEnvOption = 'local' | ||
|
|
||
| export function getTestEnv(): TestEnvOption { | ||
| return testEnv | ||
| } | ||
|
|
||
| export function setTestEnv(value: TestEnvOption): void { | ||
| testEnv = value | ||
| } |
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.
🟡 Medium
wrappers/ArchiveMetadataWrapper.kt:42encodeToMapreturns"messages"(plural) for the null-metadata default, butgetArchiveElementStringreturns"message"(singular) forArchiveElement.MESSAGESand the catch block fallback also uses"message". Downstream consumers expecting consistent element names receive"messages"when metadata is null but"message"when encoding succeeds or fails.🚀 Reply "fix it for me" or copy this AI Prompt for your agent: