@@ -158,15 +158,7 @@ export const deploy = async (payload: any, callback: any) => {
158
158
}
159
159
}
160
160
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 ;
170
162
171
163
const instanceJson = JSON . stringify ( {
172
164
...instance ,
@@ -179,29 +171,35 @@ export const deploy = async (payload: any, callback: any) => {
179
171
'dir/assets/instance.json' : instanceJson ,
180
172
} ;
181
173
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
+ }
195
197
}
196
198
197
199
if ( logo ) {
198
200
files [ 'dir/assets/logo.png' ] = logo
199
201
}
200
202
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
- ) ;
205
203
206
204
try {
207
205
await surgeClient . publish ( {
@@ -287,8 +285,27 @@ export const initInstance = async ({
287
285
methodIdentifiers,
288
286
devdoc,
289
287
solcVersion,
288
+ htmlTemplate,
290
289
...payload
291
290
} : 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)
292
309
const functionHashes : any = { } ;
293
310
const natSpec : any = { checked : false , methods : { } } ;
294
311
if ( methodIdentifiers && devdoc ) {
@@ -324,18 +341,20 @@ export const initInstance = async ({
324
341
325
342
const abi : any = { } ;
326
343
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
+ }
339
358
const ids = Object . keys ( abi ) ;
340
359
const items =
341
360
ids . length > 2
@@ -345,8 +364,6 @@ export const initInstance = async ({
345
364
}
346
365
: { A : ids } ;
347
366
348
- // const logo = await axios.get('https://dev.remix-dapp.pages.dev/logo.png', { responseType: 'arraybuffer' })
349
-
350
367
await dispatch ( {
351
368
type : 'SET_INSTANCE' ,
352
369
payload : {
@@ -355,9 +372,8 @@ export const initInstance = async ({
355
372
items,
356
373
containers : Object . keys ( items ) ,
357
374
natSpec,
358
- solcVersion : getVersion ( solcVersion ) ,
375
+ solcVersion : solcVersion ? getVersion ( solcVersion ) : { version : '0.8.25' , canReceive : true } ,
359
376
...lowLevel ,
360
- // logo: logo.data,
361
377
} ,
362
378
} ) ;
363
379
} ;
@@ -394,6 +410,7 @@ export const emptyInstance = async () => {
394
410
name : '' ,
395
411
address : '' ,
396
412
network : '' ,
413
+ htmlTemplate : '' ,
397
414
abi : { } ,
398
415
items : { } ,
399
416
containers : [ ] ,
0 commit comments