@cowprotocol/widget-lib 4.0.2 → 4.0.3
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 +2 -2
- package/types.d.ts +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/widget-lib",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@cowprotocol/cow-sdk": "9.0.2",
|
|
19
19
|
"@cowprotocol/events": "^4.3.1",
|
|
20
|
-
"@cowprotocol/iframe-transport": "^2.2.
|
|
20
|
+
"@cowprotocol/iframe-transport": "^2.2.4"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
package/types.d.ts
CHANGED
|
@@ -5,6 +5,39 @@ export type { OnTradeParamsPayload } from '@cowprotocol/events';
|
|
|
5
5
|
export type PerTradeTypeConfig<T> = Partial<Record<TradeType, T>>;
|
|
6
6
|
export type PerNetworkConfig<T> = Partial<Record<SupportedChainId, T>>;
|
|
7
7
|
export type FlexibleConfig<T> = T | PerNetworkConfig<T> | PerTradeTypeConfig<T> | PerTradeTypeConfig<PerNetworkConfig<T>> | PerNetworkConfig<PerTradeTypeConfig<T>>;
|
|
8
|
+
/**
|
|
9
|
+
* A single forbidden sell→buy token combination for the widget.
|
|
10
|
+
*
|
|
11
|
+
* Used as an entry in {@link CowSwapWidgetParams.tokenPairConstraints} to
|
|
12
|
+
* prevent users from creating orders that swap the given `sell` token for
|
|
13
|
+
* the given `buy` token (in that direction). Reversing the direction —
|
|
14
|
+
* trading `buy` for `sell` — is **not** blocked unless an explicit entry
|
|
15
|
+
* for the reverse pair is also supplied.
|
|
16
|
+
*
|
|
17
|
+
* Addresses are matched case-insensitively against the user's selected
|
|
18
|
+
* tokens; `chainId` must match the active widget chain for the entry to
|
|
19
|
+
* apply.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* tokenPairConstraints: [
|
|
24
|
+
* {
|
|
25
|
+
* sell: { address: '0xA0b8...eB48', chainId: SupportedChainId.MAINNET },
|
|
26
|
+
* buy: { address: '0xdAC1...1ec7', chainId: SupportedChainId.MAINNET },
|
|
27
|
+
* },
|
|
28
|
+
* ]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export type TokenPairConstraint = {
|
|
32
|
+
sell: {
|
|
33
|
+
address: string;
|
|
34
|
+
chainId: SupportedChainId;
|
|
35
|
+
};
|
|
36
|
+
buy: {
|
|
37
|
+
address: string;
|
|
38
|
+
chainId: SupportedChainId;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
8
41
|
export declare enum WidgetMethodsEmit {
|
|
9
42
|
ACTIVATE = "ACTIVATE",
|
|
10
43
|
READY = "READY",
|
|
@@ -362,6 +395,10 @@ export interface CowSwapWidgetParams {
|
|
|
362
395
|
whenPriceImpactIsUnknown?: boolean;
|
|
363
396
|
whenPriceImpactIsHigherThan?: number;
|
|
364
397
|
};
|
|
398
|
+
/**
|
|
399
|
+
* Disables trading of specific token pair
|
|
400
|
+
*/
|
|
401
|
+
tokenPairConstraints?: TokenPairConstraint[];
|
|
365
402
|
hooks?: Partial<{
|
|
366
403
|
onBeforeApproval(payload: OnApprovalPayload): WidgetHookResult;
|
|
367
404
|
onBeforeWrapOrUnwrap(payload: OnTradeParamsPayload): WidgetHookResult;
|