• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cowprotocol / cow-sdk / #1878

25 Jun 2025 10:06AM UTC coverage: 73.99% (-0.2%) from 74.222%
#1878

push

shoom3301
fix(bridge): use gasLimit for hook depending on proxy deployment

613 of 875 branches covered (70.06%)

Branch coverage included in aggregate %.

15 of 26 new or added lines in 9 files covered. (57.69%)

2 existing lines in 2 files now uncovered.

1273 of 1674 relevant lines covered (76.05%)

18.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/bridging/BridgingSdk/getCrossChainOrder.ts
1
import { BridgeProvider, BridgeQuoteResult, BridgeStatus, CrossChainOrder } from '../types'
2

3
import { CowEnv } from '../../common'
4
import { BridgeOrderParsingError } from '../errors'
5
import { SupportedChainId } from '../../chains'
6
import { OrderBookApi } from '../../order-book'
7
import { findBridgeProviderFromHook } from './findBridgeProviderFromHook'
8

9
interface GetCrossChainOrderParams {
10
  chainId: SupportedChainId
11
  orderId: string
12
  orderBookApi: OrderBookApi
13
  providers: BridgeProvider<BridgeQuoteResult>[]
14
  env: CowEnv
15
}
16

17
/**
18
 * Fetch a cross-chain order and its status.
19
 */
20
export async function getCrossChainOrder(params: GetCrossChainOrderParams): Promise<CrossChainOrder | null> {
NEW
21
  const { chainId, orderId, orderBookApi, providers, env } = params
×
22

23
  const chainContext = { chainId, env }
×
24
  const order = await orderBookApi.getOrder(orderId, chainContext)
×
25

26
  // Find the provider by name (note that I could just have use this.provider, but just wanted to leave it ready in case we implement multiple providers)
27
  const provider = order.fullAppData && findBridgeProviderFromHook(order.fullAppData, providers)
×
28
  if (!provider) {
×
29
    throw new BridgeOrderParsingError(
×
30
      `Unknown Bridge provider in order ${order.uid}. Add provider to the SDK config to be able to decode the order`,
31
    )
32
  }
33

34
  // TODO: We might want to decode the bridge appData (reverse the encoding of the call in the provider)
35
  //const bridgeDeposit = await provider.decodeBridgeHook(bridgingHook)
36

37
  // Check if there are any trades for this order
38
  const trades = await orderBookApi.getTrades({ orderUid: order.uid }, chainContext)
×
39

40
  if (trades.length > 0) {
×
41
    // Bridging already initiated
42
    const firstTrade = trades[0]
×
43
    const tradeTxHash = firstTrade.txHash
×
44

45
    if (!tradeTxHash) {
×
46
      throw new BridgeOrderParsingError(
×
47
        `No tx hash found for order ${orderId} . First trade, with log index ${firstTrade.logIndex}`,
48
      )
49
    }
50

51
    // Get bridging id for this order
NEW
52
    const bridgingParams = await provider.getBridgingParams(chainId, orderId, tradeTxHash)
×
53

54
    if (!bridgingParams) {
×
55
      throw new BridgeOrderParsingError(`Bridging params cannot be derived from transaction: ${tradeTxHash}`)
×
56
    }
57

58
    const state: CrossChainOrder = {
×
59
      provider,
60
      chainId,
61
      order,
62
      statusResult: {
63
        status: BridgeStatus.UNKNOWN,
64
      },
65
      bridgingParams,
66
      tradeTxHash,
67
    }
68

69
    try {
×
70
      const statusResult = await provider.getStatus(bridgingParams.bridgingId, chainId)
×
71
      const explorerUrl = provider.getExplorerUrl(bridgingParams.bridgingId)
×
72

73
      return {
×
74
        ...state,
75
        statusResult,
76
        explorerUrl,
77
      }
78
    } catch (e) {
79
      console.error('Cannot get bridging status', e)
×
80
      return state
×
81
    }
82
  }
83

84
  // Bridging not initiated yet
85
  return null
×
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc