-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Jovells workflow auto sync after pr merge (#4) * Update main.yml * Update main.yml * added comments to custom metamask config * refined bookings * fixed error in buying expts
- Loading branch information
Showing
12 changed files
with
560 additions
and
286 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,69 +1,118 @@ | ||
|
||
import {connectorsForWallets} from "@rainbow-me/rainbowkit"; | ||
import { connectorsForWallets } from "@rainbow-me/rainbowkit"; | ||
import { | ||
injectedWallet, | ||
metaMaskWallet, | ||
walletConnectWallet, | ||
} from '@rainbow-me/rainbowkit/wallets'; | ||
import { configureChains, createConfig } from 'wagmi'; | ||
import { publicProvider } from 'wagmi/providers/public'; | ||
} from "@rainbow-me/rainbowkit/wallets"; | ||
import { configureChains, createConfig } from "wagmi"; | ||
import { publicProvider } from "wagmi/providers/public"; | ||
|
||
import { collection } from "firebase/firestore"; | ||
import { firestore } from "@/lib/firebase"; | ||
|
||
import {chain, envChains} from './contracts' | ||
import { chain, envChains } from "./contracts"; | ||
import { HOME_PAGE } from "@/app/(with wallet)/_components/page-links"; | ||
|
||
const { chains, publicClient } = configureChains( | ||
envChains, | ||
[ | ||
publicProvider() | ||
] | ||
); | ||
const { chains, publicClient } = configureChains(envChains, [publicProvider()]); | ||
|
||
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string | ||
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string; | ||
|
||
const customMetamaskWallet = metaMaskWallet({ projectId, chains }) | ||
customMetamaskWallet.createConnector = () => { | ||
const old = metaMaskWallet({ projectId, chains }).createConnector() | ||
const oldMobileGetUri = old.mobile!.getUri; | ||
old.mobile!.getUri = async () => { | ||
if(window?.ethereum){ | ||
return oldMobileGetUri as any | ||
} | ||
return 'https://metamask.app.link/dapp/'+location.origin+HOME_PAGE | ||
/** | ||
* Creates a custom metamask connector that opens the app in the metamask app if the user is on mobile. | ||
* | ||
*/ | ||
const customMetamaskWallet = metaMaskWallet({ projectId, chains }); | ||
/** | ||
* modify the createConnector function to return a custom connector | ||
*/ | ||
customMetamaskWallet.createConnector = () => { | ||
const newConnector = metaMaskWallet({ projectId, chains }).createConnector(); | ||
const oldMobileGetUri = newConnector.mobile!.getUri; | ||
/** | ||
* modify the getUri function to return a custom uri | ||
*/ | ||
newConnector.mobile!.getUri = async () => { | ||
/** | ||
* if the user is not in the matamask browser, return the default uri | ||
*/ | ||
if (window?.ethereum) { | ||
return oldMobileGetUri as any; | ||
} | ||
return old | ||
} | ||
|
||
const connectors = connectorsForWallets([ | ||
/** | ||
* if the user is in the metamask browser, return a custom uri | ||
*/ | ||
return "https://metamask.app.link/dapp/" + location.origin + HOME_PAGE; | ||
}; | ||
return newConnector; | ||
}; | ||
|
||
const connectors = connectorsForWallets([ | ||
{ | ||
groupName: 'Recommended', | ||
groupName: "Recommended", | ||
wallets: [ | ||
injectedWallet({ chains }), | ||
customMetamaskWallet, | ||
walletConnectWallet({ projectId, chains }), | ||
], | ||
}, | ||
]); | ||
|
||
const wagmiConfig = createConfig({ | ||
autoConnect: true, | ||
connectors, | ||
publicClient | ||
}) | ||
|
||
export const emtChains = chains | ||
export const emtWagmiConfig = wagmiConfig | ||
export {chain} | ||
const wagmiConfig = createConfig({ | ||
autoConnect: true, | ||
connectors, | ||
publicClient, | ||
}); | ||
|
||
export const emtChains = chains; | ||
export const emtWagmiConfig = wagmiConfig; | ||
export { chain }; | ||
|
||
export const USERS_COLLECTION = collection(firestore, "users"); | ||
export const ADMIN_COLLECTION = collection(firestore, "admin"); | ||
export const NOTIFICATIONS_COLLECTION = | ||
process.env.NODE_ENV === "production" | ||
? collection(firestore, "notifications") | ||
: collection( | ||
firestore, | ||
"dev", | ||
String(process.env.NEXT_PUBLIC_DEV!) + chain.id, | ||
"notifications" | ||
); | ||
export const CLAIM_HISTORY_COLLECTION = | ||
process.env.NODE_ENV === "production" | ||
? collection(firestore, "claimHistory") | ||
: collection( | ||
firestore, | ||
"dev", | ||
String(process.env.NEXT_PUBLIC_DEV!) + chain.id, | ||
"claimHistory" | ||
); | ||
export const CONTENTS_COLLECTION = | ||
process.env.NODE_ENV === "production" | ||
? collection(firestore, "contents") | ||
: collection( | ||
firestore, | ||
"dev", | ||
String(process.env.NEXT_PUBLIC_DEV!) + chain.id, | ||
"contents" | ||
); | ||
export const EXPT_LISTINGS_COLLECTION = | ||
process.env.NODE_ENV === "production" | ||
? collection(firestore, "exptListings") | ||
: collection( | ||
firestore, | ||
"dev", | ||
String(process.env.NEXT_PUBLIC_DEV!) + chain.id, | ||
"exptListings" | ||
); | ||
export const BOOKINGS_COLLECTION = | ||
process.env.NODE_ENV === "production" | ||
? collection(firestore, "bookings") | ||
: collection( | ||
firestore, | ||
"dev", | ||
String(process.env.NEXT_PUBLIC_DEV!) + chain.id, | ||
"bookings" | ||
); | ||
|
||
export const USERS_COLLECTION = collection(firestore, 'users'); | ||
export const ADMIN_COLLECTION = collection(firestore, 'admin'); | ||
export const NOTIFICATIONS_COLLECTION = process.env.NODE_ENV === "production"? collection(firestore, 'notifications') : collection(firestore, 'dev', String(process.env.NEXT_PUBLIC_DEV!) + chain.id , 'notifications'); | ||
export const CLAIM_HISTORY_COLLECTION = process.env.NODE_ENV === "production"? collection(firestore, 'claimHistory') : collection(firestore, 'dev', String(process.env.NEXT_PUBLIC_DEV!) + chain.id , 'claimHistory'); | ||
export const CONTENTS_COLLECTION = process.env.NODE_ENV === "production"? collection(firestore, 'contents') : collection(firestore, 'dev', String(process.env.NEXT_PUBLIC_DEV!) + chain.id, 'contents'); | ||
export const EXPT_LISTINGS_COLLECTION = process.env.NODE_ENV === "production"? collection(firestore, 'exptListings') : collection(firestore, 'dev', String(process.env.NEXT_PUBLIC_DEV!) + chain.id, 'exptListings'); | ||
export const BOOKINGS_COLLECTION = process.env.NODE_ENV === "production"? collection(firestore, 'bookings') : collection(firestore, 'dev', String(process.env.NEXT_PUBLIC_DEV!) + chain.id, 'bookings'); | ||
|
||
export const exptLevelKeys = [1, 2, 3] | ||
export const exptLevelKeys = [1, 2, 3]; |
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
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
Oops, something went wrong.