@@ -2,6 +2,8 @@ import { useNavigate, useParams } from 'react-router-dom';
22import {
33 assert ,
44 BitgoEnv ,
5+ getEip1559Params ,
6+ getEthLikeRecoveryChainId ,
57 includePubsFor ,
68 safeEnv ,
79 updateKeysFromIds ,
@@ -17,6 +19,7 @@ import { GenericEcdsaForm } from '~/containers/BuildUnsignedConsolidation/Generi
1719import { SolForm } from '~/containers/BuildUnsignedConsolidation/SolForm' ;
1820import { SolTokenForm } from '~/containers/BuildUnsignedConsolidation/SolTokenForm' ;
1921import { SuiTokenForm } from '~/containers/BuildUnsignedConsolidation/SuiTokenForm' ;
22+ import { EthLikeForm } from './EthLikeForm' ;
2023
2124type ConsolidationFormProps = {
2225 coin ?: string ;
@@ -361,11 +364,11 @@ function ConsolidationForm({ coin, environment }: ConsolidationFormProps) {
361364 const parentCoin = tokenParentCoins [ coin ] ;
362365 const chainData = await window . queries . getChain ( parentCoin ) ;
363366 const consolidateData = await window . commands . recoverConsolidations ( parentCoin , {
364- ...( await updateKeysFromIds ( parentCoin , values ) ) ,
365- bitgoKey : values . bitgoKey . replace ( / \s + / g, '' ) ,
366- tokenContractAddress : values . packageId ,
367- seed : values . seed ,
368- } ) ;
367+ ...( await updateKeysFromIds ( parentCoin , values ) ) ,
368+ bitgoKey : values . bitgoKey . replace ( / \s + / g, '' ) ,
369+ tokenContractAddress : values . packageId ,
370+ seed : values . seed ,
371+ } ) ;
369372
370373 if ( consolidateData instanceof Error ) {
371374 throw consolidateData ;
@@ -399,6 +402,80 @@ function ConsolidationForm({ coin, environment }: ConsolidationFormProps) {
399402 console . log ( e ) ;
400403 }
401404
405+ setSubmitting ( false ) ;
406+ }
407+ } }
408+ />
409+ ) ;
410+ case 'eth' :
411+ case 'hteth' :
412+ return (
413+ < EthLikeForm
414+ key = { coin }
415+ coinName = { coin }
416+ onSubmit = { async ( values , { setSubmitting } ) => {
417+ setAlert ( undefined ) ;
418+ setSubmitting ( true ) ;
419+ try {
420+ await window . commands . setBitGoEnvironment (
421+ environment ,
422+ coin ,
423+ values . apiKey
424+ ) ;
425+ const chainData = await window . queries . getChain ( coin ) ;
426+
427+ const { maxFeePerGas, maxPriorityFeePerGas, ...rest } =
428+ await updateKeysFromIds ( coin , values ) ;
429+ const recoverData = await window . commands . recoverConsolidations (
430+ coin ,
431+ {
432+ ...rest ,
433+ coinName : coin ,
434+ eip1559 : getEip1559Params (
435+ coin ,
436+ maxFeePerGas ,
437+ maxPriorityFeePerGas
438+ ) ,
439+ replayProtectionOptions : {
440+ chain : getEthLikeRecoveryChainId ( coin , environment ) ,
441+ hardfork : 'london' ,
442+ } ,
443+ bitgoKey : '' ,
444+ ignoreAddressTypes : [ ] ,
445+ }
446+ ) ;
447+
448+ if ( recoverData instanceof Error ) {
449+ throw recoverData ;
450+ }
451+
452+ const showSaveDialogData = await window . commands . showSaveDialog ( {
453+ filters : [
454+ {
455+ name : 'Custom File Type' ,
456+ extensions : [ 'json' ] ,
457+ } ,
458+ ] ,
459+ defaultPath : `~/${ chainData } -unsigned-sweep-${ Date . now ( ) } .json` ,
460+ } ) ;
461+
462+ if ( ! showSaveDialogData . filePath ) {
463+ throw new Error ( 'No file path selected' ) ;
464+ }
465+
466+ await window . commands . writeFile (
467+ showSaveDialogData . filePath ,
468+ JSON . stringify ( recoverData , null , 2 ) ,
469+ { encoding : 'utf-8' }
470+ ) ;
471+
472+ navigate ( `/${ environment } /build-unsigned-sweep/${ coin } /success` ) ;
473+ } catch ( err ) {
474+ if ( err instanceof Error ) {
475+ setAlert ( err . message ) ;
476+ } else {
477+ console . error ( err ) ;
478+ }
402479 setSubmitting ( false ) ;
403480 }
404481 } }
0 commit comments