Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 67a949d

Browse files
committed
Merge branch 'upstream-main' into upstream-main-merge-2
2 parents 697c776 + f86f2c1 commit 67a949d

File tree

3 files changed

+8
-69
lines changed

3 files changed

+8
-69
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ NEXT_PUBLIC_INFURA_ID={YOUR_INFURA_ID}
2626

2727
If you do not have an Infura ID, you can follow [these instructions](https://blog.infura.io/getting-started-with-infura-28e41844cc89/) to get one.
2828

29-
_This example comes preconfigured with an Infura ID provided for demonstration purposes. If you plan to fork or host it, you must use your own Infura ID as detailed above._
30-
3129
### Install the package
3230

3331
```bash
@@ -62,6 +60,6 @@ The application uses the `xmtp-js` [Conversations](https://github.com/xmtp/xmtp-
6260
Here are some important considerations when working with the example chat application:
6361

6462
- The application sends and receives messages using the XMTP `dev` network environment. To connect to the `production` network instead, set the following environment variable `NEXT_PUBLIC_XMTP_ENVIRONMENT=production`.
65-
- XMTP may occasionally delete messages and keys from the `dev` network, and will provide advance notice in the XMTP Discord community ([request access](https://xmtp.typeform.com/to/yojTJarb?utm_source=docs_home)). The `production` network is configured to store messages indefinitely.
63+
- XMTP may occasionally delete messages and keys from the `dev` network, and will provide advance notice in the XMTP Discord community ([request access](https://xmtp.typeform.com/to/yojTJarb?utm_source=docs_home)). The `production` network is configured to store messages indefinitely.
6664
- You can't yet send a message to a wallet address that hasn't used XMTP. The client displays an error when it looks up an address that doesn't have an identity broadcast on the XMTP network.
67-
- This limitation will soon be resolved by improvements to the `xmtp-js` library that will allow messages to be created and stored for future delivery, even if the recipient hasn't used XMTP yet.
65+
- This limitation will soon be resolved by improvements to the `xmtp-js` library that will allow messages to be created and stored for future delivery, even if the recipient hasn't used XMTP yet.

hooks/useWalletProvider.tsx

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ let provider: ethers.providers.Web3Provider
2121
const useWalletProvider = () => {
2222
const { open: openWeb3Modal, isOpen } = useWeb3Modal()
2323
const { data: signer } = useSigner()
24-
// useWalletProvider()
25-
// const [web3Modal, setWeb3Modal] = useState<Web3Modal>()
26-
// const setAddress = useAppStore((state) => state.setAddress)
2724
const setSigner = useAppStore((state) => state.setSigner)
2825
const reset = useAppStore((state) => state.reset)
2926

@@ -104,68 +101,6 @@ const useWalletProvider = () => {
104101
}
105102
}, [openWeb3Modal, isOpen])
106103

107-
// const connect = useCallback(async () => {
108-
// // if (!web3Modal) {
109-
// // throw new Error('web3Modal not initialized')
110-
// // }
111-
// if (isOpen) {
112-
// return null
113-
// }
114-
115-
// try {
116-
// openWeb3Modal()
117-
// // const instance = await web3Modal.connect()
118-
// // if (!instance) {
119-
// // return
120-
// // }
121-
// // instance.on('accountsChanged', handleAccountsChanged)
122-
123-
// // provider = new ethers.providers.Web3Provider(instance, 'any')
124-
// // const newSigner = provider.getSigner()
125-
// // setSigner(newSigner)
126-
// // setAddress(await newSigner.getAddress())
127-
// // return newSigner
128-
// } catch (e) {
129-
// // TODO: better error handling/surfacing here.
130-
// // Note that web3Modal.connect throws an error when the user closes the
131-
// // modal, as "User closed modal"
132-
// console.log('error', e)
133-
// }
134-
// }, [isOpen, openWeb3Modal])
135-
136-
// useEffect(() => {
137-
// console.log('useWalletProvider: initializing web3Modal')
138-
139-
// TODO: Remove this, don't need all the useEffect stuff with the new web3modal stuff
140-
// useEffect(() => {
141-
// if (!web3Modal) {
142-
// return
143-
// }
144-
// const initCached = async () => {
145-
// try {
146-
// const cachedProviderJson = localStorage.getItem(
147-
// 'WEB3_CONNECT_CACHED_PROVIDER'
148-
// )
149-
// if (!cachedProviderJson) {
150-
// return
151-
// }
152-
// const cachedProviderName = JSON.parse(cachedProviderJson)
153-
// const instance = await web3Modal.connectTo(cachedProviderName)
154-
// if (!instance) {
155-
// return
156-
// }
157-
// instance.on('accountsChanged', handleAccountsChanged)
158-
// provider = new ethers.providers.Web3Provider(instance, 'any')
159-
// const newSigner = provider.getSigner()
160-
// setSigner(newSigner)
161-
// setAddress(await newSigner.getAddress())
162-
// } catch (e) {
163-
// console.error(e)
164-
// }
165-
// }
166-
// initCached()
167-
// }, [web3Modal])
168-
169104
return {
170105
resolveName,
171106
lookupAddress,

store/app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { Client, Conversation, DecodedMessage } from '@xmtp/xmtp-js'
22
import { Signer } from 'ethers'
33
import create from 'zustand'
44
import getUniqueMessages from '../helpers/getUniqueMessages'
5+
import Web3Modal from 'web3modal'
56

67
// Used to keep track of the current view state of the extension app
78
// The extension doesn't have access to next/router, so captures
89
// the state otherwise handled by the router.
910
type ExtensionAppViewState = 'dm' | 'home' | 'conversation'
1011

1112
interface AppState {
13+
web3Modal: Web3Modal | undefined
14+
setWeb3Modal: (signer: Web3Modal | undefined) => void
1215
signer: Signer | undefined
1316
activeRecipient: string | undefined
1417
setSigner: (signer: Signer | undefined) => void
@@ -34,6 +37,9 @@ interface AppState {
3437
}
3538

3639
export const useAppStore = create<AppState>((set) => ({
40+
web3Modal: undefined,
41+
setWeb3Modal: (web3Modal: Web3Modal | undefined) =>
42+
set(() => ({ web3Modal })),
3743
signer: undefined,
3844
setSigner: (signer: Signer | undefined) => set(() => ({ signer })),
3945
address: undefined,

0 commit comments

Comments
 (0)