mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
Added mainnet check to composeDB port modal
This commit is contained in:
@@ -24,7 +24,7 @@ actions:
|
||||
- name: linkCeramicProfileNode
|
||||
definition:
|
||||
kind: synchronous
|
||||
handler: '{{ACTION_BASE_ENDPOINT}}/ceramic/linkProfileNode'
|
||||
handler: '{{ACTION_BASE_ENDPOINT}}/composeDB/linkProfileNode'
|
||||
forward_client_headers: true
|
||||
permissions:
|
||||
- role: player
|
||||
@@ -53,7 +53,7 @@ actions:
|
||||
- name: updateCachedProfile
|
||||
definition:
|
||||
kind: asynchronous
|
||||
handler: http://host.do{{ACTION_BASE_ENDPOINT}}/composeDB/updateCachedProfile.internal:3000
|
||||
handler: '{{ACTION_BASE_ENDPOINT}}/composeDB/updateCachedProfile'
|
||||
forward_client_headers: true
|
||||
- name: updateQuestCompletion
|
||||
definition:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"start": "node --trace-warnings dist/index.js",
|
||||
"build": "yarn generate && tsc -b",
|
||||
"dev": "tsc --build && concurrently 'tsc --watch --preserveWatchOutput' nodemon 'yarn generate # --watch'",
|
||||
"dev": "tsc --build && concurrently 'tsc --watch --preserveWatchOutput' nodemon",
|
||||
"typecheck": "yarn build",
|
||||
"precommit": "yarn lint-staged",
|
||||
"generate": "graphql-codegen && yarn fix:daohaus-types",
|
||||
|
||||
@@ -47,6 +47,8 @@ export default async (req: Request, res: Response): Promise<void> => {
|
||||
const controllerEthAddress = controller.substring(
|
||||
controller.lastIndexOf(':') + 1,
|
||||
);
|
||||
// controller is something like did:pkh:eip155:137:0x4c81e51aa103490838fd9db1d859a5fcd8276324
|
||||
// make sure this is a mainnet address!
|
||||
if (
|
||||
controller.startsWith('did:pkh') &&
|
||||
controllerEthAddress.toLowerCase() === ethereumAddress.toLowerCase()
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
useToast,
|
||||
} from '@metafam/ds';
|
||||
import {
|
||||
@@ -16,8 +17,10 @@ import {
|
||||
Maybe,
|
||||
} from '@metafam/utils';
|
||||
import { MetaLink } from 'components/Link';
|
||||
import { SwitchNetworkButton } from 'components/SwitchNetworkButton';
|
||||
import { Player } from 'graphql/autogen/types';
|
||||
import { CeramicError } from 'lib/errors';
|
||||
import { useWeb3 } from 'lib/hooks';
|
||||
import { hasuraToComposeDBProfile } from 'lib/hooks/ceramic/usePlayerSetupSaveToComposeDB';
|
||||
import { useSaveToComposeDB } from 'lib/hooks/ceramic/useSaveToComposeDB';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
@@ -42,6 +45,7 @@ export const ComposeDBPromptModal: React.FC<ComposeDBPromptModalProps> = ({
|
||||
}) => {
|
||||
const toast = useToast();
|
||||
const [status, setStatus] = useState(initialStatus);
|
||||
const { chainId } = useWeb3();
|
||||
|
||||
const [profileImageMetadata, setProfileImageMetadata] =
|
||||
useState<Maybe<ComposeDBImageMetadata>>(null);
|
||||
@@ -162,11 +166,20 @@ export const ComposeDBPromptModal: React.FC<ComposeDBPromptModalProps> = ({
|
||||
</MetaLink>
|
||||
for storing profile data.
|
||||
</Box>
|
||||
{/* <Box>What is this?</Box> */}
|
||||
<Box mt={10}>
|
||||
<MetaButton disabled={!areImagesLoaded} onClick={onClick}>
|
||||
{status}
|
||||
</MetaButton>
|
||||
{chainId === '0x1' ? (
|
||||
<>
|
||||
{/* <Box>What is this?</Box> */}
|
||||
<MetaButton disabled={!areImagesLoaded} onClick={onClick}>
|
||||
{status}
|
||||
</MetaButton>
|
||||
</>
|
||||
) : (
|
||||
<Text fontSize="md" w="100%" textAlign="center">
|
||||
Please switch to <SwitchNetworkButton chainId="0x1" /> to
|
||||
progress
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Center>
|
||||
</ModalBody>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { composeDBDefinition, Maybe } from '@metafam/utils';
|
||||
import { CONFIG } from 'config';
|
||||
import { DIDSession } from 'did-session';
|
||||
import { cacheDIDSession, getCachedDIDSession } from 'lib/auth';
|
||||
import { CeramicError } from 'lib/errors';
|
||||
import { useWeb3 } from 'lib/hooks/useWeb3';
|
||||
import { createContext, PropsWithChildren, useCallback, useState } from 'react';
|
||||
import { errorHandler } from 'utils/errorHandler';
|
||||
@@ -33,7 +34,7 @@ const composeDBClient = new ComposeClient({
|
||||
export const ComposeDBContextProvider: React.FC<PropsWithChildren> = ({
|
||||
children,
|
||||
}) => {
|
||||
const { provider } = useWeb3();
|
||||
const { chainId, provider } = useWeb3();
|
||||
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
const [authenticated, setAuthenticated] = useState(false);
|
||||
@@ -66,6 +67,9 @@ export const ComposeDBContextProvider: React.FC<PropsWithChildren> = ({
|
||||
|
||||
const connect = useCallback(async () => {
|
||||
if (provider == null || connecting) return;
|
||||
if (chainId !== '0x1') {
|
||||
throw new CeramicError('ComposeDB should be used on mainnet only');
|
||||
}
|
||||
|
||||
setConnecting(true);
|
||||
|
||||
@@ -86,7 +90,7 @@ export const ComposeDBContextProvider: React.FC<PropsWithChildren> = ({
|
||||
} finally {
|
||||
setConnecting(false);
|
||||
}
|
||||
}, [connecting, createSession, disconnect, provider]);
|
||||
}, [connecting, createSession, disconnect, provider, chainId]);
|
||||
|
||||
return (
|
||||
<ComposeDBContext.Provider
|
||||
|
||||
Reference in New Issue
Block a user