@cowprotocol/widget-lib 0.7.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.
- package/README.md +9 -8
- package/package.json +1 -1
- 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](
|
|
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 {
|
|
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: '
|
|
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
|
|
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
|
-
|
|
55
|
+
updateParams({ ...params, tradeType: 'limit' })
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
## Developers
|
package/package.json
CHANGED
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;
|