Skip to content

Commit cde5f04

Browse files
committed
unify cow env
1 parent 9ebbe21 commit cde5f04

File tree

7 files changed

+16
-13
lines changed

7 files changed

+16
-13
lines changed

src/components/transactions/CancelCowOrder/CancelCowOrderActions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ActionName, SwapActionFields, TransactionHistoryItem } from 'src/module
88
import { getErrorTextFromError, TxAction } from 'src/ui-config/errorMapping';
99
import { wagmiConfig } from 'src/ui-config/wagmiConfig';
1010

11+
import { COW_ENV } from '../Swap/helpers/cow';
1112
import { TxActionsWrapper } from '../TxActionsWrapper';
1213

1314
// TODO: check with cow if we can cancel adapters orders
@@ -26,7 +27,7 @@ export const CancelCowOrderActions = ({ cowOrder, blocked }: CancelCowOrderActio
2627
setMainTxState({ ...mainTxState, loading: true });
2728
const provider = getEthersProvider(wagmiConfig, { chainId: cowOrder.chainId });
2829
const signer = (await provider).getSigner();
29-
const orderBookApi = new OrderBookApi({ chainId: cowOrder.chainId });
30+
const orderBookApi = new OrderBookApi({ chainId: cowOrder.chainId, env: COW_ENV });
3031
const { signature, signingScheme } = await OrderSigningUtils.signOrderCancellation(
3132
cowOrder.id,
3233
cowOrder.chainId,

src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaCoWAdapters.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ export const CollateralSwapActionsViaCowAdapters = ({
144144

145145
const tradingSdk = await getCowTradingSdkByChainIdAndAppCode(
146146
state.chainId,
147-
APP_CODE_PER_SWAP_TYPE[state.swapType],
148-
'staging'
147+
APP_CODE_PER_SWAP_TYPE[state.swapType]
149148
);
150149
const flashLoanSdk = await getCowFlashLoanSdk(state.chainId);
151150

src/components/transactions/Swap/actions/DebtSwap/DebtSwapActionsViaCoW.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ export const DebtSwapActionsViaCoW = ({
149149

150150
const tradingSdk = await getCowTradingSdkByChainIdAndAppCode(
151151
state.chainId,
152-
APP_CODE_PER_SWAP_TYPE[state.swapType],
153-
'staging'
152+
APP_CODE_PER_SWAP_TYPE[state.swapType]
154153
);
155154
const flashLoanSdk = await getCowFlashLoanSdk(state.chainId);
156155

src/components/transactions/Swap/actions/RepayWithCollateral/RepayWithCollateralActionsViaCoW.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ export const RepayWithCollateralActionsViaCoW = ({
148148

149149
const tradingSdk = await getCowTradingSdkByChainIdAndAppCode(
150150
state.chainId,
151-
APP_CODE_PER_SWAP_TYPE[state.swapType],
152-
'staging'
151+
APP_CODE_PER_SWAP_TYPE[state.swapType]
153152
);
154153
const flashLoanSdk = await getCowFlashLoanSdk(state.chainId);
155154

src/components/transactions/Swap/helpers/cow/env.helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getPublicClient, getWalletClient } from 'wagmi/actions';
66

77
import { APP_CODE_PER_SWAP_TYPE } from '../../constants/shared.constants';
88
import { SwapState } from '../../types';
9+
import { COW_ENV } from './orders.helpers';
910

1011
export const getCowTradingSdk = async (state: SwapState, env: CowEnv = 'prod') => {
1112
return getCowTradingSdkByChainIdAndAppCode(
@@ -18,7 +19,7 @@ export const getCowTradingSdk = async (state: SwapState, env: CowEnv = 'prod') =
1819
export const getCowTradingSdkByChainIdAndAppCode = async (
1920
chainId: number,
2021
appCode: string,
21-
env: CowEnv = 'prod'
22+
env: CowEnv = COW_ENV
2223
) => {
2324
const adapter = await getCowAdapter(chainId);
2425
return new TradingSdk(

src/components/transactions/Swap/helpers/cow/orders.helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers';
22
import {
33
BuyTokenDestination,
4+
CowEnv,
45
OrderBookApi,
56
OrderClass,
67
OrderKind,
@@ -28,6 +29,8 @@ import {
2829
import { OrderType, SwapType } from '../../types';
2930
import { getCowTradingSdkByChainIdAndAppCode } from './env.helpers';
3031

32+
export const COW_ENV: CowEnv = 'staging';
33+
3134
const EIP_2612_PERMIT_ABI = [
3235
{
3336
constant: false,
@@ -218,23 +221,23 @@ export const sendOrder = async ({
218221
};
219222

220223
export const getOrderStatus = async (orderId: string, chainId: number) => {
221-
const orderBookApi = new OrderBookApi({ chainId: chainId });
224+
const orderBookApi = new OrderBookApi({ chainId: chainId, env: COW_ENV });
222225
const status = await orderBookApi.getOrderCompetitionStatus(orderId, {
223226
chainId,
224227
});
225228
return status.type;
226229
};
227230

228231
export const getOrder = async (orderId: string, chainId: number) => {
229-
const orderBookApi = new OrderBookApi({ chainId, env: 'staging' });
232+
const orderBookApi = new OrderBookApi({ chainId, env: COW_ENV });
230233
const order = await orderBookApi.getOrder(orderId, {
231234
chainId,
232235
});
233236
return order;
234237
};
235238

236239
export const getOrders = async (chainId: number, account: string) => {
237-
const orderBookApi = new OrderBookApi({ chainId });
240+
const orderBookApi = new OrderBookApi({ chainId, env: COW_ENV });
238241
const orders = await orderBookApi.getOrders({
239242
owner: account,
240243
});
@@ -401,7 +404,7 @@ export const getRecommendedSlippage = (srcUSD: string) => {
401404
};
402405

403406
export const uploadAppData = async (orderId: string, appDataHex: string, chainId: number) => {
404-
const orderBookApi = new OrderBookApi({ chainId });
407+
const orderBookApi = new OrderBookApi({ chainId, env: COW_ENV });
405408

406409
return orderBookApi.uploadAppData(orderId, appDataHex);
407410
};

src/hooks/useTransactionHistory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
APP_CODE_PER_SWAP_TYPE,
1515
APP_CODE_VALUES,
1616
} from 'src/components/transactions/Swap/constants/shared.constants';
17+
import { COW_ENV } from 'src/components/transactions/Swap/helpers/cow';
1718
import { SwapType } from 'src/components/transactions/Swap/types';
1819
import { getTransactionAction, getTransactionId } from 'src/modules/history/helpers';
1920
import {
@@ -249,7 +250,7 @@ export const useTransactionHistory = ({ isFilterActive }: { isFilterActive: bool
249250
return [];
250251
}
251252

252-
const orderBookApi = new OrderBookApi({ chainId: chainId }); // TODO: use prod for production
253+
const orderBookApi = new OrderBookApi({ chainId: chainId, env: COW_ENV });
253254
const orders = await orderBookApi.getOrders({
254255
owner: account,
255256
limit: first,

0 commit comments

Comments
 (0)