chore: remove deprecated metamask and rainbow (#9299)
* Remove deprecated code related to rainbow * Remove translations for rainbow specific features * Remove english translations for metamask * Remove translations for metamask * Fix lint issues * Fix prettier issues * update yarn lock * Generated yarn.lock with submodules * Added auth submodule deps --------- Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: alannnc <[email protected]> Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
69 files changed
+591
-3255
No files matched your search
@@ -36,11 +36,6 @@ export const getEventTypeAppData = <T extends EventTypeAppsList>(
|
||||
currency: eventType.currency,
|
||||
paymentOption: "ON_BOOKING",
|
||||
},
|
||||
rainbow: {
|
||||
enabled: !!(eventType.metadata?.smartContractAddress && eventType.metadata?.blockchainId),
|
||||
smartContractAddress: eventType.metadata?.smartContractAddress || "",
|
||||
blockchainId: eventType.metadata?.blockchainId || 0,
|
||||
},
|
||||
giphy: {
|
||||
enabled: !!eventType.metadata?.giphyThankYouPage,
|
||||
thankYouPage: eventType.metadata?.giphyThankYouPage || "",
|
||||
|
||||
@@ -27,7 +27,6 @@ export const EventTypeAddonMap = {
|
||||
metapixel: dynamic(() => import("./metapixel/components/EventTypeAppCardInterface")),
|
||||
plausible: dynamic(() => import("./plausible/components/EventTypeAppCardInterface")),
|
||||
qr_code: dynamic(() => import("./qr_code/components/EventTypeAppCardInterface")),
|
||||
rainbow: dynamic(() => import("./rainbow/components/EventTypeAppCardInterface")),
|
||||
stripepayment: dynamic(() => import("./stripepayment/components/EventTypeAppCardInterface")),
|
||||
"booking-pages-tag": dynamic(() =>
|
||||
import("./templates/booking-pages-tag/components/EventTypeAppCardInterface")
|
||||
|
||||
@@ -16,7 +16,6 @@ import { appKeysSchema as office365calendar_zod_ts } from "./office365calendar/z
|
||||
import { appKeysSchema as office365video_zod_ts } from "./office365video/zod";
|
||||
import { appKeysSchema as plausible_zod_ts } from "./plausible/zod";
|
||||
import { appKeysSchema as qr_code_zod_ts } from "./qr_code/zod";
|
||||
import { appKeysSchema as rainbow_zod_ts } from "./rainbow/zod";
|
||||
import { appKeysSchema as routing_forms_zod_ts } from "./routing-forms/zod";
|
||||
import { appKeysSchema as salesforce_zod_ts } from "./salesforce/zod";
|
||||
import { appKeysSchema as stripepayment_zod_ts } from "./stripepayment/zod";
|
||||
@@ -46,7 +45,6 @@ export const appKeysSchemas = {
|
||||
office365video: office365video_zod_ts,
|
||||
plausible: plausible_zod_ts,
|
||||
qr_code: qr_code_zod_ts,
|
||||
rainbow: rainbow_zod_ts,
|
||||
"routing-forms": routing_forms_zod_ts,
|
||||
salesforce: salesforce_zod_ts,
|
||||
stripe: stripepayment_zod_ts,
|
||||
|
||||
@@ -35,7 +35,6 @@ import ping_config_json from "./ping/config.json";
|
||||
import pipedream_config_json from "./pipedream/config.json";
|
||||
import plausible_config_json from "./plausible/config.json";
|
||||
import qr_code_config_json from "./qr_code/config.json";
|
||||
import rainbow_config_json from "./rainbow/config.json";
|
||||
import raycast_config_json from "./raycast/config.json";
|
||||
import riverside_config_json from "./riverside/config.json";
|
||||
import routing_forms_config_json from "./routing-forms/config.json";
|
||||
@@ -101,7 +100,6 @@ export const appStoreMetadata = {
|
||||
pipedream: pipedream_config_json,
|
||||
plausible: plausible_config_json,
|
||||
qr_code: qr_code_config_json,
|
||||
rainbow: rainbow_config_json,
|
||||
raycast: raycast_config_json,
|
||||
riverside: riverside_config_json,
|
||||
"routing-forms": routing_forms_config_json,
|
||||
|
||||
@@ -16,7 +16,6 @@ import { appDataSchema as office365calendar_zod_ts } from "./office365calendar/z
|
||||
import { appDataSchema as office365video_zod_ts } from "./office365video/zod";
|
||||
import { appDataSchema as plausible_zod_ts } from "./plausible/zod";
|
||||
import { appDataSchema as qr_code_zod_ts } from "./qr_code/zod";
|
||||
import { appDataSchema as rainbow_zod_ts } from "./rainbow/zod";
|
||||
import { appDataSchema as routing_forms_zod_ts } from "./routing-forms/zod";
|
||||
import { appDataSchema as salesforce_zod_ts } from "./salesforce/zod";
|
||||
import { appDataSchema as stripepayment_zod_ts } from "./stripepayment/zod";
|
||||
@@ -46,7 +45,6 @@ export const appDataSchemas = {
|
||||
office365video: office365video_zod_ts,
|
||||
plausible: plausible_zod_ts,
|
||||
qr_code: qr_code_zod_ts,
|
||||
rainbow: rainbow_zod_ts,
|
||||
"routing-forms": routing_forms_zod_ts,
|
||||
salesforce: salesforce_zod_ts,
|
||||
stripe: stripepayment_zod_ts,
|
||||
|
||||
@@ -35,7 +35,6 @@ export const apiHandlers = {
|
||||
pipedream: import("./pipedream/api"),
|
||||
plausible: import("./plausible/api"),
|
||||
qr_code: import("./qr_code/api"),
|
||||
rainbow: import("./rainbow/api"),
|
||||
raycast: import("./raycast/api"),
|
||||
riverside: import("./riverside/api"),
|
||||
"routing-forms": import("./routing-forms/api"),
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
items:
|
||||
- 1.jpg
|
||||
- 2.jpg
|
||||
- 3.jpg
|
||||
---
|
||||
|
||||
Token gate bookings based on NFTs, DAO tokens, and ERC-20 tokens. Rainbow supports dozens of trusted Ethereum wallet apps to verify token ownership. Available blockchains are Ethereum mainnet, Arbitrum, Optimism, and Polygon mainnet.
|
||||
@@ -1,12 +0,0 @@
|
||||
# Rainbow App
|
||||
|
||||
> Intended for developer information
|
||||
|
||||
The web3 app uses [RainbowKit](https://www.rainbowkit.com/) to authenticate Ethereum users.
|
||||
|
||||
When deploying, the app requires either a `ALCHEMY_API_KEY` or `INFURA_API_KEY` (or both) which can be obtained by creating an Alchemy or Infura project respectively.
|
||||
|
||||
<img width="901" alt="Find your Alchemy API key" src="https://user-images.githubusercontent.com/8162609/187499278-e5f03c3f-b4a5-430a-9121-f30207802d4c.png">
|
||||
<img width="932" alt="Find your Infura API key" src="https://user-images.githubusercontent.com/8162609/187499759-425b4fc4-621b-4753-b77f-257b5055408a.png">
|
||||
|
||||
Available blockchains are Ethereum mainnet, Arbitrum, Optimism, and Polygon mainnet.
|
||||
@@ -1,16 +0,0 @@
|
||||
import type { AppDeclarativeHandler } from "@calcom/types/AppHandler";
|
||||
|
||||
import { createDefaultInstallation } from "../../_utils/installation";
|
||||
import appConfig from "../config.json";
|
||||
|
||||
const handler: AppDeclarativeHandler = {
|
||||
appType: appConfig.type,
|
||||
slug: appConfig.slug,
|
||||
variant: appConfig.slug,
|
||||
supportsMultipleInstalls: false,
|
||||
handlerType: "add",
|
||||
createCredential: ({ appType, user, slug }) =>
|
||||
createDefaultInstallation({ appType, userId: user.id, slug, key: {} }),
|
||||
};
|
||||
|
||||
export default handler;
|
||||
@@ -1 +0,0 @@
|
||||
export { default as add } from "./add";
|
||||
@@ -1,35 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
|
||||
import AppCard from "@calcom/app-store/_components/AppCard";
|
||||
import RainbowInstallForm from "@calcom/app-store/rainbow/components/RainbowInstallForm";
|
||||
import type { EventTypeAppCardComponent } from "@calcom/app-store/types";
|
||||
|
||||
import type { appDataSchema } from "../zod";
|
||||
|
||||
const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({ app }) {
|
||||
const [getAppData, setAppData] = useAppContextWithSchema<typeof appDataSchema>();
|
||||
const blockchainId = getAppData("blockchainId");
|
||||
const smartContractAddress = getAppData("smartContractAddress");
|
||||
const [showRainbowSection, setShowRainbowSection] = useState(getAppData("enabled"));
|
||||
|
||||
return (
|
||||
<AppCard
|
||||
setAppData={setAppData}
|
||||
app={app}
|
||||
switchOnClick={(e) => {
|
||||
setShowRainbowSection(e);
|
||||
}}
|
||||
switchChecked={showRainbowSection}>
|
||||
{showRainbowSection && (
|
||||
<RainbowInstallForm
|
||||
setAppData={setAppData}
|
||||
blockchainId={blockchainId}
|
||||
smartContractAddress={(smartContractAddress as string) || ""}
|
||||
/>
|
||||
)}
|
||||
</AppCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default EventTypeAppCard;
|
||||
@@ -1,63 +0,0 @@
|
||||
import type { z } from "zod";
|
||||
|
||||
import type { SetAppDataGeneric } from "@calcom/app-store/EventTypeAppContext";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SUPPORTED_CHAINS_FOR_FORM } from "@calcom/rainbow/utils/ethereum";
|
||||
import { Select } from "@calcom/ui";
|
||||
|
||||
import type { appDataSchema } from "../zod";
|
||||
|
||||
type RainbowInstallFormProps = {
|
||||
setAppData: SetAppDataGeneric<typeof appDataSchema>;
|
||||
} & Pick<z.infer<typeof appDataSchema>, "smartContractAddress" | "blockchainId">;
|
||||
|
||||
const RainbowInstallForm: React.FC<RainbowInstallFormProps> = ({
|
||||
setAppData,
|
||||
blockchainId,
|
||||
smartContractAddress,
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mt-5 block items-center sm:flex">
|
||||
<div className="min-w-48 mb-4 sm:mb-0">
|
||||
<label htmlFor="blockchainId" className="text-default flex text-sm font-medium">
|
||||
{t("Blockchain")}
|
||||
</label>
|
||||
</div>
|
||||
<Select
|
||||
isSearchable={false}
|
||||
className="block w-full min-w-0 flex-1 rounded-sm text-sm"
|
||||
onChange={(e) => {
|
||||
setAppData("blockchainId", (e && e.value) || 1);
|
||||
}}
|
||||
defaultValue={SUPPORTED_CHAINS_FOR_FORM.find((e) => e.value === blockchainId)}
|
||||
options={SUPPORTED_CHAINS_FOR_FORM || [{ value: 1, label: "Ethereum" }]}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-5 block items-center pb-4 sm:flex">
|
||||
<div className="min-w-48 mb-4 sm:mb-0">
|
||||
<label htmlFor="smartContractAddress" className="text-default flex text-sm font-medium">
|
||||
{t("token_address")}
|
||||
</label>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<div className="relative mt-1 rounded-sm">
|
||||
<input
|
||||
type="text"
|
||||
className="border-default block w-full rounded-sm text-sm"
|
||||
placeholder={t("Example: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f")}
|
||||
defaultValue={(smartContractAddress || "") as string}
|
||||
onChange={(e) => {
|
||||
setAppData("smartContractAddress", e.target.value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default RainbowInstallForm;
|
||||
@@ -1,175 +0,0 @@
|
||||
import {
|
||||
ConnectButton,
|
||||
darkTheme,
|
||||
getDefaultWallets,
|
||||
lightTheme,
|
||||
RainbowKitProvider,
|
||||
} from "@rainbow-me/rainbowkit";
|
||||
import "@rainbow-me/rainbowkit/styles.css";
|
||||
import { useTheme } from "next-themes";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Trans } from "react-i18next";
|
||||
import { configureChains, createClient, useAccount, useSignMessage, WagmiConfig } from "wagmi";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { showToast, SkeletonText } from "@calcom/ui";
|
||||
import { AlertTriangle, Loader } from "@calcom/ui/components/icon";
|
||||
|
||||
import { ETH_MESSAGE, getProviders, SUPPORTED_CHAINS } from "../utils/ethereum";
|
||||
|
||||
const { chains, provider } = configureChains(SUPPORTED_CHAINS, getProviders());
|
||||
|
||||
const { connectors } = getDefaultWallets({
|
||||
appName: "Cal.com",
|
||||
chains,
|
||||
});
|
||||
|
||||
const wagmiClient = createClient({
|
||||
autoConnect: true,
|
||||
connectors,
|
||||
provider,
|
||||
});
|
||||
|
||||
type RainbowGateProps = {
|
||||
children: React.ReactNode;
|
||||
setToken: (_: string) => void;
|
||||
chainId: number;
|
||||
tokenAddress: string;
|
||||
};
|
||||
|
||||
const RainbowGate: React.FC<RainbowGateProps> = (props) => {
|
||||
const { resolvedTheme: theme } = useTheme();
|
||||
const [rainbowTheme, setRainbowTheme] = useState(theme === "dark" ? darkTheme() : lightTheme());
|
||||
|
||||
useEffect(() => {
|
||||
theme === "dark" ? setRainbowTheme(darkTheme()) : setRainbowTheme(lightTheme());
|
||||
}, [theme]);
|
||||
|
||||
return (
|
||||
<WagmiConfig client={wagmiClient}>
|
||||
<RainbowKitProvider chains={chains.filter((chain) => chain.id === props.chainId)} theme={rainbowTheme}>
|
||||
<BalanceCheck {...props} />
|
||||
</RainbowKitProvider>
|
||||
</WagmiConfig>
|
||||
);
|
||||
};
|
||||
|
||||
// The word "token" is used for two differenct concepts here: `setToken` is the token for
|
||||
// the Gate while `useToken` is a hook used to retrieve the Ethereum token.
|
||||
const BalanceCheck: React.FC<RainbowGateProps> = ({ chainId, setToken, tokenAddress }) => {
|
||||
const { t } = useLocale();
|
||||
const { address } = useAccount();
|
||||
const {
|
||||
data: signedMessage,
|
||||
isLoading: isSignatureLoading,
|
||||
isError: isSignatureError,
|
||||
signMessage,
|
||||
} = useSignMessage({
|
||||
message: ETH_MESSAGE,
|
||||
});
|
||||
const { data: contractData, isLoading: isContractLoading } = trpc.viewer.eth.contract.useQuery({
|
||||
address: tokenAddress,
|
||||
chainId,
|
||||
});
|
||||
const { data: balanceData, isLoading: isBalanceLoading } = trpc.viewer.eth.balance.useQuery(
|
||||
{ address: address || "", tokenAddress, chainId },
|
||||
{
|
||||
enabled: !!address,
|
||||
}
|
||||
);
|
||||
|
||||
// The token may have already been set in the query params, so we can extract it here
|
||||
const router = useRouter();
|
||||
const { ethSignature, ...routerQuery } = router.query;
|
||||
|
||||
const isLoading = isContractLoading || isBalanceLoading;
|
||||
|
||||
// Any logic here will unlock the gate by setting the token to the user's wallet signature
|
||||
useEffect(() => {
|
||||
// If the `ethSignature` is found, remove it from the URL bar and propogate back up
|
||||
if (ethSignature !== undefined) {
|
||||
// Remove the `ethSignature` param but keep all others
|
||||
router.replace({ query: { ...routerQuery } });
|
||||
setToken(ethSignature as string);
|
||||
}
|
||||
|
||||
if (balanceData && balanceData.data) {
|
||||
if (balanceData.data.hasBalance) {
|
||||
if (signedMessage) {
|
||||
showToast("Wallet verified.", "success");
|
||||
setToken(signedMessage);
|
||||
} else if (router.isReady && !ethSignature) {
|
||||
signMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [router.isReady, balanceData, setToken, signedMessage, signMessage]);
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl py-24 px-4">
|
||||
<div className="rounded-md border border-neutral-200 dark:border-neutral-700 dark:hover:border-neutral-600">
|
||||
<div className="hover:border-brand-default dark:bg-darkgray-100 bg-default hover:bg-default flex min-h-[120px] grow flex-col border-b border-neutral-200 p-6 text-center first:rounded-t-md last:rounded-b-md last:border-b-0 dark:border-neutral-700 dark:hover:border-neutral-600 md:flex-row md:text-left">
|
||||
<span className="mb-4 grow md:mb-0">
|
||||
<h2 className="text-emphasis dark:text-inverted mb-2 grow font-semibold">Token Gate</h2>
|
||||
{isLoading && (
|
||||
<>
|
||||
<SkeletonText className="mb-3 h-1 w-full" />
|
||||
<SkeletonText className="h-1 w-full" />
|
||||
</>
|
||||
)}
|
||||
{!isLoading && contractData && contractData.data && (
|
||||
<>
|
||||
<p className="dark:text-inverted text-gray-300">
|
||||
<Trans i18nKey="rainbow_connect_wallet_gate" t={t}>
|
||||
Connect your wallet if you own {contractData.data.name} ({contractData.data.symbol}) .
|
||||
</Trans>
|
||||
</p>
|
||||
|
||||
{balanceData && balanceData.data && (
|
||||
<>
|
||||
{!balanceData.data.hasBalance && (
|
||||
<div className="mt-2 flex flex-row items-center">
|
||||
<AlertTriangle className="h-5 w-5 text-red-600" />
|
||||
<p className="ml-2 text-red-600">
|
||||
<Trans i18nKey="rainbow_insufficient_balance" t={t}>
|
||||
Your connected wallet doesn't contain enough {contractData.data.symbol}.
|
||||
</Trans>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{balanceData.data.hasBalance && isSignatureLoading && (
|
||||
<div className="mt-2 flex flex-row items-center">
|
||||
<Loader className="h-5 w-5 text-green-600" />
|
||||
<p className="ml-2 text-green-600">{t("rainbow_sign_message_request")}</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{isSignatureError && (
|
||||
<div className="mt-2 flex flex-row items-center">
|
||||
<AlertTriangle className="h-5 w-5 text-red-600" />
|
||||
<p className="ml-2 text-red-600">
|
||||
<Trans i18nKey="rainbow_signature_error" t={t}>
|
||||
{t("rainbow_signature_error")}
|
||||
</Trans>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
<span className="ml-10 min-w-[170px] self-center">
|
||||
<ConnectButton chainStatus="icon" showBalance={false} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
export default RainbowGate;
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"/*": "Don't modify slug - If required, do it using cli edit command",
|
||||
"name": "Rainbow",
|
||||
"slug": "rainbow",
|
||||
"type": "rainbow_web3",
|
||||
"logo": "icon.svg",
|
||||
"url": "https://github.com/hexcowboy",
|
||||
"variant": "web3",
|
||||
"categories": ["web3"],
|
||||
"extendsFeature": "EventType",
|
||||
"publisher": "hexcowboy",
|
||||
"email": "",
|
||||
"description": "Web3 integration for token gating on Fungible Tokens, NFTs, and DAOs.",
|
||||
"__createdUsingCli": true
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * as api from "./api";
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"name": "@calcom/rainbow",
|
||||
"version": "0.0.0",
|
||||
"main": "./index.ts",
|
||||
"description": "Web3 integration for token gating on Fungible Tokens, NFTs, and DAOs.",
|
||||
"dependencies": {
|
||||
"@calcom/lib": "*",
|
||||
"@rainbow-me/rainbowkit": "^0.5.0",
|
||||
"ethers": "^5.7.0",
|
||||
"wagmi": "^0.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@calcom/types": "*"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 83 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
@@ -1,54 +0,0 @@
|
||||
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="120" height="120" fill="url(#paint0_linear_62_329)"/>
|
||||
<path d="M20 38H26C56.9279 38 82 63.0721 82 94V100H94C97.3137 100 100 97.3137 100 94C100 53.1309 66.8691 20 26 20C22.6863 20 20 22.6863 20 26V38Z" fill="url(#paint1_radial_62_329)"/>
|
||||
<path d="M84 94H100C100 97.3137 97.3137 100 94 100H84V94Z" fill="url(#paint2_linear_62_329)"/>
|
||||
<path d="M26 20L26 36H20L20 26C20 22.6863 22.6863 20 26 20Z" fill="url(#paint3_linear_62_329)"/>
|
||||
<path d="M20 36H26C58.0325 36 84 61.9675 84 94V100H66V94C66 71.9086 48.0914 54 26 54H20V36Z" fill="url(#paint4_radial_62_329)"/>
|
||||
<path d="M68 94H84V100H68V94Z" fill="url(#paint5_linear_62_329)"/>
|
||||
<path d="M20 52L20 36L26 36L26 52H20Z" fill="url(#paint6_linear_62_329)"/>
|
||||
<path d="M20 62C20 65.3137 22.6863 68 26 68C40.3594 68 52 79.6406 52 94C52 97.3137 54.6863 100 58 100H68V94C68 70.804 49.196 52 26 52H20V62Z" fill="url(#paint7_radial_62_329)"/>
|
||||
<path d="M52 94H68V100H58C54.6863 100 52 97.3137 52 94Z" fill="url(#paint8_radial_62_329)"/>
|
||||
<path d="M26 68C22.6863 68 20 65.3137 20 62L20 52L26 52L26 68Z" fill="url(#paint9_radial_62_329)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_62_329" x1="60" y1="0" x2="60" y2="120" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#174299"/>
|
||||
<stop offset="1" stop-color="#001E59"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="paint1_radial_62_329" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(26 94) rotate(-90) scale(74)">
|
||||
<stop offset="0.770277" stop-color="#FF4000"/>
|
||||
<stop offset="1" stop-color="#8754C9"/>
|
||||
</radialGradient>
|
||||
<linearGradient id="paint2_linear_62_329" x1="83" y1="97" x2="100" y2="97" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FF4000"/>
|
||||
<stop offset="1" stop-color="#8754C9"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_62_329" x1="23" y1="20" x2="23" y2="37" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#8754C9"/>
|
||||
<stop offset="1" stop-color="#FF4000"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="paint4_radial_62_329" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(26 94) rotate(-90) scale(58)">
|
||||
<stop offset="0.723929" stop-color="#FFF700"/>
|
||||
<stop offset="1" stop-color="#FF9901"/>
|
||||
</radialGradient>
|
||||
<linearGradient id="paint5_linear_62_329" x1="68" y1="97" x2="84" y2="97" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFF700"/>
|
||||
<stop offset="1" stop-color="#FF9901"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear_62_329" x1="23" y1="52" x2="23" y2="36" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFF700"/>
|
||||
<stop offset="1" stop-color="#FF9901"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="paint7_radial_62_329" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(26 94) rotate(-90) scale(42)">
|
||||
<stop offset="0.59513" stop-color="#00AAFF"/>
|
||||
<stop offset="1" stop-color="#01DA40"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint8_radial_62_329" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(51 97) scale(17 45.3333)">
|
||||
<stop stop-color="#00AAFF"/>
|
||||
<stop offset="1" stop-color="#01DA40"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint9_radial_62_329" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(23 69) rotate(-90) scale(17 322.37)">
|
||||
<stop stop-color="#00AAFF"/>
|
||||
<stop offset="1" stop-color="#01DA40"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,25 +0,0 @@
|
||||
import { checkBalance } from "../utils/ethereum";
|
||||
import type { TBalanceInputSchema } from "./balance.schema";
|
||||
|
||||
interface BalanceHandlerOptions {
|
||||
input: TBalanceInputSchema;
|
||||
}
|
||||
|
||||
export const balanceHandler = async ({ input }: BalanceHandlerOptions) => {
|
||||
const { address, tokenAddress, chainId } = input;
|
||||
try {
|
||||
const hasBalance = await checkBalance(address, tokenAddress, chainId);
|
||||
|
||||
return {
|
||||
data: {
|
||||
hasBalance,
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
data: {
|
||||
hasBalance: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import z from "zod";
|
||||
|
||||
export const ZBalanceInputSchema = z.object({
|
||||
address: z.string(),
|
||||
tokenAddress: z.string(),
|
||||
chainId: z.number(),
|
||||
});
|
||||
|
||||
export const ZBalanceOutputSchema = z.object({
|
||||
data: z
|
||||
.object({
|
||||
hasBalance: z.boolean(),
|
||||
})
|
||||
.nullish(),
|
||||
error: z.string().nullish(),
|
||||
});
|
||||
|
||||
export type TBalanceOutputSchema = z.infer<typeof ZBalanceOutputSchema>;
|
||||
export type TBalanceInputSchema = z.infer<typeof ZBalanceInputSchema>;
|
||||
@@ -1,42 +0,0 @@
|
||||
import { ethers } from "ethers";
|
||||
import { configureChains, createClient } from "wagmi";
|
||||
|
||||
import abi from "../utils/abi.json";
|
||||
import { getProviders, SUPPORTED_CHAINS } from "../utils/ethereum";
|
||||
import type { TContractInputSchema } from "./contract.schema";
|
||||
|
||||
interface ContractHandlerOptions {
|
||||
input: TContractInputSchema;
|
||||
}
|
||||
export const contractHandler = async ({ input }: ContractHandlerOptions) => {
|
||||
const { address, chainId } = input;
|
||||
const { provider } = configureChains(
|
||||
SUPPORTED_CHAINS.filter((chain) => chain.id === chainId),
|
||||
getProviders()
|
||||
);
|
||||
|
||||
const client = createClient({
|
||||
provider,
|
||||
});
|
||||
|
||||
const contract = new ethers.Contract(address, abi, client.provider);
|
||||
|
||||
try {
|
||||
const name = await contract.name();
|
||||
const symbol = await contract.symbol();
|
||||
|
||||
return {
|
||||
data: {
|
||||
name,
|
||||
symbol: `$${symbol}`,
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
data: {
|
||||
name: address,
|
||||
symbol: "$UNKNOWN",
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import z from "zod";
|
||||
|
||||
export const ZContractInputSchema = z.object({
|
||||
address: z.string(),
|
||||
chainId: z.number(),
|
||||
});
|
||||
|
||||
export const ZContractOutputSchema = z.object({
|
||||
data: z
|
||||
.object({
|
||||
name: z.string(),
|
||||
symbol: z.string(),
|
||||
})
|
||||
.nullish(),
|
||||
error: z.string().nullish(),
|
||||
});
|
||||
|
||||
export type TContractInputSchema = z.infer<typeof ZContractInputSchema>;
|
||||
export type TContractOutputSchema = z.infer<typeof ZContractOutputSchema>;
|
||||
@@ -1,55 +0,0 @@
|
||||
import publicProcedure from "@calcom/trpc/server/procedures/publicProcedure";
|
||||
import { router } from "@calcom/trpc/server/trpc";
|
||||
|
||||
import { ZBalanceInputSchema, ZBalanceOutputSchema } from "./balance.schema";
|
||||
import { ZContractInputSchema, ZContractOutputSchema } from "./contract.schema";
|
||||
|
||||
interface EthRouterHandlersCache {
|
||||
contract?: typeof import("./contract.handler").contractHandler;
|
||||
balance?: typeof import("./balance.handler").balanceHandler;
|
||||
}
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: EthRouterHandlersCache = {};
|
||||
|
||||
const ethRouter = router({
|
||||
// Fetch contract `name` and `symbol` or error
|
||||
contract: publicProcedure
|
||||
.input(ZContractInputSchema)
|
||||
.output(ZContractOutputSchema)
|
||||
.query(async ({ input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.contract) {
|
||||
UNSTABLE_HANDLER_CACHE.contract = await import("./contract.handler").then(
|
||||
(mod) => mod.contractHandler
|
||||
);
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.contract) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.contract({
|
||||
input,
|
||||
});
|
||||
}),
|
||||
// Fetch user's `balance` of either ERC-20 or ERC-721 compliant token or error
|
||||
balance: publicProcedure
|
||||
.input(ZBalanceInputSchema)
|
||||
.output(ZBalanceOutputSchema)
|
||||
.query(async ({ input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.balance) {
|
||||
UNSTABLE_HANDLER_CACHE.balance = await import("./balance.handler").then((mod) => mod.balanceHandler);
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.balance) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.balance({
|
||||
input,
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
export default ethRouter;
|
||||
@@ -1,49 +0,0 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "balance",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
@@ -1,116 +0,0 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { utils, Contract } from "ethers";
|
||||
import { chain, configureChains, createClient } from "wagmi";
|
||||
import { alchemyProvider } from "wagmi/providers/alchemy";
|
||||
import { infuraProvider } from "wagmi/providers/infura";
|
||||
import { publicProvider } from "wagmi/providers/public";
|
||||
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
|
||||
import abi from "./abi.json";
|
||||
|
||||
export const ETH_MESSAGE = "Connect to Cal.com";
|
||||
export const SUPPORTED_CHAINS = [chain.mainnet, chain.polygon, chain.optimism, chain.arbitrum];
|
||||
|
||||
export const SUPPORTED_CHAINS_FOR_FORM = SUPPORTED_CHAINS.map((chain) => {
|
||||
return { value: chain.id, label: chain.name };
|
||||
});
|
||||
|
||||
// Optionally grabs Alchemy, Infura, in addition to public providers
|
||||
export const getProviders = () => {
|
||||
let providers = []; // eslint-disable-line prefer-const
|
||||
|
||||
if (process.env.ALCHEMY_API_KEY) {
|
||||
providers.push(alchemyProvider({ apiKey: process.env.ALCHEMY_API_KEY }));
|
||||
}
|
||||
|
||||
if (process.env.INFURA_API_KEY) {
|
||||
providers.push(infuraProvider({ apiKey: process.env.INFURA_API_KEY }));
|
||||
}
|
||||
|
||||
// Public provider will always be available as fallback, but having at least
|
||||
// on of either Infura or Alchemy providers is highly recommended
|
||||
providers.push(publicProvider());
|
||||
|
||||
return providers;
|
||||
};
|
||||
|
||||
type VerifyResult = {
|
||||
hasBalance: boolean;
|
||||
address: string;
|
||||
};
|
||||
|
||||
// Checks balance for any contract that implements the abi (NFT, ERC20, etc)
|
||||
export const checkBalance = async (
|
||||
walletAddress: string,
|
||||
tokenAddress: string,
|
||||
chainId: number
|
||||
): Promise<boolean> => {
|
||||
const { provider } = configureChains(
|
||||
SUPPORTED_CHAINS.filter((chain) => chain.id === chainId),
|
||||
getProviders()
|
||||
);
|
||||
|
||||
const client = createClient({
|
||||
provider,
|
||||
});
|
||||
|
||||
const contract = new Contract(tokenAddress, abi, client.provider);
|
||||
const userAddress = utils.getAddress(walletAddress);
|
||||
const balance = await contract.balanceOf(userAddress);
|
||||
|
||||
return !balance.isZero();
|
||||
};
|
||||
|
||||
// Extracts wallet address from a signed message and checks balance
|
||||
export const verifyEthSig = async (
|
||||
sig: string,
|
||||
tokenAddress: string,
|
||||
chainId: number
|
||||
): Promise<VerifyResult> => {
|
||||
const address = utils.verifyMessage(ETH_MESSAGE, sig);
|
||||
const hasBalance = await checkBalance(address, tokenAddress, chainId);
|
||||
|
||||
return {
|
||||
address,
|
||||
hasBalance,
|
||||
};
|
||||
};
|
||||
|
||||
type HandleEthSignatureInput = {
|
||||
smartContractAddress?: string;
|
||||
blockchainId?: number;
|
||||
};
|
||||
|
||||
// Handler used in `/book/event` API
|
||||
export const handleEthSignature = async (
|
||||
_metadata: Prisma.JsonValue,
|
||||
ethSignature?: string
|
||||
): Promise<string | undefined> => {
|
||||
if (!_metadata) {
|
||||
return;
|
||||
}
|
||||
const metadata = _metadata as HandleEthSignatureInput;
|
||||
|
||||
if (metadata) {
|
||||
if (metadata.blockchainId && metadata.smartContractAddress) {
|
||||
if (!ethSignature) {
|
||||
throw new HttpError({ statusCode: 400, message: "Ethereum signature required." });
|
||||
}
|
||||
|
||||
const { address, hasBalance } = await verifyEthSig(
|
||||
ethSignature,
|
||||
metadata.smartContractAddress as string,
|
||||
metadata.blockchainId as number
|
||||
);
|
||||
|
||||
if (!hasBalance) {
|
||||
throw new HttpError({ statusCode: 400, message: "The wallet doesn't contain enough tokens." });
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { eventTypeAppCardZod } from "../eventTypeAppCardZod";
|
||||
|
||||
export const appDataSchema = eventTypeAppCardZod.merge(
|
||||
z.object({
|
||||
smartContractAddress: z.string().optional(),
|
||||
blockchainId: z.number().optional(),
|
||||
})
|
||||
);
|
||||
|
||||
export const appKeysSchema = z.object({});
|
||||
@@ -13,7 +13,6 @@ import { metadata as GoogleMeetMetadata } from "@calcom/app-store/googlevideo/_m
|
||||
import type { LocationObject } from "@calcom/app-store/locations";
|
||||
import { getLocationValueForDB } from "@calcom/app-store/locations";
|
||||
import { MeetLocationType } from "@calcom/app-store/locations";
|
||||
import { handleEthSignature } from "@calcom/app-store/rainbow/utils/ethereum";
|
||||
import type { EventTypeAppsList } from "@calcom/app-store/utils";
|
||||
import { getAppFromSlug, getEventTypeAppData } from "@calcom/app-store/utils";
|
||||
import { cancelScheduledJobs, scheduleTrigger } from "@calcom/app-store/zapier/lib/nodeScheduler";
|
||||
@@ -817,12 +816,6 @@ async function handler(
|
||||
users = [...availableUsers.filter((user) => user.isFixed), ...luckyUsers];
|
||||
}
|
||||
|
||||
const rainbowAppData = getEventTypeAppData(eventType, "rainbow") || {};
|
||||
|
||||
// @TODO: use the returned address somewhere in booking creation?
|
||||
// const address: string | undefined = await ...
|
||||
await handleEthSignature(rainbowAppData, reqBody.ethSignature);
|
||||
|
||||
const [organizerUser] = users;
|
||||
const tOrganizer = await getTranslation(organizerUser?.locale ?? "en", "common");
|
||||
// use host default
|
||||
|
||||
@@ -257,7 +257,6 @@ export default async function getEventTypeById({
|
||||
)?.default_currency || "usd",
|
||||
},
|
||||
giphy: getEventTypeAppData(eventTypeWithParsedMetadata, "giphy", true),
|
||||
rainbow: getEventTypeAppData(eventTypeWithParsedMetadata, "rainbow", true),
|
||||
};
|
||||
|
||||
// TODO: How to extract metadata schema from _EventTypeModel to be able to parse it?
|
||||
|
||||
@@ -42,12 +42,6 @@
|
||||
"slug": "campfire",
|
||||
"type": "campfire_video"
|
||||
},
|
||||
{
|
||||
"dirName": "rainbow",
|
||||
"categories": ["web3"],
|
||||
"slug": "rainbow",
|
||||
"type": "rainbow_web3"
|
||||
},
|
||||
{
|
||||
"dirName": "raycast",
|
||||
"categories": ["other"],
|
||||
|
||||
@@ -174,7 +174,6 @@ export const bookingCreateBodySchema = z.object({
|
||||
metadata: z.record(z.string()),
|
||||
hasHashedBookingLink: z.boolean().optional(),
|
||||
hashedLink: z.string().nullish(),
|
||||
ethSignature: z.string().optional(),
|
||||
seatReferenceUid: z.string().optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ const ENDPOINTS = [
|
||||
"availability",
|
||||
"bookings",
|
||||
"deploymentSetup",
|
||||
"eth",
|
||||
"eventTypes",
|
||||
"features",
|
||||
"insights",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import ethRouter from "@calcom/app-store/rainbow/trpc/router";
|
||||
import app_RoutingForms from "@calcom/app-store/routing-forms/trpc-router";
|
||||
import { userAdminRouter } from "@calcom/features/ee/users/server/trpc-router";
|
||||
import { featureFlagRouter } from "@calcom/features/flags/server/router";
|
||||
@@ -43,7 +42,6 @@ export const viewerRouter = mergeRouters(
|
||||
// NOTE: Add all app related routes in the bottom till the problem described in @calcom/app-store/trpc-routers.ts is solved.
|
||||
// After that there would just one merge call here for all the apps.
|
||||
appRoutingForms: app_RoutingForms,
|
||||
eth: ethRouter,
|
||||
features: featureFlagRouter,
|
||||
appsRouter,
|
||||
users: userAdminRouter,
|
||||
|
||||
Reference in new issue
Block a user