@cowprotocol/widget-lib 0.11.1 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/widget-lib",
3
- "version": "0.11.1",
3
+ "version": "0.13.1",
4
4
  "type": "commonjs",
5
5
  "description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.",
6
6
  "main": "index.js",
package/types.d.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  import { CowEventListeners, CowEventPayloadMap, CowEvents } from '../../events/src/index.ts';
2
2
  import { SupportedChainId } from '@cowprotocol/cow-sdk';
3
3
 
4
- export type { SupportedChainId } from '@cowprotocol/cow-sdk';
4
+ export { SupportedChainId } from '@cowprotocol/cow-sdk';
5
+ export type PerTradeTypeConfig<T> = Partial<Record<TradeType, T>>;
6
+ export type PerNetworkConfig<T> = Partial<Record<SupportedChainId, T>>;
7
+ export type FlexibleConfig<T> = T | PerNetworkConfig<T> | PerTradeTypeConfig<T> | PerTradeTypeConfig<PerNetworkConfig<T>> | PerNetworkConfig<PerTradeTypeConfig<T>>;
5
8
  export declare enum WidgetMethodsEmit {
6
9
  ACTIVATE = "ACTIVATE",
7
10
  UPDATE_HEIGHT = "UPDATE_HEIGHT",
8
11
  SET_FULL_HEIGHT = "SET_FULL_HEIGHT",
9
12
  EMIT_COW_EVENT = "EMIT_COW_EVENT",
10
- PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST"
13
+ PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST",
14
+ INTERCEPT_WINDOW_OPEN = "INTERCEPT_WINDOW_OPEN"
11
15
  }
12
16
  export declare enum WidgetMethodsListen {
13
17
  UPDATE_PARAMS = "UPDATE_PARAMS",
@@ -71,18 +75,16 @@ export declare enum TradeType {
71
75
  }
72
76
  /**
73
77
  * The partner fee
74
- *
75
- * Please contact https://cowprotocol.typeform.com/to/rONXaxHV
76
78
  */
77
79
  export interface PartnerFee {
78
80
  /**
79
81
  * The fee in basis points (BPS). One basis point is equivalent to 0.01% (1/100th of a percent)
80
82
  */
81
- bps: number;
83
+ bps: FlexibleConfig<number>;
82
84
  /**
83
85
  * The Ethereum address of the partner to receive the fee.
84
86
  */
85
- recipient: string | Record<SupportedChainId, string>;
87
+ recipient: FlexibleConfig<string>;
86
88
  }
87
89
  /**
88
90
  * ERC-20 token information
@@ -252,6 +254,7 @@ export interface WidgetMethodsEmitPayloadMap {
252
254
  [WidgetMethodsEmit.UPDATE_HEIGHT]: UpdateWidgetHeightPayload;
253
255
  [WidgetMethodsEmit.SET_FULL_HEIGHT]: SetWidgetFullHeightPayload;
254
256
  [WidgetMethodsEmit.PROVIDER_RPC_REQUEST]: ProviderRpcRequestPayload;
257
+ [WidgetMethodsEmit.INTERCEPT_WINDOW_OPEN]: WindowOpenPayload;
255
258
  }
256
259
  export interface WidgetMethodsListenPayloadMap {
257
260
  [WidgetMethodsListen.UPDATE_APP_DATA]: UpdateAppDataPayload;
@@ -293,6 +296,11 @@ export type WidgetMethodHandler<T extends WidgetMethodsEmit> = (payload: WidgetM
293
296
  export interface ProviderRpcRequestPayload {
294
297
  rpcRequest: JsonRpcRequestMessage;
295
298
  }
299
+ export interface WindowOpenPayload {
300
+ href: string | URL;
301
+ target: string;
302
+ rel: string;
303
+ }
296
304
  export interface JsonRpcRequestMessage {
297
305
  jsonrpc: '2.0';
298
306
  id?: number;