@cowprotocol/widget-lib 0.6.0 → 0.7.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.
Files changed (3) hide show
  1. package/README.md +9 -8
  2. package/package.json +2 -2
  3. package/types.d.ts +0 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@ See the widget in action in the [widget configurator](https://widget.cow.fi)
10
10
 
11
11
  ## Docs
12
12
 
13
- You can find a detailed description of all widget parameters in the [documentation](../../libs/widget-lib/docs/README.md)
13
+ You can find a detailed description of all widget parameters in the [documentation](https://docs.cow.fi/cow-protocol/tutorials/widget)
14
14
 
15
15
  ## Quick start
16
16
 
@@ -31,27 +31,28 @@ Create a container somewhere in your website, the widget will be rendered inside
31
31
  Import the widget and initialise it:
32
32
 
33
33
  ```js
34
- import { cowSwapWidget, CowSwapWidgetParams } from '@cowprotocol/widget-lib'
34
+ import { createCowSwapWidget, CowSwapWidgetParams } from '@cowprotocol/widget-lib'
35
35
 
36
36
  // Initialise the widget
37
37
  const widgetContainer = document.getElementById('cowswap-widget')
38
38
 
39
+ // instantiate your own web3 provider
40
+ const provider = window.ethereum
41
+
39
42
  const params: CowSwapWidgetParams = {
40
- appCode: '<YOUR_APP_KEY>', // Just an unique identifier for your app
43
+ appCode: 'NAME-OF-YOU-APP', // Add here the name of your app. e.g. "Pig Swap"
41
44
  sell: { asset: 'DAI' },
42
45
  buy: { asset: 'USDC', amount: '0.1' },
43
- // instantiate your own web3 provider
44
- provider: window.ethereum,
45
46
  }
46
47
 
47
- const updateWidget = cowSwapWidget(
48
+ const {updateParams} = createCowSwapWidget(
48
49
  widgetContainer,
49
50
  // Optionally, you can provide some additional params to customise your widget
50
- params
51
+ {params, provider}
51
52
  )
52
53
 
53
54
  // You also can change widget configuration on the fly
54
- updateWidget({ ...params, tradeType: 'limit' })
55
+ updateParams({ ...params, tradeType: 'limit' })
55
56
  ```
56
57
 
57
58
  ## Developers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/widget-lib",
3
- "version": "0.6.0",
3
+ "version": "0.7.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": "^0.1.0"
24
+ "@cowprotocol/events": "^0.2.0"
25
25
  }
26
26
  }
package/types.d.ts CHANGED
@@ -122,9 +122,7 @@ export interface CowSwapWidgetParams {
122
122
  tradeType?: TradeType;
123
123
  /**
124
124
  * The base url of the widget implementation
125
- *
126
125
  * The parameter can have the URL directly, or an object with the environment property,
127
- *
128
126
  * The base URL will default to the production environment if not specified, so it will use https://swap.cow.fi by default.
129
127
  */
130
128
  baseUrl?: string;