Skip to content

Commit

Permalink
Merge branch 'custom-content-types' of https://github.com/xmtp/xmtp-r…
Browse files Browse the repository at this point in the history
…eact-native into np/custom-content-types-android
  • Loading branch information
nplasterer committed Nov 28, 2023
2 parents e3fb360 + 22213a6 commit 25541cc
Show file tree
Hide file tree
Showing 36 changed files with 9,406 additions and 11,372 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
root: true,
extends: ["universe/native", "universe/web"],
ignorePatterns: ["build"],
};
extends: ['universe/native', 'universe/web'],
ignorePatterns: ['build'],
plugins: ['prettier'],
globals: {
__dirname: true,
},
}
13 changes: 13 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint
on:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- run: npm install
- run: npm run eslint
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: false,
singleQuote: true,
trailingComma: 'es5',
arrowParens: 'always',
printWidth: 80,
}
52 changes: 26 additions & 26 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from "react";
import { NavigationContainer } from '@react-navigation/native'
import React from 'react'
import { Button } from 'react-native'
import { QueryClient, QueryClientProvider } from 'react-query'

import LaunchScreen from "./src/LaunchScreen";
import TestScreen from "./src/TestScreen";
import HomeScreen from "./src/HomeScreen";
import ConversationScreen from "./src/ConversationScreen";
import ConversationCreateScreen from "./src/ConversationCreateScreen";
import { NavigationContainer } from "@react-navigation/native";
import { XmtpContextProvider } from "./src/XmtpContext";
import { Navigator } from "./src/Navigation";
import { QueryClient, QueryClientProvider } from "react-query";
import { Button } from "react-native";
import ConversationCreateScreen from './src/ConversationCreateScreen'
import ConversationScreen from './src/ConversationScreen'
import HomeScreen from './src/HomeScreen'
import LaunchScreen from './src/LaunchScreen'
import { Navigator } from './src/Navigation'
import TestScreen from './src/TestScreen'
import { XmtpContextProvider } from './src/XmtpContext'

const queryClient = new QueryClient();
const queryClient = new QueryClient()
export default function App() {
return (
<QueryClientProvider client={queryClient}>
Expand All @@ -22,36 +22,36 @@ export default function App() {
name="launch"
component={LaunchScreen}
options={{
title: "XMTP RN Example",
title: 'XMTP RN Example',
headerStyle: {
backgroundColor: "rgb(49 0 110)",
backgroundColor: 'rgb(49 0 110)',
},
headerTintColor: "#fff",
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: "bold",
fontWeight: 'bold',
},
}}
/>
<Navigator.Screen
name="test"
component={TestScreen}
options={{ title: "Unit Tests" }}
options={{ title: 'Unit Tests' }}
/>
<Navigator.Screen
name="home"
component={HomeScreen}
options={({ navigation }) => ({
title: "My Conversations",
title: 'My Conversations',
headerStyle: {
backgroundColor: "rgb(49 0 110)",
backgroundColor: 'rgb(49 0 110)',
},
headerTintColor: "#fff",
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: "bold",
fontWeight: 'bold',
},
headerRight: () => (
<Button
onPress={() => navigation.navigate("conversationCreate")}
onPress={() => navigation.navigate('conversationCreate')}
title="New"
color="#fff"
/>
Expand All @@ -61,17 +61,17 @@ export default function App() {
<Navigator.Screen
name="conversation"
component={ConversationScreen}
options={{ title: "Conversation" }}
initialParams={{ topic: "" }}
options={{ title: 'Conversation' }}
initialParams={{ topic: '' }}
/>
<Navigator.Screen
name="conversationCreate"
component={ConversationCreateScreen}
options={{ title: "New Conversation" }}
options={{ title: 'New Conversation' }}
/>
</Navigator.Navigator>
</NavigationContainer>
</XmtpContextProvider>
</QueryClientProvider>
);
)
}
24 changes: 12 additions & 12 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const path = require("path");
const path = require('path')
module.exports = function (api) {
api.cache(true);
api.cache(true)
return {
presets: ["babel-preset-expo"],
presets: ['babel-preset-expo'],
plugins: [
[
"module-resolver",
'module-resolver',
{
extensions: [".tsx", ".ts", ".js", ".json"],
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: {
// For development, we want to alias the library to the source
"xmtp-react-native-sdk": path.join(
'xmtp-react-native-sdk': path.join(
__dirname,
"..",
"src",
"index.ts",
'..',
'src',
'index.ts'
),
},
},
],
"@babel/plugin-proposal-export-namespace-from",
'@babel/plugin-proposal-export-namespace-from',
],
};
};
}
}
30 changes: 15 additions & 15 deletions example/dev/local/test/script.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
let Client = require("@xmtp/xmtp-js").Client;
let Wallet = require("ethers").Wallet;
const Client = require('@xmtp/xmtp-js').Client
const Wallet = require('ethers').Wallet

console.log("NODE VERSION", process.version);
console.log('NODE VERSION', process.version)

// 0xf4BF19Ed562651837bc11ff975472ABd239D35B5
const keyBytes = [
80, 7, 53, 52, 122, 163, 75, 130, 199, 86, 216, 14, 29, 2, 255, 71, 121, 51,
165, 3, 208, 178, 193, 207, 223, 217, 75, 247, 84, 78, 204, 3,
];
]

async function checkAll() {
const wallet = new Wallet(keyBytes);
const wallet = new Wallet(keyBytes)
const client = await Client.create(wallet, {
apiUrl: "http://wakunode:5555",
});
apiUrl: 'http://wakunode:5555',
})

