Skip to content

Commit

Permalink
Use json rpc for live invite handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mondoreale committed Apr 11, 2024
1 parent 2e87f84 commit 51c1fa6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 69 deletions.
2 changes: 2 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const ERC1155PolicyFactoryAddress = '0x0f31377cBd078C82b34Ab586A3f8d973fE

export const JoinPolicyRegistryAddress = '0x3eB2Ec4d2876d22EE103aBc1e0A7CCEefD117CD3'

export const StreamRegistryAddress = '0x0D483E10612F327FC11965Fc82E90dC19b141641'

export enum PermissionType {
Edit = 0,
Delete,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useListenForInvitesEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { useEffect, useRef } from 'react'
import { Address, OptionalAddress, Prefix } from '$/types'
import { RoomId } from '$/features/room/types'
import isSameAddress from '$/utils/isSameAddress'
import useStreamRegistry from './useStreamRegistry'
import { getStreamRegistry } from '$/utils'

export default function useListenForInvitesEffect(
address: OptionalAddress,
onInvite: (roomId: RoomId, address: Address) => void
) {
const registry = useStreamRegistry()
const registry = getStreamRegistry()

const onInviteRef = useRef(onInvite)

Expand Down
67 changes: 0 additions & 67 deletions src/hooks/useStreamRegistry.ts

This file was deleted.

18 changes: 18 additions & 0 deletions src/utils/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { JSON_RPC_URL, StreamRegistryAddress } from '$/consts'
import { Contract, providers } from 'ethers'
import { StreamRegistryV3 } from '../contracts/StreamRegistryV3.sol/StreamRegistryV3'
import { abi } from '../contracts/StreamRegistryV3.sol/StreamRegistryV3.json'

let streamRegistry: undefined | StreamRegistryV3

export function getStreamRegistry() {
if (!streamRegistry) {
streamRegistry = new Contract(
StreamRegistryAddress,
abi,
new providers.JsonRpcProvider(JSON_RPC_URL)
) as StreamRegistryV3
}

return streamRegistry
}

0 comments on commit 51c1fa6

Please sign in to comment.