From ed54f645f7527ec2d377c21885907c351068f707 Mon Sep 17 00:00:00 2001 From: drafish Date: Sun, 7 Jul 2024 19:53:27 +0800 Subject: [PATCH] upload logo in quick-dapp --- apps/quick-dapp/package.json | 2 +- apps/quick-dapp/src/actions/index.ts | 12 ++- .../src/components/EditInstance/index.tsx | 80 ++++++++++--------- .../src/components/ImageUpload/index.tsx | 48 +++++++++++ apps/quick-dapp/yarn.lock | 8 +- 5 files changed, 105 insertions(+), 45 deletions(-) create mode 100644 apps/quick-dapp/src/components/ImageUpload/index.tsx diff --git a/apps/quick-dapp/package.json b/apps/quick-dapp/package.json index 73cc34a5d8..b18fa18435 100644 --- a/apps/quick-dapp/package.json +++ b/apps/quick-dapp/package.json @@ -6,6 +6,6 @@ "dependencies": { "@dnd-kit/core": "^6.1.0", "@dnd-kit/sortable": "^8.0.0", - "@drafish/surge-client": "^1.1.4" + "@drafish/surge-client": "^1.1.5" } } diff --git a/apps/quick-dapp/src/actions/index.ts b/apps/quick-dapp/src/actions/index.ts index fa90328401..5bb71c2c12 100644 --- a/apps/quick-dapp/src/actions/index.ts +++ b/apps/quick-dapp/src/actions/index.ts @@ -160,7 +160,7 @@ export const deploy = async (payload: any, callback: any) => { const { data } = await axios.get( // It's the json file contains all the static files paths of dapp-template. // It's generated through the build process automatically. - 'https://remix-dapp.pages.dev/manifest.json' + 'https://dev.remix-dapp.pages.dev/manifest.json' ); let paths: any = []; @@ -174,7 +174,7 @@ export const deploy = async (payload: any, callback: any) => { } }); - const instance = state.instance; + const {logo, ...instance} = state.instance; const files: Record = { 'dir/instance.json': JSON.stringify({ @@ -195,10 +195,12 @@ export const deploy = async (payload: any, callback: any) => { const path = paths[index]; // download all the static files from the dapp-template domain. // here is the codebase of dapp-template: https://github.com/drafish/remix-dapp - const resp = await axios.get(`https://remix-dapp.pages.dev/${path}`); + const resp = await axios.get(`https://dev.remix-dapp.pages.dev/${path}`); files[`dir/${path}`] = resp.data; } + files['dir/logo.png'] = logo + files['dir/index.html'] = files['dir/index.html'].replace( 'assets/css/themes/remix-dark_tvx1s2.css', themeMap[instance.theme].url @@ -295,6 +297,9 @@ export const initInstance = async ({ B: ids.slice(ids.length / 2 + 1), } : { A: ids }; + + const logo = await axios.get('https://dev.remix-dapp.pages.dev/logo.png', { responseType: 'arraybuffer' }) + await dispatch({ type: 'SET_INSTANCE', payload: { @@ -305,6 +310,7 @@ export const initInstance = async ({ natSpec, solcVersion: getVersion(solcVersion), ...lowLevel, + logo: logo.data, }, }); }; diff --git a/apps/quick-dapp/src/components/EditInstance/index.tsx b/apps/quick-dapp/src/components/EditInstance/index.tsx index 72129820e8..0064f24fc4 100644 --- a/apps/quick-dapp/src/components/EditInstance/index.tsx +++ b/apps/quick-dapp/src/components/EditInstance/index.tsx @@ -2,6 +2,7 @@ import { useContext } from 'react'; import { omitBy } from 'lodash'; import { MultipleContainers } from '../MultipleContainers'; import { AppContext } from '../../contexts'; +import ImageUpload from '../ImageUpload' function EditInstance(): JSX.Element { const { appState, dispatch } = useContext(AppContext); @@ -9,43 +10,48 @@ function EditInstance(): JSX.Element { appState.instance; return (
-
- { - dispatch({ - type: 'SET_INSTANCE', - payload: { - title: natSpec.checked && !value ? natSpec.title : value, - userInput: omitBy( - { ...userInput, title: value }, - (item) => item === '' - ), - }, - }); - }} - /> -
-
-