console.log("Listening…");
console.log('Listening…')

try {
for await (const message of await client.conversations.streamAllMessages()) {
if (message.senderAddress === wallet.address) {
continue;
continue
}

await message.conversation.send({
text: "HI " + message.senderAddress,
});
console.log(`Replied to ${message.senderAddress}`);
text: 'HI ' + message.senderAddress,
})
console.log(`Replied to ${message.senderAddress}`)
}
} catch (e) {
console.info(`Error:`, e);
await checkAll();
console.info(`Error:`, e)
await checkAll()
}
}

checkAll().then(() => console.log("Done"));
checkAll().then(() => console.log('Done'))
6 changes: 3 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { registerRootComponent } from "expo";
import { registerRootComponent } from 'expo'

import App from "./App";
import App from './App'

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
registerRootComponent(App)
26 changes: 13 additions & 13 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");
const { getDefaultConfig } = require('expo/metro-config')
const path = require('path')

const config = getDefaultConfig(__dirname);
const extraNodeModules = require("node-libs-browser");
config.resolver.extraNodeModules = extraNodeModules;
const config = getDefaultConfig(__dirname)
const extraNodeModules = require('node-libs-browser')
config.resolver.extraNodeModules = extraNodeModules
// npm v7+ will install ../node_modules/react-native because of peerDependencies.
// To prevent the incompatible react-native bewtween ./node_modules/react-native and ../node_modules/react-native,
// excludes the one from the parent folder when bundling.
config.resolver.blockList = [
...Array.from(config.resolver.blockList ?? []),
new RegExp(path.resolve("..", "node_modules", "react-native")),
];
new RegExp(path.resolve('..', 'node_modules', 'react-native')),
]

config.resolver.nodeModulesPaths = [
path.resolve(__dirname, "./node_modules"),
path.resolve(__dirname, "../node_modules"),
];
path.resolve(__dirname, './node_modules'),
path.resolve(__dirname, '../node_modules'),
]

config.watchFolders = [path.resolve(__dirname, "..")];
config.watchFolders = [path.resolve(__dirname, '..')]

config.transformer.getTransformOptions = async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
});
})

module.exports = config;
module.exports = config
Loading

0 comments on commit 25541cc

Please sign in to comment.