@cowprotocol/widget-lib 0.11.0 → 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/IframeCowEventEmitter.d.ts +2 -1
- package/IframeRpcProviderBridge.d.ts +1 -0
- package/cowSwapWidget.d.ts +2 -1
- package/flexibleConfig.d.ts +6 -0
- package/index.d.ts +1 -0
- package/index.iife.js +91 -1
- package/index.js +91 -1
- package/index.mjs +102123 -174
- package/messages.d.ts +1 -0
- package/package.json +2 -2
- package/themeUtils.d.ts +1 -0
- package/types.d.ts +22 -8
- package/urlUtils.d.ts +1 -0
package/messages.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WidgetMethodsEmit, WidgetMethodsEmitPayloadMap, WidgetMethodsListen, WidgetMethodsListenPayloadMap } from './types';
|
|
2
|
+
|
|
2
3
|
export declare function postMessageToWindow<T extends WidgetMethodsEmit>(contentWindow: Window, method: T, payload: WidgetMethodsEmitPayloadMap[T]): void;
|
|
3
4
|
export declare function postMessageToWindow<T extends WidgetMethodsListen>(contentWindow: Window, method: T, payload: WidgetMethodsListenPayloadMap[T]): void;
|
|
4
5
|
export type WindowListener = (event: MessageEvent<unknown>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/widget-lib",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"widget-lib"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cowprotocol/events": "^1.
|
|
24
|
+
"@cowprotocol/events": "^1.3.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/themeUtils.d.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { CowEventListeners, CowEventPayloadMap, CowEvents } from '../../events/src/index.ts';
|
|
2
|
+
import { SupportedChainId } from '@cowprotocol/cow-sdk';
|
|
3
|
+
|
|
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>>;
|
|
4
8
|
export declare enum WidgetMethodsEmit {
|
|
5
9
|
ACTIVATE = "ACTIVATE",
|
|
6
10
|
UPDATE_HEIGHT = "UPDATE_HEIGHT",
|
|
11
|
+
SET_FULL_HEIGHT = "SET_FULL_HEIGHT",
|
|
7
12
|
EMIT_COW_EVENT = "EMIT_COW_EVENT",
|
|
8
|
-
PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST"
|
|
13
|
+
PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST",
|
|
14
|
+
INTERCEPT_WINDOW_OPEN = "INTERCEPT_WINDOW_OPEN"
|
|
9
15
|
}
|
|
10
16
|
export declare enum WidgetMethodsListen {
|
|
11
17
|
UPDATE_PARAMS = "UPDATE_PARAMS",
|
|
@@ -69,18 +75,16 @@ export declare enum TradeType {
|
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* The partner fee
|
|
72
|
-
*
|
|
73
|
-
* Please contact https://cowprotocol.typeform.com/to/rONXaxHV
|
|
74
78
|
*/
|
|
75
79
|
export interface PartnerFee {
|
|
76
80
|
/**
|
|
77
81
|
* The fee in basis points (BPS). One basis point is equivalent to 0.01% (1/100th of a percent)
|
|
78
82
|
*/
|
|
79
|
-
bps: number
|
|
83
|
+
bps: FlexibleConfig<number>;
|
|
80
84
|
/**
|
|
81
85
|
* The Ethereum address of the partner to receive the fee.
|
|
82
86
|
*/
|
|
83
|
-
recipient: string
|
|
87
|
+
recipient: FlexibleConfig<string>;
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* ERC-20 token information
|
|
@@ -248,7 +252,9 @@ export interface WidgetMethodsEmitPayloadMap {
|
|
|
248
252
|
[WidgetMethodsEmit.ACTIVATE]: void;
|
|
249
253
|
[WidgetMethodsEmit.EMIT_COW_EVENT]: EmitCowEventPayload<CowEvents>;
|
|
250
254
|
[WidgetMethodsEmit.UPDATE_HEIGHT]: UpdateWidgetHeightPayload;
|
|
255
|
+
[WidgetMethodsEmit.SET_FULL_HEIGHT]: SetWidgetFullHeightPayload;
|
|
251
256
|
[WidgetMethodsEmit.PROVIDER_RPC_REQUEST]: ProviderRpcRequestPayload;
|
|
257
|
+
[WidgetMethodsEmit.INTERCEPT_WINDOW_OPEN]: WindowOpenPayload;
|
|
252
258
|
}
|
|
253
259
|
export interface WidgetMethodsListenPayloadMap {
|
|
254
260
|
[WidgetMethodsListen.UPDATE_APP_DATA]: UpdateAppDataPayload;
|
|
@@ -275,6 +281,9 @@ export interface UpdateAppDataPayload {
|
|
|
275
281
|
export interface UpdateWidgetHeightPayload {
|
|
276
282
|
height?: number;
|
|
277
283
|
}
|
|
284
|
+
export interface SetWidgetFullHeightPayload {
|
|
285
|
+
isUpToSmall?: boolean;
|
|
286
|
+
}
|
|
278
287
|
export interface EmitCowEventPayload<T extends CowEvents> {
|
|
279
288
|
event: T;
|
|
280
289
|
payload: CowEventPayloadMap[T];
|
|
@@ -287,6 +296,11 @@ export type WidgetMethodHandler<T extends WidgetMethodsEmit> = (payload: WidgetM
|
|
|
287
296
|
export interface ProviderRpcRequestPayload {
|
|
288
297
|
rpcRequest: JsonRpcRequestMessage;
|
|
289
298
|
}
|
|
299
|
+
export interface WindowOpenPayload {
|
|
300
|
+
href: string | URL;
|
|
301
|
+
target: string;
|
|
302
|
+
rel: string;
|
|
303
|
+
}
|
|
290
304
|
export interface JsonRpcRequestMessage {
|
|
291
305
|
jsonrpc: '2.0';
|
|
292
306
|
id?: number;
|
package/urlUtils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CowSwapWidgetParams } from './types';
|
|
2
|
+
|
|
2
3
|
export declare function buildWidgetUrl(params: Partial<CowSwapWidgetParams>): string;
|
|
3
4
|
export declare function buildWidgetPath(params: Partial<CowSwapWidgetParams>): string;
|
|
4
5
|
export declare function buildWidgetUrlQuery(params: Partial<CowSwapWidgetParams>): URLSearchParams;
|