-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #456 from xmtp-labs/rygine/fix-consent
Upgrade React SDK, fix inbox tabs
- Loading branch information
Showing
16 changed files
with
17,009 additions
and
9,260 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/component-library/components/FullConversation/AcceptOrDeny.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { useState } from "react"; | ||
import { useConsent } from "@xmtp/react-sdk"; | ||
import { useXmtpStore } from "../../../store/xmtp"; | ||
|
||
export const AcceptOrDeny = ({ address }: { address: string }) => { | ||
const { t } = useTranslation(); | ||
const { allow, deny } = useConsent(); | ||
const activeTab = useXmtpStore((s) => s.activeTab); | ||
const changedConsentCount = useXmtpStore((s) => s.changedConsentCount); | ||
const setChangedConsentCount = useXmtpStore((s) => s.setChangedConsentCount); | ||
|
||
const [modalOpen, setModalOpen] = useState(true); | ||
|
||
return activeTab === "requests" && modalOpen ? ( | ||
<div | ||
className="bg-gray-100 p-4 w-full flex flex-col justify-center items-center text-gray-500 border-2 border-gray-300" | ||
data-testid="accept_or_deny_container"> | ||
<h3 className="font-bold">{t("consent.new_message_request")}</h3> | ||
<p>{t("consent.new_message_request_description")}</p> | ||
<div className="flex w-full justify-between p-3 gap-2"> | ||
<button | ||
type="button" | ||
className="text-indigo-600 flex w-full justify-center border border-2 border-indigo-600 rounded-md p-2 hover:bg-indigo-600 hover:text-white" | ||
onClick={() => { | ||
void allow([address]); | ||
setModalOpen(false); | ||
setChangedConsentCount(changedConsentCount + 1); | ||
}}> | ||
{t("consent.accept")} | ||
</button> | ||
<button | ||
type="button" | ||
className="text-red-600 flex w-full justify-center border border-2 border-red-600 rounded-md p-2 hover:bg-red-600 hover:text-white" | ||
onClick={() => { | ||
void deny([address]); | ||
setModalOpen(false); | ||
setChangedConsentCount(changedConsentCount + 1); | ||
}}> | ||
{t("consent.block")} | ||
</button> | ||
</div> | ||
</div> | ||
) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
connectorsForWallets, | ||
getDefaultWallets, | ||
} from "@rainbow-me/rainbowkit"; | ||
import { trustWallet } from "@rainbow-me/rainbowkit/wallets"; | ||
import { mainnet } from "@wagmi/core/chains"; | ||
import type { Config } from "@wagmi/core"; | ||
import { http, fallback } from "@wagmi/core"; | ||
import { createConfig } from "wagmi"; | ||
import { demoConnector } from "./demoConnector"; | ||
import { isAppEnvDemo } from "./env"; | ||
|
||
// Required field as of WalletConnect v2. | ||
// Replace with your project id: https://www.rainbowkit.com/docs/migration-guide#2-supply-a-walletconnect-cloud-projectid | ||
const projectId = import.meta.env.VITE_PROJECT_ID || "ADD_PROJECT_ID_HERE"; | ||
const appName = "XMTP Inbox Web"; | ||
|
||
const { wallets } = getDefaultWallets({ | ||
appName, | ||
projectId, | ||
}); | ||
|
||
const connectors = connectorsForWallets( | ||
[ | ||
...wallets, | ||
{ | ||
groupName: "Other", | ||
wallets: [trustWallet], | ||
}, | ||
], | ||
{ | ||
appName, | ||
projectId, | ||
}, | ||
); | ||
|
||
const transports = { | ||
[mainnet.id]: fallback([ | ||
http( | ||
`https://mainnet.infura.io/v3/${import.meta.env.VITE_INFURA_ID ?? ""}`, | ||
), | ||
http(), | ||
]), | ||
}; | ||
|
||
let config: Config; | ||
|
||
export const getWagmiConfig = () => { | ||
if (!config) { | ||
if (isAppEnvDemo()) { | ||
config = createConfig({ | ||
connectors: [demoConnector], | ||
chains: [mainnet], | ||
transports, | ||
}); | ||
} else { | ||
config = createConfig({ | ||
connectors, | ||
chains: [mainnet], | ||
transports, | ||
}); | ||
} | ||
} | ||
return config; | ||
}; |
Oops, something went wrong.