@@ -481,20 +481,33 @@ export function useUpdateApp() {
481481}
482482
483483export function useRemoveApp ( ) {
484+ const wagmiConfig = useConfig ( )
484485 const { sendTransactionAsync } = useSendTransaction ( )
486+ const { mutateAsync : stopMachine } = useMachineExecuteStopCmd ( )
485487 return useMutation < void , AxiosError < unknown > , { appId : `rofl1${string } `; network : 'mainnet' | 'testnet' } > ( {
486488 mutationFn : async ( { appId, network } ) => {
487489 const sapphireRuntimeId =
488490 network === 'mainnet'
489491 ? oasis . misc . fromHex ( '000000000000000000000000000000000000000000000000f80306c9858e7279' )
490492 : oasis . misc . fromHex ( '000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c' )
491493 const rofl = new oasisRT . rofl . Wrapper ( sapphireRuntimeId )
492- await sendTransactionAsync (
494+ const hash = await sendTransactionAsync (
493495 rofl
494496 . callRemove ( )
495497 . setBody ( { id : oasisRT . rofl . fromBech32 ( appId ) } )
496498 . toSubcall ( ) ,
497499 )
500+ await waitForTransactionReceipt ( wagmiConfig , { hash } )
501+
502+ const machinesResponse = await GetRuntimeRoflmarketInstances ( network , 'sapphire' , {
503+ deployed_app_id : appId ,
504+ } )
505+ const activeMachines = machinesResponse . data . instances . filter ( m => ! m . removed )
506+ console . log ( 'stop machines?' , activeMachines )
507+ for ( const machine of activeMachines ) {
508+ const hash = await stopMachine ( { machineId : machine . id , provider : machine . provider , network } )
509+ await waitForTransactionReceipt ( wagmiConfig , { hash } )
510+ }
498511 } ,
499512 } )
500513}
@@ -544,7 +557,7 @@ export function useMachineExecuteRestartCmd() {
544557export function useMachineExecuteStopCmd ( ) {
545558 const { sendTransactionAsync } = useSendTransaction ( )
546559 return useMutation <
547- void ,
560+ `0x${ string } ` ,
548561 AxiosError < unknown > ,
549562 { machineId : string ; provider : string ; network : 'mainnet' | 'testnet' }
550563 > ( {
@@ -567,7 +580,7 @@ export function useMachineExecuteStopCmd() {
567580
568581 const encodedCommand = oasis . misc . toCBOR ( command )
569582
570- await sendTransactionAsync (
583+ return await sendTransactionAsync (
571584 roflmarket
572585 . callInstanceExecuteCmds ( )
573586 . setBody ( {
0 commit comments