@@ -158,15 +158,7 @@ export const deploy = async (payload: any, callback: any) => {
158158 }
159159 }
160160
161- const { data } = await axios . get (
162- // It's the json file contains all the static files paths of dapp-template.
163- // It's generated through the build process automatically.
164- `${ window . origin } /plugins/remix-dapp/manifest.json`
165- ) ;
166-
167- const paths = Object . keys ( data ) ;
168-
169- const { logo, ...instance } = state . instance ;
161+ const { logo, htmlTemplate, ...instance } = state . instance ;
170162
171163 const instanceJson = JSON . stringify ( {
172164 ...instance ,
@@ -179,29 +171,35 @@ export const deploy = async (payload: any, callback: any) => {
179171 'dir/assets/instance.json' : instanceJson ,
180172 } ;
181173
182- // console.log(
183- // JSON.stringify({
184- // ...instance,
185- // shareTo: payload.shareTo,
186- // })
187- // );
188-
189- for ( let index = 0 ; index < paths . length ; index ++ ) {
190- const path = paths [ index ] ;
191- // download all the static files from the dapp-template domain.
192- // here is the codebase of dapp-template: https://github.com/drafish/remix-dapp
193- const resp = await axios . get ( `${ window . origin } /plugins/remix-dapp/${ path } ` ) ;
194- files [ `dir/${ path } ` ] = resp . data ;
174+ // Use the HTML template provided by the user instead of downloading dapp-template
175+ if ( htmlTemplate ) {
176+ files [ 'dir/index.html' ] = htmlTemplate ;
177+ } else {
178+ // Fallback to the old method if no HTML template is provided
179+ const { data } = await axios . get (
180+ `${ window . origin } /plugins/remix-dapp/manifest.json`
181+ ) ;
182+
183+ const paths = Object . keys ( data ) ;
184+
185+ for ( let index = 0 ; index < paths . length ; index ++ ) {
186+ const path = paths [ index ] ;
187+ const resp = await axios . get ( `${ window . origin } /plugins/remix-dapp/${ path } ` ) ;
188+ files [ `dir/${ path } ` ] = resp . data ;
189+ }
190+
191+ if ( files [ 'dir/index.html' ] ) {
192+ files [ 'dir/index.html' ] = files [ 'dir/index.html' ] . replace (
193+ 'assets/css/themes/remix-dark_tvx1s2.css' ,
194+ themeMap [ instance . theme ] . url
195+ ) ;
196+ }
195197 }
196198
197199 if ( logo ) {
198200 files [ 'dir/assets/logo.png' ] = logo
199201 }
200202 files [ 'dir/CORS' ] = '*'
201- files [ 'dir/index.html' ] = files [ 'dir/index.html' ] . replace (
202- 'assets/css/themes/remix-dark_tvx1s2.css' ,
203- themeMap [ instance . theme ] . url
204- ) ;
205203
206204 try {
207205 await surgeClient . publish ( {
@@ -287,8 +285,27 @@ export const initInstance = async ({
287285 methodIdentifiers,
288286 devdoc,
289287 solcVersion,
288+ htmlTemplate,
290289 ...payload
291290} : any ) => {
291+ // If HTML template is provided, use simplified initialization
292+ if ( htmlTemplate ) {
293+ await dispatch ( {
294+ type : 'SET_INSTANCE' ,
295+ payload : {
296+ ...payload ,
297+ htmlTemplate,
298+ abi : { } ,
299+ items : { } ,
300+ containers : [ ] ,
301+ natSpec : { checked : false , methods : { } } ,
302+ solcVersion : solcVersion ? getVersion ( solcVersion ) : { version : '0.8.25' , canReceive : true } ,
303+ } ,
304+ } ) ;
305+ return ;
306+ }
307+
308+ // Original ABI-based initialization (kept for backward compatibility)
292309 const functionHashes : any = { } ;
293310 const natSpec : any = { checked : false , methods : { } } ;
294311 if ( methodIdentifiers && devdoc ) {
@@ -324,18 +341,20 @@ export const initInstance = async ({
324341
325342 const abi : any = { } ;
326343 const lowLevel : any = { }
327- payload . abi . forEach ( ( item : any ) => {
328- if ( item . type === 'function' ) {
329- item . id = encodeFunctionId ( item ) ;
330- abi [ item . id ] = item ;
331- }
332- if ( item . type === 'fallback' ) {
333- lowLevel . fallback = item ;
334- }
335- if ( item . type === 'receive' ) {
336- lowLevel . receive = item ;
337- }
338- } ) ;
344+ if ( payload . abi ) {
345+ payload . abi . forEach ( ( item : any ) => {
346+ if ( item . type === 'function' ) {
347+ item . id = encodeFunctionId ( item ) ;
348+ abi [ item . id ] = item ;
349+ }
350+ if ( item . type === 'fallback' ) {
351+ lowLevel . fallback = item ;
352+ }
353+ if ( item . type === 'receive' ) {
354+ lowLevel . receive = item ;
355+ }
356+ } ) ;
357+ }
339358 const ids = Object . keys ( abi ) ;
340359 const items =
341360 ids . length > 2
@@ -345,8 +364,6 @@ export const initInstance = async ({
345364 }
346365 : { A : ids } ;
347366
348- // const logo = await axios.get('https://dev.remix-dapp.pages.dev/logo.png', { responseType: 'arraybuffer' })
349-
350367 await dispatch ( {
351368 type : 'SET_INSTANCE' ,
352369 payload : {
@@ -355,9 +372,8 @@ export const initInstance = async ({
355372 items,
356373 containers : Object . keys ( items ) ,
357374 natSpec,
358- solcVersion : getVersion ( solcVersion ) ,
375+ solcVersion : solcVersion ? getVersion ( solcVersion ) : { version : '0.8.25' , canReceive : true } ,
359376 ...lowLevel ,
360- // logo: logo.data,
361377 } ,
362378 } ) ;
363379} ;
@@ -394,6 +410,7 @@ export const emptyInstance = async () => {
394410 name : '' ,
395411 address : '' ,
396412 network : '' ,
413+ htmlTemplate : '' ,
397414 abi : { } ,
398415 items : { } ,
399416 containers : [ ] ,
0 commit comments