Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/DeploymentInfo/DeploymentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useGetIfUnsafeDeployment } from '@hooks/useGetIfUnsafeDeployment';
import { ChatBoxTooltip, Spinner, Typography } from '@subql/components';
import { ProjectType } from '@subql/contract-sdk/types';
import { clsx } from 'clsx';
import { toSvg } from 'jdenticon';

import { useChatBoxStore } from 'src/stores/chatbox';

Expand Down Expand Up @@ -55,7 +56,10 @@ export const DeploymentInfo: React.FC<Props> = ({ project, deploymentId, type, m
chatBoxInstance={chatBoxStore.chatBoxRef}
>
<div className={styles.projectInfo}>
<IPFSImage src={project?.image || '/static/default.project.png'} className={styles.ipfsImage} />
<IPFSImage
src={project?.image || `data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project?.name, 500))}`}
className={styles.ipfsImage}
/>

<div
className={styles.projectTextInfo}
Expand Down
6 changes: 5 additions & 1 deletion src/components/DoAllocate/DoAllocate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { parseError, TOKEN } from '@utils';
import { Button, Form, Radio, Tooltip } from 'antd';
import { useForm, useWatch } from 'antd/es/form/Form';
import BigNumber from 'bignumber.js';
import { toSvg } from 'jdenticon';

import { PER_MILL } from 'src/const/const';
import { useWeb3Store } from 'src/stores';
Expand Down Expand Up @@ -294,7 +295,10 @@ const DoAllocate: FC<IProps> = ({ projectId, deploymentId, actionBtn, onSuccess,

<div className="flex" style={{ marginTop: 24 }}>
<IPFSImage
src={project.data?.metadata.image || '/static/default.project.png'}
src={
project.data?.metadata.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project.data?.metadata.name, 500))}`
}
style={{ width: 60, height: 60, borderRadius: 8 }}
></IPFSImage>

Expand Down
7 changes: 6 additions & 1 deletion src/components/DoBooster/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useForm, useWatch } from 'antd/es/form/Form';
import BigNumberJs from 'bignumber.js';
import clsx from 'clsx';
import { ContractReceipt } from 'ethers';
import { toSvg } from 'jdenticon';

import { useWeb3Store } from 'src/stores';

Expand Down Expand Up @@ -248,7 +249,10 @@ const DoBooster: FC<IProps> = ({
</div>
<div className="flex" style={{ marginTop: 24 }}>
<IPFSImage
src={project.data?.metadata.image || '/static/default.project.png'}
src={
project.data?.metadata.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project.data?.metadata.name, 500))}`
}
style={{ width: 60, height: 60, borderRadius: 8 }}
></IPFSImage>

Expand Down Expand Up @@ -329,6 +333,7 @@ const DoBooster: FC<IProps> = ({
type="info"
variant="small"
style={{ transform: 'translateY(-10px)' }}
target="_blank"
>
Get SQT
</Typography.Link>
Expand Down
13 changes: 11 additions & 2 deletions src/components/GetEndpoint/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const GetEndpoint: FC<IProps> = ({ deploymentId, project, initialOpen = false })
const [userHostingPlan, setUserHostingPlan] = useState<IGetHostingPlans[]>([]);
const [userApiKeys, setUserApiKeys] = useState<GetUserApiKeys[]>([]);

const { getHostingPlanApi, checkIfHasLogin, getUserApiKeysApi } = useConsumerHostServices({
const { getHostingPlanApi, checkIfHasLogin, getUserApiKeysApi, createNewApiKey } = useConsumerHostServices({
alert: false,
autoLogin: false,
});
Expand Down Expand Up @@ -316,9 +316,18 @@ const GetEndpoint: FC<IProps> = ({ deploymentId, project, initialOpen = false })
setNextBtnLoading(true);
const hostingPlan = await fetchHostingPlan();

const apiKeys = await getUserApiKeysApi();
let apiKeys = await getUserApiKeysApi();
if (!isConsumerHostError(apiKeys.data)) {
setUserApiKeys(apiKeys.data);
if (!apiKeys.data.find((i) => i.name === specialApiKeyName)) {
await createNewApiKey({
name: specialApiKeyName,
});
apiKeys = await getUserApiKeysApi();
if (!isConsumerHostError(apiKeys.data)) {
setUserApiKeys(apiKeys.data);
}
}
}
return {
hostingPlan,
Expand Down
4 changes: 3 additions & 1 deletion src/components/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { formatSQT } from '@subql/react-hooks';
import { formatNumber, ROUTES, TOKEN } from '@utils';
import BigNumber from 'bignumber.js';
import dayjs from 'dayjs';
import { toSvg } from 'jdenticon';

import { ProjectMetadata } from 'src/models';

Expand All @@ -32,7 +33,8 @@ const ProjectCard: React.FC<Props> = ({ project, href, onClick }) => {
return '';
}

if (!project.metadata.image) return '/static/default.project.png';
if (!project.metadata.image)
return `data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project.metadata.name, 500))}`;

return project.metadata.image;
}, [project.metadata]);
Expand Down
9 changes: 8 additions & 1 deletion src/components/ProjectHeader/ProjectHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Button, Tooltip } from 'antd';
import { BigNumber } from 'bignumber.js';
import clsx from 'clsx';
import dayjs from 'dayjs';
import { toSvg } from 'jdenticon';

import { ETH_TYPE_DICTION, NETWORK_TYPE_DICTION } from 'src/const/const';
import { useProjectStore } from 'src/stores/project';
Expand Down Expand Up @@ -160,7 +161,13 @@ const ProjectHeader: React.FC<Props> = ({
return (
<div className={styles.container}>
<div className={styles.left}>
<IPFSImage src={project.metadata.image || '/static/default.project.png'} className={styles.image} />
<IPFSImage
src={
project.metadata.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project?.metadata.name, 500))}`
}
className={styles.image}
/>
</div>
<div className={styles.inner}>
<div className={styles.upper}>
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useConsumerHostServices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const useConsumerHostServices = (
}

const res = await requestConsumerHostToken(account);
console.warn(res);

if (res.error) {
return {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/dashboard/components/ActiveCard/ActiveCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { filterSuccessPromoiseSettledResult, getMonthProgress, notEmpty } from '
import { useInterval } from 'ahooks';
import { Button, Carousel, Progress, Skeleton } from 'antd';
import dayjs from 'dayjs';
import { toSvg } from 'jdenticon';

import { ProjectMetadata } from 'src/models';

Expand Down Expand Up @@ -134,7 +135,10 @@ export const ActiveCard = () => {
{projects.projects?.nodes.filter(notEmpty).map((project, index) => (
<IPFSImage
key={project.id}
src={projectsMetadata[index]?.image || '/static/default.project.png'}
src={
projectsMetadata[index]?.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(projectsMetadata[index]?.name, 500))}`
}
className={styles.image}
onClick={() => {
navigate(`/explorer/project/${project.id}`);
Expand Down
6 changes: 5 additions & 1 deletion src/pages/indexer/IndexerProfile/IndexerProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import clsx from 'clsx';
import { toChecksumAddress } from 'ethereum-checksum-address';
import { constants } from 'ethers';
import { t } from 'i18next';
import { toSvg } from 'jdenticon';
import { isString } from 'lodash-es';

import { OwnDelegator } from '../MyDelegators/OwnDelegator';
Expand Down Expand Up @@ -185,7 +186,10 @@ const ActiveCard = (props: { account: string }) => {
.map((project) => (
<IPFSImage
key={project.projectId}
src={project.projectMeta.image || '/static/default.project.png'}
src={
project.projectMeta.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project.projectMeta.name, 500))}`
}
className={styles.image}
onClick={() => {
navigate(`/explorer/project/${project.projectId}`);
Expand Down
6 changes: 5 additions & 1 deletion src/pages/projects/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useUpdate } from 'ahooks';
import { Breadcrumb, Button, Form, Input } from 'antd';
import { useForm } from 'antd/es/form/Form';
import clsx from 'clsx';
import { toSvg } from 'jdenticon';

import { ProjectDetails, ProjectType } from 'src/models';

Expand Down Expand Up @@ -246,7 +247,10 @@ const Project: React.FC = () => {

<div style={{ display: 'flex', gap: 24, marginTop: 24 }}>
<IPFSImage
src={project.metadata.image || '/static/default.project.png'}
src={
project.metadata.image ||
`data:image/svg+xml;utf8,${encodeURIComponent(toSvg(project.metadata.name, 500))}`
}
style={{ width: 160, height: 160 }}
/>{' '}
<div className="col-flex" style={{ flex: 1 }}>
Expand Down