Skip to content

Commit

Permalink
composedb ID chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Apr 1, 2024
1 parent f6495f4 commit a8ac464
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const updatePlayerFromComposeDB = async (
({ did } = await Caip10Link.fromAccount(
composeDBClient.context.ceramic,
// mainnet; the site prompts them to switch if necessary
`${ethereumAddress.toLowerCase()}@eip155:1`,
`${ethereumAddress.toLowerCase()}@eip155:10`,
));

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/web/components/ConnectToProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const ConnectToProgress: React.FC<{
const { fetching } = useUser();

if (isConnected && !fetching) {
if (chainId !== 1 && showSwitchButton) {
if (chainId !== 10 && showSwitchButton) {
return (
<Stack w="100%" align="center">
<Stack color="white" spacing={8} w="100%" maxW="30rem">
<MetaGameLogo />
{header && <MetaHeading>{header}</MetaHeading>}
<Text fontSize="md" w="100%" textAlign="center">
Please switch to <SwitchNetworkButton chainId="0x1" /> to progress
Please switch to <SwitchNetworkButton chainId="0xa" /> to progress
</Text>
</Stack>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/EditProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const EditProfileModal: React.FC<EditProfileModalProps> = ({
}
};

if (chainId !== '0x1') {
if (chainId !== '0xa') {
return (
<Modal {...{ isOpen, onClose }}>
<ModalOverlay />
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/Player/PlayerStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const PlayerStart: React.FC = () => {
}, [connected, user, fetching]);

const canRedirect = useMemo(
() => connected && !fetching && chainId === '0x1',
() => connected && !fetching && chainId === '0xa',
[connected, fetching, chainId],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ export const ComposeDBPromptModal: React.FC<ComposeDBPromptModalProps> = ({
</Center>
</ModalBody>
<ModalFooter justifyContent="center">
{chainId === '0x1' ? (
{chainId === '0xa' ? (
<MetaButton disabled={!areImagesLoaded} {...{ onClick }}>
{status}
</MetaButton>
) : (
<Text fontSize="md" w="100%" textAlign="center">
Please switch to <SwitchNetworkButton chainId="0x1" /> to
Please switch to <SwitchNetworkButton chainId="0xa" /> to
progress.
</Text>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/Setup/SetupHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const SetupHeader: React.FC = () => {
);

const { connected, chainId } = useWeb3();
if (!connected || chainId !== '0x1') return null;
if (!connected || chainId !== '0xa') return null;

return (
<Grid templateColumns={templateColumns.join(' ')} gap={[1, 4]} w="full">
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/Setup/WizardPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const WizardPane = <T,>({
}
}, [current, defaultValues, dirtyFields, field, resetField]);

const wrongChain = chainId != null && chainId !== '0x1';
const wrongChain = chainId != null && chainId !== '0xa';
if ((!connecting && !connected) || wrongChain) {
return <WalletNotConnected {...{ wrongChain }} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/SwitchNetworkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NETWORK_INFO } from 'utils/networks';
import { useSwitchChain } from 'wagmi';

export const SwitchNetworkButton: React.FC<{ chainId?: string }> = ({
chainId = '0x1',
chainId = '0xa',
}) => {
const { connected } = useWeb3();
const networkInfo = NETWORK_INFO[chainId];
Expand Down
5 changes: 2 additions & 3 deletions packages/web/contexts/ComposeDBContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const ComposeDBContextProvider: React.FC<PropsWithChildren> = ({
children,
}) => {
const { chainId, provider } = useWeb3();

const [connecting, setConnecting] = useState(false);
const [authenticated, setAuthenticated] = useState(false);

Expand Down Expand Up @@ -67,8 +66,8 @@ 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');
if (chainId !== '0xa') {
throw new CeramicError('ComposeDB should be used on Optimism only');
}

setConnecting(true);
Expand Down
8 changes: 4 additions & 4 deletions packages/web/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import { mainnet, optimism, polygon } from 'wagmi/chains';

const config = createConfig(
getDefaultConfig({
chains: [mainnet, optimism, polygon],
chains: [optimism, polygon, mainnet],
transports: {
[optimism.id]: http(
`https://opt-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`,
),
[mainnet.id]: http(
`https://eth-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`,
),
[polygon.id]: http(
`https://polygon-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`,
),
[optimism.id]: http(
`https://opt-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`,
),
},

// Required API Keys
Expand Down
1 change: 0 additions & 1 deletion packages/web/utils/playerHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Maybe,
profileMapping,
} from '@metafam/utils';
import ProfileIcon from 'assets/generic-user-icon.svg';
import GuildCoverImageFull from 'assets/guild-background-full.jpeg';
import GuildCoverImageSmall from 'assets/guild-background-small.jpeg';
import PlayerCoverImageSmall from 'assets/player-background-small.jpg';
Expand Down

0 comments on commit a8ac464

Please sign in to comment.