1- import { OrderBookApi , OrderSigningUtils } from '@cowprotocol/cow-sdk' ;
1+ import { AdapterContext , OrderBookApi , OrderSigningUtils } from '@cowprotocol/cow-sdk' ;
22import { Trans } from '@lingui/macro' ;
33import { useQueryClient } from '@tanstack/react-query' ;
44import { useIsWrongNetwork } from 'src/hooks/useIsWrongNetwork' ;
@@ -8,7 +8,7 @@ import { getErrorTextFromError, TxAction } from 'src/ui-config/errorMapping';
88import { wagmiConfig } from 'src/ui-config/wagmiConfig' ;
99import { getWalletClient } from 'wagmi/actions' ;
1010
11- import { COW_ENV } from '../Swap/helpers/cow' ;
11+ import { COW_ENV , getCowAdapter } from '../Swap/helpers/cow' ;
1212import { TxActionsWrapper } from '../TxActionsWrapper' ;
1313
1414// TODO: check with cow if we can cancel adapters orders
@@ -25,8 +25,12 @@ export const CancelCowOrderActions = ({ cowOrder, blocked }: CancelCowOrderActio
2525 const action = async ( ) => {
2626 try {
2727 setMainTxState ( { ...mainTxState , loading : true } ) ;
28+
29+ const adapter = await getCowAdapter ( cowOrder . chainId ) ;
30+ AdapterContext . getInstance ( ) . setAdapter ( adapter ) ;
2831 const orderBookApi = new OrderBookApi ( { chainId : cowOrder . chainId , env : COW_ENV } ) ;
2932 const walletClient = await getWalletClient ( wagmiConfig , { chainId : cowOrder . chainId } ) ;
33+
3034 if ( ! walletClient || ! walletClient . account ) {
3135 throw new Error ( 'Wallet not connected for signing' ) ;
3236 }
0 commit comments