Skip to content

Commit

Permalink
fix(widget-lib): exclude cow-sdk from the bundle (#4681)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Jul 5, 2024
1 parent cf6f037 commit a2eaa3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions libs/widget-lib/src/flexibleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import type { SupportedChainId } from '@cowprotocol/cow-sdk'

import { FlexibleConfig, PerNetworkConfig, PerTradeTypeConfig, TradeType } from './types'

Expand Down Expand Up @@ -30,8 +30,10 @@ export function isPerTradeTypeConfig<T>(config: FlexibleConfig<T>): config is Pe
return Object.keys(config as object).every((key) => TradeTypes.includes(key as TradeType))
}

const D_REGEX = /^\d+$/

export function isPerNetworkConfig<T>(config: FlexibleConfig<T>): config is PerNetworkConfig<T> {
if (typeof config !== 'object') return false

return Object.keys(config as object).every((key) => key in SupportedChainId)
return Object.keys(config as object).every((key) => typeof key === 'number' || D_REGEX.test(key))
}
3 changes: 1 addition & 2 deletions libs/widget-lib/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { SupportedChainId } from '@cowprotocol/cow-sdk'
import { CowEventListeners, CowEventPayloadMap, CowEvents } from '@cowprotocol/events'

export { SupportedChainId } from '@cowprotocol/cow-sdk'
export type { SupportedChainId } from '@cowprotocol/cow-sdk'

export type PerTradeTypeConfig<T> = Partial<Record<TradeType, T>>

Expand Down

0 comments on commit a2eaa3d

Please sign in to comment.